#38465 [Opn->Asn]: ReflectionParameter fails if default value is an access to self::

From: Date: Mon, 18 Sep 2006 10:59:54 +0000
Subject: #38465 [Opn->Asn]: ReflectionParameter fails if default value is an access to self::
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-102325@lists.php.net to get a copy of this message
ID: 38465 Updated by: tony2001@php.net Reported By: baldurien at bbnwn dot eu -Status: Open +Status: Assigned Bug Type: Scripting Engine problem Operating System: Windows XP PHP Version: 5.1.4 -Assigned To: +Assigned To: helly Previous Comments: ------------------------------------------------------------------------ [2006-08-15 10:55:25] baldurien at bbnwn dot eu 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 this bug report at http://bugs.php.net/?id=38465&edit=1

« previous php.bugs (#102325) next »