[PHP-BUG] Bug #63665 [NEW]: Relative namespace import causes getClass() method to throw an exception
From: dev at jurajsplayground dot com Operating system: Ubuntu PHP version: 5.4.9 Package: Reflection related Bug Type: Bug Bug description:Relative namespace import causes getClass() method to throw an exception Description: While importing of namespaced classes via relative namespace directive works when creating objects, ReflectionParameter::getClass() has a problem with it and throws an exception that such class cannot be found. Test script: --- namespace Foo\Bar; use A\B\BInterface; class Bar implements BarInterface { public function __construct() { echo "Hello!"; } public function getSomething(BInterface $b){} } namespace Foo\Bar; use A\B\BInterface; interface BarInterface { public function getSomething(BInterface $b); } namespace Foo\Bar\A\B; interface BInterface {} namespace TestNamespace; $obj = new \Foo\Bar\Bar(); $ref = new \ReflectionMethod("\\Foo\Bar\Bar", "getSomething"); echo current($ref->getParameters())->getClass(); Expected result: Should display interface information Actual result: -- ReflectionException is thrown: Class A\B\BInterface does not exist -- Edit bug report at https://bugs.php.net/bug.php?id=63665&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63665&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63665&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63665&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63665&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63665&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63665&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63665&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63665&r=oldversion Not developer issue:https://bugs.php.net/fix.php?id=63665&r=support Expected behavior: https://bugs.php.net/fix.php?id=63665&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63665&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63665&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63665&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63665&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63665&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63665&r=isapi Install GNU Sed:https://bugs.php.net/fix.php?id=63665&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63665&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63665&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63665&r=mysqlcfg
[PHP-BUG] Req #63668 [NEW]: Unable to replicate method signature if the method uses "self"
From: dev at jurajsplayground dot com Operating system: Linux/GNU PHP version: 5.4.9 Package: Reflection related Bug Type: Feature/Change Request Bug description:Unable to replicate method signature if the method uses "self" Description: I was trying to mock a ZF class using PHPUnit which has a method that hints a parameter as "self" rather than using the class name. ReflectionParameter::getClass() returns the correct class name, however, there is no way to find out that the actual method signature used "self" rather than the class name. See: https://github.com/sebastianbergmann/phpunit-mock-objects/issues/107 https://github.com/zendframework/zf2/issues/2977 While this behaviour is expected, using echo() on the parameters outputs "Parameter #0 [ self $merge ]" (we can see it's not "Config" but "self") while using getClass() returns the "self" turned into ReflectionClass. Could another method be added to ReflectionParameter that returns the raw "type hint", i.e. "self" so that method's signature can be properly replicated for testing? Test script: --- class Config { public function merge(self $merge){ } } $ref = new ReflectionMethod("Config", "merge"); echo current($ref->getParameters()) , " ", current($ref->getParameters())->getClass()->name; -- Edit bug report at https://bugs.php.net/bug.php?id=63668&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63668&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63668&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63668&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63668&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63668&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63668&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63668&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63668&r=oldversion Not developer issue:https://bugs.php.net/fix.php?id=63668&r=support Expected behavior: https://bugs.php.net/fix.php?id=63668&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63668&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63668&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63668&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63668&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63668&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63668&r=isapi Install GNU Sed:https://bugs.php.net/fix.php?id=63668&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63668&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63668&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63668&r=mysqlcfg