Req #51083 [Opn]: Closures returned by functions/methods must be stored to be executed...
| From: | kalle@php.net | Date: | Sat, 06 Mar 2010 11:17:02 +0000 |
| Subject: | Req #51083 [Opn]: Closures returned by functions/methods must be stored to be executed... | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-148329@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51083&edit=1
ID: 51083
Updated by: kalle@php.net
Reported by: adam dot jorgensen dot za at gmail dot com
Summary: Closures returned by functions/methods must be stored
to be executed...
Status: Open
Type: Feature/Change Request
Package: Feature/Change Request
Operating System: Linux
PHP Version: 5.3.1
New Comment:
Function call chaining is not supported in any versions of php, its was
however
decided at the May 2009 PDM to implement it together with array
dereferencing in
PHP6.
Previous Comments:
------------------------------------------------------------------------
[2010-02-18 15:02:43] adam dot jorgensen dot za at gmail dot com
Description:
------------
When returning an anonymous function from a method or function call, the
returned closure is not directly executable in a logical fashion. The
closure needs to be stored in order to be executed or must be called via
the call_user_func family of functions.
This is fairly illogical and inconsistent with the idea of closures.
Reproduce code:
---------------
function test($a)
{
return function($b) use($a) { echo $a . ':' . $b . '<br/>'; };
}
call_user_func(test(1), 2);
$x = test(1);
$x(2);
test(1)(2);
Expected result:
----------------
Output should be:
1:2
1:2
1:2
Actual result:
--------------
Execution fails. Error:
PHP Parse error: syntax error, unexpected '('
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51083&edit=1