|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-03-10 22:19 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 03:00:01 2025 UTC |
In that case i must understand anythink completely wrong or... ---code class Foo { function myMeth($param0){} } $class = new ReflectionClass('Foo'); $params = $class->getMethod('myMeth')->getParameters(); var_dump($params[0]->getDeclaringClass()); ---output NULL ---end ...NULL is the declaring class.