Bug #65530 [Opn->Ver]: Anonymous functions not callable directly when part of a static class
| From: | yohgaki@php.net | Date: | Mon, 26 Aug 2013 09:51:28 +0000 |
| Subject: | Bug #65530 [Opn->Ver]: Anonymous functions not callable directly when part of a static class | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-181200@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65530&edit=1
ID: 65530
Updated by: yohgaki@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