Req #65612 [NEW]: Calling the result of a function call as a function causes a parse error

From: Date: Wed, 04 Sep 2013 08:08:06 +0000
Subject: Req #65612 [NEW]: Calling the result of a function call as a function causes a parse error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-181420@lists.php.net to get a copy of this message
From:             tdammers at gmail dot com
Operating system: Any (debian wheezy e.a.)
PHP version:      Irrelevant
Package:          Compile Failure
Bug Type:         Feature/Change Request
Bug description:Calling the result of a function call as a function causes a parse error

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 bug report at https://bugs.php.net/bug.php?id=65612&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=65612&r=trysnapshot54
Try a snapshot (PHP 5.3):   https://bugs.php.net/fix.php?id=65612&r=trysnapshot53
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=65612&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=65612&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=65612&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=65612&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=65612&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=65612&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=65612&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=65612&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=65612&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=65612&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=65612&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65612&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=65612&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=65612&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=65612&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65612&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=65612&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65612&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#181420) next »