#47161 [NEW]: Dereferencing for array/function access
| From: | a at b dot c dot de | Date: | Tue, 20 Jan 2009 09:08:52 +0000 |
| Subject: | #47161 [NEW]: Dereferencing for array/function access | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-133045@lists.php.net to get a copy of this message | ||
From: a at b dot c dot de
Operating system: Windows (irrelevant)
PHP version: 5.3.0alpha3
PHP Bug Type: Feature/Change Request
Bug description: Dereferencing for array/function access
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 bug report at http://bugs.php.net/?id=47161&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47161&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47161&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47161&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=47161&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47161&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=47161&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=47161&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=47161&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=47161&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=47161&r=support
Expected behavior: http://bugs.php.net/fix.php?id=47161&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=47161&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=47161&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=47161&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47161&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47161&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=47161&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=47161&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=47161&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=47161&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=47161&r=mysqlcfg