Edit report at http://bugs.php.net/bug.php?id=53652&edit=1

 ID:                 53652
 Updated by:         [email protected]
 Reported by:        jerry at jmweb dot net
 Summary:            Can not define function as an array element of a
                     class property
 Status:             Open
-Type:               Bug
+Type:               Feature/Change Request
 Package:            Class/Object related
 Operating System:   WIN
 PHP Version:        5.3SVN-2011-01-04 (snap)
 Block user comment: N
 Private report:     N

 New Comment:

This is currently an expected behavior.



Changed to Feature request.


Previous Comments:
------------------------------------------------------------------------
[2011-01-04 19:14:37] jerry at jmweb dot net

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 this bug report at http://bugs.php.net/bug.php?id=53652&edit=1

Reply via email to