Req #47161 [Opn->Csd]: Dereferencing for array/function access

From: Date: Sun, 12 Oct 2014 14:42:39 +0000
Subject: Req #47161 [Opn->Csd]: Dereferencing for array/function access
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188033@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=47161&edit=1 ID: 47161 Updated by: nikic@php.net Reported by: a at b dot c dot de Summary: Dereferencing for array/function access -Status: Open +Status: Closed Type: Feature/Change Request Package: Scripting Engine problem Operating System: Windows (irrelevant) PHP Version: 5.3.0alpha3 -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: Supported in PHP 7. Previous Comments: ------------------------------------------------------------------------ [2009-01-20 09:17:17] a at b dot c dot de Perhaps I should just add.... although I reference Bug #23022, I'm not asking for this to be over _arbitrary_ expressions, only arrays and callables. I don't want this language turning into Perl :) ------------------------------------------------------------------------ [2009-01-20 09:08:50] a at b dot c dot de Description: ------------ See Bug #23022. Since we can have arrays that contain arrays, arrays that contain functions, functions that return arrays and functions return functions; and since both arrays and functions effectively define mappings between their arguments/indices and their values; and since we can already dereference array accesses into higher dimensions (i.e., we can write $foo[1][2]); I would like to be able to do the same thing with the other three cases. The bug cited above asks for $foo(1)[2]; I'd like to add a request for $foo[1](2) and $foo(1)(2). Please, sir: can we have these? Reproduce code: --------------- <?php $func = function($a) { return function($b)use($a) { return $a+$b; }; }; echo $func(5)(3); ?> Expected result: ---------------- 8 Actual result: -------------- Parse error: syntax error, unexpected '(', expecting ',' or ';' in C:\test.php on line 9 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=47161&edit=1

« previous php.bugs (#188033) next »