Req #61252 [Opn->Csd]: Add ability to directly execute a closure

From: Date: Sun, 12 Oct 2014 15:06:43 +0000
Subject: Req #61252 [Opn->Csd]: Add ability to directly execute a closure
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188039@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61252&edit=1 ID: 61252 Updated by: nikic@php.net Reported by: alex dot pilon at gmail dot com Summary: Add ability to directly execute a closure -Status: Open +Status: Closed Type: Feature/Change Request Package: Scripting Engine problem Operating System: linux PHP Version: 5.4.0 -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: Supported in PHP 7, if you wrap the closure in some parens. Previous Comments: ------------------------------------------------------------------------ [2012-03-02 20:30:11] alex dot pilon at gmail dot com Description: ------------ You cannot directly execute a closure. Prevents code such as <?php $condition ? function () { // path a }() : function () { // path b }(); Which can be useful in various cases. Test script: --------------- <?php function () { echo 'test'; }(); function () { echo 'tickle'; }->__invoke(); Expected result: ---------------- testtickle Actual result: -------------- PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in php shell code on line 1 PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in php shell code on line 1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61252&edit=1

« previous php.bugs (#188039) next »