From:             
Operating system: linux
PHP version:      5.2.13
Package:          Reflection related
Bug Type:         Bug
Bug description:ReflectionParameter::getDefaultValue for array with consts

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 bug report at http://bugs.php.net/bug.php?id=52250&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52250&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52250&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52250&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52250&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52250&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52250&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52250&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52250&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52250&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52250&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52250&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52250&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52250&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52250&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52250&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52250&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52250&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52250&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52250&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52250&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52250&r=mysqlcfg

Reply via email to