diff --git a/grammar/php5.y b/grammar/php5.y index 2897f67..943e933 100644 --- a/grammar/php5.y +++ b/grammar/php5.y @@ -939,7 +939,7 @@ list_expr_elements: list_expr_element: variable { $$ = Expr\ArrayItem[$1, null, false]; } - | list_expr { $$ = $1; } + | list_expr { $$ = Expr\ArrayItem[$1, null, false]; } | /* empty */ { $$ = null; } ; diff --git a/grammar/php7.y b/grammar/php7.y index 17e3847..5c9d586 100644 --- a/grammar/php7.y +++ b/grammar/php7.y @@ -823,7 +823,7 @@ list_expr_elements: list_expr_element: variable { $$ = Expr\ArrayItem[$1, null, false]; } - | list_expr { $$ = $1; } + | list_expr { $$ = Expr\ArrayItem[$1, null, false]; } | expr T_DOUBLE_ARROW variable { $$ = Expr\ArrayItem[$3, $1, false]; } | expr T_DOUBLE_ARROW list_expr { $$ = Expr\ArrayItem[$3, $1, false]; } | /* empty */ { $$ = null; } diff --git a/lib/PhpParser/Parser/Php5.php b/lib/PhpParser/Parser/Php5.php index 5ed211f..46d31db 100644 --- a/lib/PhpParser/Parser/Php5.php +++ b/lib/PhpParser/Parser/Php5.php @@ -3035,7 +3035,7 @@ class Php5 extends \PhpParser\ParserAbstract } protected function reduceRule523() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; + $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(1-1)], null, false, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); } protected function reduceRule524() { diff --git a/lib/PhpParser/Parser/Php7.php b/lib/PhpParser/Parser/Php7.php index 100c561..1727dd9 100644 --- a/lib/PhpParser/Parser/Php7.php +++ b/lib/PhpParser/Parser/Php7.php @@ -2657,7 +2657,7 @@ class Php7 extends \PhpParser\ParserAbstract } protected function reduceRule460() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; + $this->semValue = new Expr\ArrayItem($this->semStack[$this->stackPos-(1-1)], null, false, $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); } protected function reduceRule461() { diff --git a/test/code/parser/expr/assign.test b/test/code/parser/expr/assign.test index 95dcff2..1d6b187 100644 --- a/test/code/parser/expr/assign.test +++ b/test/code/parser/expr/assign.test @@ -246,17 +246,21 @@ array( ) byRef: false ) - 1: Expr_List( - items: array( - 0: null - 1: Expr_ArrayItem( - key: null - value: Expr_Variable( - name: c + 1: Expr_ArrayItem( + key: null + value: Expr_List( + items: array( + 0: null + 1: Expr_ArrayItem( + key: null + value: Expr_Variable( + name: c + ) + byRef: false ) - byRef: false ) ) + byRef: false ) 2: Expr_ArrayItem( key: null