Bug #52250 [Opn->Asn]: ReflectionParameter::getDefaultValue for array with consts
| From: | johannes@php.net | Date: | Mon, 05 Jul 2010 11:50:01 +0000 |
| Subject: | Bug #52250 [Opn->Asn]: ReflectionParameter::getDefaultValue for array with consts | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-152098@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52250&edit=1
ID: 52250
Updated by: johannes@php.net
Reported by: nikita at rusoft dot ru
Summary: ReflectionParameter::getDefaultValue for array with
consts
-Status: Open
+Status: Assigned
Type: Bug
Package: Reflection related
Operating System: linux
PHP Version: 5.2.13
-Assigned To:
+Assigned To: johannes
Previous Comments:
------------------------------------------------------------------------
[2010-07-05 10:52:32] nikita at rusoft dot ru
Description:
------------
If I used ReflectionParameter for method parametr that include default
value with
array, I couldn't get its defaultValue.
Fatal error is throws:
"PHP Fatal error: Undefined class constant 'self::CONST_NAME' in
/path/file.php
on line NNN".
See test script.
Tested on php 5.2.13, php 5.3.2.
Test script:
---------------
<?php
class A {
const B = 'BB';
const C = 'CC';
public function some(array $param = array(self::B, self::C))
{
var_export($param);
}
}
$refClass = new ReflectionClass('A');
$refMethods = $refClass->getMethod('some')->getParameters();
$refMethod = array_pop($refMethods);
if ($refMethod->isDefaultValueAvailable()) {
var_export($refMethod->getDefaultValue()); //Fatal error
}
Expected result:
----------------
array (
0 => 'BB',
1 => 'CC',
)
Actual result:
--------------
PHP Fatal error: Cannot access self:: when no class scope is active in
test.php
on line 15
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52250&edit=1