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

 ID:                 65530
 Updated by:         yohg...@php.net
 Reported by:        matt dot minix at gmail dot com
 Summary:            Anonymous functions not callable directly when part
                     of a static class
-Status:             Open
+Status:             Verified
 Type:               Bug
-Package:            Variables related
+Package:            Scripting Engine problem
 Operating System:   Linux
-PHP Version:        5.4.18
+PHP Version:        5.4 and later
 Block user comment: N
 Private report:     N

 New Comment:

PHP behaves as reported. It does not work 5.5 also.

[yohgaki@dev PHP-5.5]$ ./sapi/cli/php
<?php
class a { 
    public static $b; 
}   

a::$b = static function($c) { echo $c; };
a::$b('Test')

?>

Fatal error: Function name must be a string in - on line 7


Previous Comments:
------------------------------------------------------------------------
[2013-08-22 21:19:27] matt dot minix at gmail dot com

Description:
------------
An anonymous function doesn't seem like it can be called directly when in a 
static 
class.





Test script:
---------------
class a { 
    public static $b; 
}   

a::$b = static function($c) { echo $c; };
a::$b('Test');

I am however able to do 

class a { 
    public static $b; 
}   

a::$b = static function($c) { echo $c; };
$Temp = a::$b;
$Temp('Test');


Expected result:
----------------
"Test"

Actual result:
--------------
Fatal error: Function name must be a string


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



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

Reply via email to