|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51905 ReflectionParameter fails if default value is an array with an access to self::
Submitted: 2010-05-25 13:23 UTC Modified: 2010-05-26 02:01 UTC
From: soid dot exe at hotmail dot com Assigned: felipe
Status: Closed Package: Scripting Engine problem
PHP Version: 5.2.13, 5.3.x OS: Linux
Private report: No CVE-ID:
 [2010-05-25 13:23 UTC] soid dot exe at hotmail dot com
The problem is similar to but an access to self:: is 
enclosed within an array (see the test script).

Test script:
class Foo {
   const X = 1;
   public function x($x = array(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 not fail

Actual result:
$x :
Fatal error: Cannot access self:: when no class scope is active in 
/home/soid/Code/test.php on line 12


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-26 02:01 UTC]
Automatic comment from SVN on behalf of felipe
Log: - Fixed bug #51905 (ReflectionParameter fails if default value is an array with an access to self::)
 [2010-05-26 02:01 UTC]
-Status: Open +Status: Closed -PHP Version: 5.2.13 +PHP Version: 5.2.13, 5.3.x -Assigned To: +Assigned To: felipe
 [2010-05-26 02:01 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 21:01:31 2015 UTC