mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-01-16 22:58:15 +01:00
Don't drop class statements before error (#952)
When encountering a null statement (indicating that an error occurred), retain the preceding statements. These were accidentally dropped previously. (cherry picked from commit 54103d838734be0499172026525e38cbf6af2711)
This commit is contained in:
parent
481fec47f4
commit
8d50e9d066
@ -816,7 +816,7 @@ static_var:
|
||||
;
|
||||
|
||||
class_statement_list_ex:
|
||||
class_statement_list_ex class_statement { if ($2 !== null) { push($1, $2); } }
|
||||
class_statement_list_ex class_statement { if ($2 !== null) { push($1, $2); } else { $$ = $1; } }
|
||||
| /* empty */ { init(); }
|
||||
;
|
||||
|
||||
|
@ -1935,7 +1935,7 @@ class Php7 extends \PhpParser\ParserAbstract
|
||||
$this->semValue = new Node\StaticVar($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->getAttributes($this->tokenStartStack[$stackPos-(3-1)], $this->tokenEndStack[$stackPos]));
|
||||
},
|
||||
340 => function ($stackPos) {
|
||||
if ($this->semStack[$stackPos-(2-2)] !== null) { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; }
|
||||
if ($this->semStack[$stackPos-(2-2)] !== null) { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; } else { $this->semValue = $this->semStack[$stackPos-(2-1)]; }
|
||||
},
|
||||
341 => function ($stackPos) {
|
||||
$this->semValue = array();
|
||||
|
@ -1953,7 +1953,7 @@ class Php8 extends \PhpParser\ParserAbstract
|
||||
$this->semValue = new Node\StaticVar($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->getAttributes($this->tokenStartStack[$stackPos-(3-1)], $this->tokenEndStack[$stackPos]));
|
||||
},
|
||||
340 => function ($stackPos) {
|
||||
if ($this->semStack[$stackPos-(2-2)] !== null) { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; }
|
||||
if ($this->semStack[$stackPos-(2-2)] !== null) { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; } else { $this->semValue = $this->semStack[$stackPos-(2-1)]; }
|
||||
},
|
||||
341 => function ($stackPos) {
|
||||
$this->semValue = array();
|
||||
|
@ -838,11 +838,12 @@ array(
|
||||
<?php
|
||||
|
||||
class Foo {
|
||||
public $bar1;
|
||||
publi $foo;
|
||||
public $bar;
|
||||
}
|
||||
-----
|
||||
Syntax error, unexpected T_STRING from 4:5 to 4:9
|
||||
Syntax error, unexpected T_STRING from 5:5 to 5:9
|
||||
array(
|
||||
0: Stmt_Class(
|
||||
attrGroups: array(
|
||||
@ -856,6 +857,20 @@ array(
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
attrGroups: array(
|
||||
)
|
||||
flags: PUBLIC (1)
|
||||
type: null
|
||||
props: array(
|
||||
0: PropertyItem(
|
||||
name: VarLikeIdentifier(
|
||||
name: bar1
|
||||
)
|
||||
default: null
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Property(
|
||||
attrGroups: array(
|
||||
)
|
||||
flags: PUBLIC (1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user