ID: 50003 User updated by: melfar at gmail dot com Reported By: melfar at gmail dot com Status: Open Bug Type: Feature/Change Request Operating System: agnostic PHP Version: 5.3.0 New Comment:
Not sure how to attach a file. The proposed patch is as follows. --- a/Zend/zend_language_parser.y.orig 2009-10-26 18:13:56.000000000 +0300 +++ b/Zend/zend_language_parser.y 2009-10-26 21:20:19.000000000 +0300 @@ -47,7 +47,7 @@ %} %pure_parser -%expect 2 +%expect 6 %left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE %left ',' @@ -874,6 +874,11 @@ variable_class_name: ; base_variable_with_function_calls: + raw_base_variable_with_function_calls { $$ = $1; } + | raw_base_variable_with_function_calls '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); } +; + +raw_base_variable_with_function_calls: base_variable { $$ = $1; } | function_call { zend_do_begin_variable_parse(TSRMLS_C); $$ = $1; $$.u.EA.type = ZEND_PARSED_FUNCTION_CALL; } ; Previous Comments: ------------------------------------------------------------------------ [2009-10-26 18:45:24] melfar at gmail dot com Description: ------------ PHP parser doesn't allow for array index operation to be used on a result of a function call. I propose a patch to allow such a construction. Reproduce code: --------------- <?php function car_brands() { return array("chevy", "hummer"); } print car_brands()[1] . "\n"; ?> Expected result: ---------------- "hummer" Actual result: -------------- Parse error: syntax error, unexpected '[' in test.php on line 5 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50003&edit=1