Bug #74726 [Opn->Nab]: Cannot call closure from static class member

From: Date: Fri, 09 Jun 2017 13:26:51 +0000
Subject: Bug #74726 [Opn->Nab]: Cannot call closure from static class member
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209448@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74726&edit=1 ID: 74726 Updated by: cmb@php.net Reported by: matteo_tassinari_TM at libero dot it Summary: Cannot call closure from static class member -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Linux PHP Version: 7.0.20 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php See <https://3v4l.org/bpsFf> on one way to do it. Note that as of PHP 7.0.0 you can also use the following: (T::$f)(); Previous Comments: ------------------------------------------------------------------------ [2017-06-09 08:56:21] matteo_tassinari_TM at libero dot it Description: ------------ If you declare a closure as a static member of a class, you cannot call it directly. Test script: --------------- class T { public static $f; } T::$f = function() { echo "static member\n"; }; $f = function() { echo "local variable\n"; }; $f(); T::$f(); Expected result: ---------------- local variable static member Actual result: -------------- local variable Fatal error: Uncaught Error: Function name must be a string ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74726&edit=1

« previous php.bugs (#209448) next »