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

 ID:               51083
 Updated by:       [email protected]
 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

Reply via email to