#38465 [NEW]: ReflectionParameter fails if default value is an access to self::

From: Date: Tue, 15 Aug 2006 10:55:26 +0000
Subject: #38465 [NEW]: ReflectionParameter fails if default value is an access to self::
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-100822@lists.php.net to get a copy of this message
From: baldurien at bbnwn dot eu Operating system: Windows XP PHP version: 5.1.4 PHP Bug Type: Scripting Engine problem Bug description: ReflectionParameter fails if default value is an access to self:: Description: ------------ While it is possible to use a class constant as default parameter, and while it is possible to use in the form of "self::X", this does not work when we try to reflect such parameter (see below). It was tested with php5.1.4 (my default version), php5.2-win32-200608150830, and php6.0-win32-200608150830. If using a class constant as a default parameter is not possible, then it should be said in the doc : http://fr.php.net/manual/en/language.oop5.paamayim-nekudotayim.php Don't not say much. Reproduce code: --------------- class Foo { const X = 1; public function x($x = self::X) {} } $clazz = new ReflectionClass('Foo'); $method = $clazz->getMethod('x'); foreach ($method->getParameters() as $param) { if ( $param->isDefaultValueAvailable()) echo '$', $param->getName(), ' : ', $param->getDefaultValue(), "\n"; } Expected result: ---------------- should work, eg: display $x = 1 Actual result: -------------- Fatal error: Cannot access self:: when no class scope is active in D:\documents\xxx\desktop\php6.0-win32-200608150830\truc.php on line 10 -- Edit bug report at http://bugs.php.net/?id=38465&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38465&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38465&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38465&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38465&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38465&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38465&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38465&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38465&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38465&r=support Expected behavior: http://bugs.php.net/fix.php?id=38465&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38465&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38465&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38465&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38465&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38465&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38465&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38465&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38465&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38465&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38465&r=mysqlcfg

« previous php.bugs (#100822) next »