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 [ <required> 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

Reply via email to