|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #47161 Dereferencing for array/function access
Submitted: 2009-01-20 09:08 UTC Modified: 2014-10-12 14:42 UTC
Avg. Score:4.4 ± 1.2
Reproduced:5 of 6 (83.3%)
Same Version:5 (100.0%)
Same OS:5 (100.0%)
From: a at b dot c dot de Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3.0alpha3 OS: Windows (irrelevant)
Private report: No CVE-ID: None
 [2009-01-20 09:08 UTC] a at b dot c dot de
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:
$func = function($a) {
    return function($b)use($a) {
        return $a+$b;

echo $func(5)(3);

Expected result:

Actual result:
Parse error: syntax error, unexpected '(', expecting ',' or ';' in C:\test.php on line 9


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-20 09:17 UTC] 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 :)
 [2011-04-08 20:46 UTC]
-Package: Feature/Change Request +Package: Scripting Engine problem
 [2014-10-12 14:42 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2014-10-12 14:42 UTC]
Supported in PHP 7.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Oct 16 13:03:34 2021 UTC