ID: 36687
User updated by: elias at adaptiveinstance dot com
Reported By: elias at adaptiveinstance dot com
Status: Open
Bug Type: Feature/Change Request
Operating System: *
PHP Version: 5CVS-2006-03-10 (snap)
Assigned To: johannes
New Comment:
Alias or not, getDeclaringClass does not return the 'declaring' class
and i don't think someone expects this.
getTypeHintClass sounds good.
Previous Comments:
------------------------------------------------------------------------
[2006-03-11 17:08:21] [EMAIL PROTECTED]
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().
------------------------------------------------------------------------
[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