Req #53357 [NEW]: Problem with getMethod of ReflectionClass
| From: | jonas dot jones at gmx dot ch | Date: | Fri, 19 Nov 2010 15:31:24 +0000 |
| Subject: | Req #53357 [NEW]: Problem with getMethod of ReflectionClass | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-156227@lists.php.net to get a copy of this message | ||
From:
Operating system: Windows 7/all
PHP version: 5.3.3
Package: Reflection related
Bug Type: Feature/Change Request
Bug description:Problem with getMethod of ReflectionClass
Description:
------------
---
From manual page: http://www.php.net/reflectionclass.getmethod
---
If you use getMethod() on a ReflecitonClass Object, for a class, that
inherits its method from a parent class, you get a ReflectionMethod Object,
that links to the parent class. There is no possibility to get a
ReflectionMethod Object, that is connected to the class linked to the
ReflectionClass Object.
This beheaviour is not nice, if you want to use the ReflectionMethod Object
to call a static method. We could not figure out a possibility to call the
method on the child class.
A second argument on getMethod() would be nice. It could be a flag, wether
getMethod should return a ReflectionMethod object, which is connected to
the class where the method was defined or an object which is connected to
the class, that was used for the ReflectionClass.
Test script:
---------------
class ParentClass {
public static function foo(){
echo get_called_class();
}
}
class ChildClass extends MainClass {
}
$class = new ReflectionClass('ChildClass');
$method = $class->getMethod('foo');
$method->invoke(null); // outputs ParentClass instead of expected
ChildClass
Expected result:
----------------
ChildClass
Actual result:
--------------
ParentClass
--
Edit bug report at http://bugs.php.net/bug.php?id=53357&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53357&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53357&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53357&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53357&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53357&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53357&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53357&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53357&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53357&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53357&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53357&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53357&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53357&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53357&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53357&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53357&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53357&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53357&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53357&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53357&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53357&r=mysqlcfg