Bug #66376 [NEW]: ReflectionClass::getPrototype returns ReflectionMethod which does not exist
| From: | rudgergravestein at gmail dot com | Date: | Tue, 31 Dec 2013 12:53:40 +0000 |
| Subject: | Bug #66376 [NEW]: ReflectionClass::getPrototype returns ReflectionMethod which does not exist | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-183512@lists.php.net to get a copy of this message | ||
From: rudgergravestein at gmail dot com
Operating system: Ubuntu 12.04.2 LTS
PHP version: 5.4.23
Package: Reflection related
Bug Type: Bug
Bug description:ReflectionClass::getPrototype returns ReflectionMethod which does not exist
Description:
------------
Specific PHP version: PHP 5.4.23-1+sury.org~precise+1
ReflectionMethod::getPrototype â Gets the method prototype (if there
is one).
Executing ReflectionClass::getPrototype on class methods, with the class
using traits, returns a ReflectionClass with reference to non-existing
class methods (these are trait methods).
Test script:
---------------
<?php
trait t {
function f() {
//do stuff
}
}
class a {
function f() {
// do stuff
}
}
class c extends a {
use t;
}
$class = new ReflectionClass('c');
foreach ($class->getMethods() as $method) {
try {
printf('method %s::%s%s', $method->class, $method->name,
PHP_EOL);
$prototype = $method->getPrototype();
printf('prototype %s::%s%s', $prototype->class,
$prototype->name, PHP_EOL);
} catch (\ReflectionException $e) {
printf('%s%s', $e->getMessage(), PHP_EOL);
}
}
Expected result:
----------------
Two possible expected results:
method c::f
prototype a::f
or
method c::f
Method c::f does not have a prototype
Actual result:
--------------
method c::f
prototype c::f
--
Edit bug report at https://bugs.php.net/bug.php?id=66376&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66376&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66376&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66376&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66376&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66376&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66376&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66376&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66376&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66376&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66376&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66376&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66376&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66376&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66376&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66376&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66376&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66376&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66376&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66376&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66376&r=mysqlcfg