ID: 36687
Updated by: [EMAIL PROTECTED]
Reported By: elias at adaptiveinstance dot com
Status: Open
-Bug Type: Class/Object related
+Bug Type: Feature/Change Request
-Operating System: linux
+Operating System: *
PHP Version: 5CVS-2006-03-10 (snap)
-Assigned To:
+Assigned To: johannes
New Comment:
getClass() is an alias for getDeclaringClass() in 5.1 and will be
dropped in later versions.
What you want is a new method maybe named getParameterClass() or
getTypeHintClass().
Previous Comments:
------------------------------------------------------------------------
[2006-03-10 22:19:12] elias at adaptiveinstance dot com
Description:
------------
The method ReflectionParameter::getDeclaringClass() always return the
wrong result. I should reaturn the reflection object of the declaring
class and not that of the typehint class.
Further this method has been introduced somewhere between php 5.0.5 and
5.1.3, but the documentation doesn't mention it.
Reproduce code:
---------------
class OtherClass {}
class MyClass
{
function myMeth(OtherClass $param0, $param1){}
}
$class = new ReflectionClass('MyClass');
$params = $class->getMethod('myMeth')->getParameters();
var_dump($params[0]->getDeclaringClass());
var_dump($params[0]->getClass());
var_dump($params[1]->getDeclaringClass());
var_dump($params[1]->getClass());
Expected result:
----------------
object(ReflectionClass)#2 (1) {
["name"]=>
string(10) "MyClass"
}
object(ReflectionClass)#2 (1) {
["name"]=>
string(10) "OtherClass"
}
object(ReflectionClass)#2 (1) {
["name"]=>
string(10) "MyClass"
}
NULL
Actual result:
--------------
object(ReflectionClass)#2 (1) {
["name"]=>
string(10) "OtherClass"
}
object(ReflectionClass)#2 (1) {
["name"]=>
string(10) "OtherClass"
}
NULL
NULL
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36687&edit=1