1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-26 20:04:48 +01:00

Improve error recovery in classes (#492)

This commit is contained in:
Nikita Popov 2018-03-30 16:03:03 +02:00
parent e4a54fa90a
commit 7208b1c7ac
3 changed files with 709 additions and 669 deletions

View File

@ -514,7 +514,7 @@ static_var:
;
class_statement_list:
class_statement_list class_statement { push($1, $2); }
class_statement_list class_statement { if ($2 !== null) { push($1, $2); } }
| /* empty */ { init(); }
;
@ -527,6 +527,7 @@ class_statement:
{ $$ = Stmt\ClassMethod[$4, ['type' => $1, 'byRef' => $3, 'params' => $6, 'returnType' => $8, 'stmts' => $9]];
$this->checkClassMethod($$, #1); }
| T_USE class_name_list trait_adaptations { $$ = Stmt\TraitUse[$2, $3]; }
| error { $$ = null; /* will be skipped */ }
;
trait_adaptations:

File diff suppressed because it is too large Load Diff

View File

@ -953,3 +953,37 @@ array(
)
)
)
-----
<?php
class Foo {
publi $foo;
public $bar;
}
-----
!!php7
Syntax error, unexpected T_STRING from 4:5 to 4:9
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: Foo
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_Property(
flags: MODIFIER_PUBLIC (1)
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: bar
)
default: null
)
)
)
)
)
)