From:             
Operating system: WIN
PHP version:      5.3SVN-2011-01-04 (snap)
Package:          Class/Object related
Bug Type:         Bug
Bug description:Can not define function as an array element of a class property

Description:
------------
The following error is displayed when a function is defined as an array
element of a class property.



Parse error: syntax error, unexpected T_FUNCTION in ...



This error was experienced in PHP 5.3.3 running on Apache 2.2.17 on
Windows.

Test script:
---------------
$funcArray = array(

    'funcName' => function($a){return $a*$a;}

);



echo $funcArray['funcName'](2); // outputs 4 as expected



class testClass{



    public function __construct(){}



    public $funcArray = array(

        'funcName' => function($a){return $a*$a;}

    );

}



// The parse error is thrown for the above class definition at runtime

Expected result:
----------------
I expect the script to run without throwing an error and allow the
definition of a function as an array element of a class property just as is
the case for global arrays defined globally.


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

Reply via email to