#33312 [NEW]: ReflectionParameter methods do not work correctly

From: Date: Sat, 11 Jun 2005 14:03:12 +0000
Subject: #33312 [NEW]: ReflectionParameter methods do not work correctly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-80160@lists.php.net to get a copy of this message
From: sb at sebastian-bergmann dot de Operating system: Windows XP PHP version: 5CVS-2005-06-11 (dev) PHP Bug Type: Zend Engine 2 problem Bug description: ReflectionParameter methods do not work correctly Description: ------------ The ReflectionParameter::isDefaultValueAvailable() and ReflectionParameter::getDefaultValue() methods only work correctly when the method only has one parameter. When the method has more than one parameter, ReflectionParameter::isDefaultValueAvailable() returns FALSE for a parameter that has a default value and ReflectionParameter::getDefaultValue() produces an error when trying to access the default value. The reproducing script below works fine with the current PHP_5_0 branch. With HEAD it prints nothing. Only after removing "Foo $foo, " from the method signature does it print "bar". Reproduce code: --------------- <?php class Foo { public function bar(Foo $foo, $bar = 'bar') { } } $class = new ReflectionClass('Foo'); $method = $class->getMethod('bar'); foreach ($method->getParameters() as $parameter) { if ($parameter->isDefaultValueAvailable()) { print $parameter->getDefaultValue(); } } ?> Expected result: ---------------- bar -- Edit bug report at http://bugs.php.net/?id=33312&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33312&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33312&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33312&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33312&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33312&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33312&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33312&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33312&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33312&r=support Expected behavior: http://bugs.php.net/fix.php?id=33312&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33312&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33312&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33312&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33312&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33312&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33312&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33312&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33312&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33312&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33312&r=mysqlcfg

« previous php.bugs (#80160) next »