Req #65612 [Opn]: Calling the result of a function call as a function causes a parse error
Edit report at https://bugs.php.net/bug.php?id=65612&edit=1
ID: 65612
Updated by: aharvey@php.net
Reported by: tdammers at gmail dot com
Summary: Calling the result of a function call as a function
causes a parse error
Status: Open
Type: Feature/Change Request
-Package: Compile Failure
+Package: Scripting Engine problem
Operating System: Any (debian wheezy e.a.)
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Relevant RFC (that never went anywhere, AFAIR):
https://wiki.php.net/rfc/fcallfcall
Previous Comments:
------------------------------------------------------------------------
[2013-09-04 08:08:06] tdammers at gmail dot com
Description:
------------
Calling the return value from a function as a function directly (without storing the return value in
an intermediate variable) results in a parse error. Apparently, the PHP parser does not understand
foo()() or (foo())().
Test script:
---------------
<?php
function foo($a) {
return function ($b) use ($a) {
print "$a, $b!\n";
};
}
foo("Hello")("world");
Expected result:
----------------
Program prints "Hello, world!"
Actual result:
--------------
PHP Parse error: syntax error, unexpected '(' in /home/tobias/test/test.php on line 9
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65612&edit=1
Thread (4 messages)