mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-26 20:04:48 +01:00
Recover from foreach without as
This commit is contained in:
parent
2b0bd657bb
commit
fa99c3fbfb
@ -1,7 +1,10 @@
|
||||
Version 4.0.2-dev
|
||||
-----------------
|
||||
|
||||
Nothing yet.
|
||||
### Added
|
||||
|
||||
* Improved error recovery inside classes.
|
||||
* Support error recovery for `foreach` without `as`.
|
||||
|
||||
Version 4.0.1 (2018-03-25)
|
||||
--------------------------
|
||||
|
@ -240,6 +240,8 @@ non_empty_statement:
|
||||
{ $$ = Stmt\Foreach_[$3, $5[0], ['keyVar' => null, 'byRef' => $5[1], 'stmts' => $7]]; }
|
||||
| T_FOREACH '(' expr T_AS variable T_DOUBLE_ARROW foreach_variable ')' foreach_statement
|
||||
{ $$ = Stmt\Foreach_[$3, $7[0], ['keyVar' => $5, 'byRef' => $7[1], 'stmts' => $9]]; }
|
||||
| T_FOREACH '(' expr error ')' foreach_statement
|
||||
{ $$ = Stmt\Foreach_[$3, new Expr\Error(stackAttributes(#4)), ['stmts' => $6]]; }
|
||||
| T_DECLARE '(' declare_list ')' declare_statement { $$ = Stmt\Declare_[$3, $5]; }
|
||||
| T_TRY '{' inner_statement_list '}' catches optional_finally
|
||||
{ $$ = Stmt\TryCatch[$3, $5, $6]; $this->checkTryCatch($$); }
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -987,3 +987,46 @@ array(
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
|
||||
foreach ($foo) { $bar; }
|
||||
foreach ($foo as ) { $bar; }
|
||||
-----
|
||||
!!php7
|
||||
Syntax error, unexpected ')' from 3:14 to 3:14
|
||||
Syntax error, unexpected ')' from 4:18 to 4:18
|
||||
array(
|
||||
0: Stmt_Foreach(
|
||||
expr: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
keyVar: null
|
||||
byRef: false
|
||||
valueVar: Expr_Error(
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_Expression(
|
||||
expr: Expr_Variable(
|
||||
name: bar
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Foreach(
|
||||
expr: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
keyVar: null
|
||||
byRef: false
|
||||
valueVar: Expr_Error(
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_Expression(
|
||||
expr: Expr_Variable(
|
||||
name: bar
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue
Block a user