php.net |  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 (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.2.13, 5.3.x OS: Linux
Private report: No CVE-ID: None
 [2010-05-25 13:23 UTC] soid dot exe at hotmail dot com
Description:
------------
The problem is similar to http://bugs.php.net/38465 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-26 02:01 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=299766
Log: - Fixed bug #51905 (ReflectionParameter fails if default value is an array with an access to self::)
 [2010-05-26 02:01 UTC] felipe@php.net
-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] felipe@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 07:01:29 2024 UTC