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

 ID:                 55078
 Updated by:         larue...@php.net
 Reported by:        charlie at charliesomerville dot com
 Summary:            Can't use anonymous function inside array
                     declaration inside a class
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

"(propeties) This declaration may include an initialization, but this 
initialization must be a constant value--that is, it must be able to be 
evaluated at compile time and must not depend on run-time information in order 
to be evaluated."
http://www.php.net/manual/pt_BR/language.oop5.properties.php

lambda is a dynamic expression like :

function lambda() use ($variable) {
}

so, we should not allow lambda in class properties initialization.


Previous Comments:
------------------------------------------------------------------------
[2012-11-23 04:38:30] nickmokisasian at gmail dot com

When will this feature be supported?

------------------------------------------------------------------------
[2011-07-01 18:46:57] fel...@php.net

This is just more one limitation, not a bug. Changing to feature request.
Thanks.

------------------------------------------------------------------------
[2011-06-29 23:54:37] charlie at charliesomerville dot com

Description:
------------
You can't declare an anonymous function in an array declaration inside a class 
declaration.

Test script:
---------------
<?php

class Foo
{
        static $array = array("hi" => function() {
                phpinfo();
        });
}

Foo::$array["hi"]();

Expected result:
----------------
phpinfo being displayed

Actual result:
--------------
Parse error: syntax error, unexpected T_FUNCTION in /path/to/script.php on line 
5


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55078&edit=1

Reply via email to