mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-26 20:04:48 +01:00
Move some uses of the toArray() macro
Previously it was applied both to the result of inner_statement_list and statement, whereas only the latter required it.
This commit is contained in:
parent
c7c94f38f1
commit
c88d227597
@ -171,10 +171,10 @@ statement:
|
||||
| T_IF '(' expr ')' statement elseif_list else_single { $$ = Stmt_If[$3, [stmts: toArray($5), elseifs: $6, else: $7]]; }
|
||||
| T_IF '(' expr ')' ':' inner_statement_list new_elseif_list new_else_single T_ENDIF ';'
|
||||
{ $$ = Stmt_If[$3, [stmts: $6, elseifs: $7, else: $8]]; }
|
||||
| T_WHILE '(' expr ')' while_statement { $$ = Stmt_While[$3, toArray($5)]; }
|
||||
| T_WHILE '(' expr ')' while_statement { $$ = Stmt_While[$3, $5]; }
|
||||
| T_DO statement T_WHILE '(' expr ')' ';' { $$ = Stmt_Do [$5, toArray($2)]; }
|
||||
| T_FOR '(' for_expr ';' for_expr ';' for_expr ')' for_statement
|
||||
{ $$ = Stmt_For[[init: $3, cond: $5, loop: $7, stmts: toArray($9)]]; }
|
||||
{ $$ = Stmt_For[[init: $3, cond: $5, loop: $7, stmts: $9]]; }
|
||||
| T_SWITCH '(' expr ')' switch_case_list { $$ = Stmt_Switch[$3, $5]; }
|
||||
| T_BREAK ';' { $$ = Stmt_Break[null]; }
|
||||
| T_BREAK expr ';' { $$ = Stmt_Break[$2]; }
|
||||
@ -189,12 +189,12 @@ statement:
|
||||
| expr ';' { $$ = $1; }
|
||||
| T_UNSET '(' variables_list ')' ';' { $$ = Stmt_Unset[$3]; }
|
||||
| T_FOREACH '(' expr T_AS variable ')' foreach_statement
|
||||
{ $$ = Stmt_Foreach[$3, $5, [keyVar: null, byRef: false, stmts: toArray($7)]]; }
|
||||
{ $$ = Stmt_Foreach[$3, $5, [keyVar: null, byRef: false, stmts: $7]]; }
|
||||
| T_FOREACH '(' expr T_AS '&' variable ')' foreach_statement
|
||||
{ $$ = Stmt_Foreach[$3, $6, [keyVar: null, byRef: true, stmts: toArray($8)]]; }
|
||||
{ $$ = Stmt_Foreach[$3, $6, [keyVar: null, byRef: true, stmts: $8]]; }
|
||||
| T_FOREACH '(' expr T_AS variable T_DOUBLE_ARROW optional_ref variable ')' foreach_statement
|
||||
{ $$ = Stmt_Foreach[$3, $8, [keyVar: $5, byRef: $7, stmts: toArray($10)]]; }
|
||||
| T_DECLARE '(' declare_list ')' declare_statement { $$ = Stmt_Declare[$3, toArray($5)]; }
|
||||
{ $$ = Stmt_Foreach[$3, $8, [keyVar: $5, byRef: $7, stmts: $10]]; }
|
||||
| T_DECLARE '(' declare_list ')' declare_statement { $$ = Stmt_Declare[$3, $5]; }
|
||||
| ';' { $$ = array(); /* means: no statement */ }
|
||||
| T_TRY '{' inner_statement_list '}' catches { $$ = Stmt_TryCatch[$3, $5]; }
|
||||
| T_THROW expr ';' { $$ = Stmt_Throw[$2]; }
|
||||
@ -261,17 +261,17 @@ interface_list:
|
||||
;
|
||||
|
||||
for_statement:
|
||||
statement { $$ = $1; }
|
||||
statement { $$ = toArray($1); }
|
||||
| ':' inner_statement_list T_ENDFOR ';' { $$ = $2; }
|
||||
;
|
||||
|
||||
foreach_statement:
|
||||
statement { $$ = $1; }
|
||||
statement { $$ = toArray($1); }
|
||||
| ':' inner_statement_list T_ENDFOREACH ';' { $$ = $2; }
|
||||
;
|
||||
|
||||
declare_statement:
|
||||
statement { $$ = $1; }
|
||||
statement { $$ = toArray($1); }
|
||||
| ':' inner_statement_list T_ENDDECLARE ';' { $$ = $2; }
|
||||
;
|
||||
|
||||
@ -301,7 +301,7 @@ case_separator:
|
||||
;
|
||||
|
||||
while_statement:
|
||||
statement { $$ = $1; }
|
||||
statement { $$ = toArray($1); }
|
||||
| ':' inner_statement_list T_ENDWHILE ';' { $$ = $2; }
|
||||
;
|
||||
|
||||
|
@ -1107,7 +1107,7 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
protected function yyn33($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Stmt_While($this->yyastk[$this->yysp-(5-3)], is_array($this->yyastk[$this->yysp-(5-5)]) ? $this->yyastk[$this->yysp-(5-5)] : array($this->yyastk[$this->yysp-(5-5)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Stmt_While($this->yyastk[$this->yysp-(5-3)], $this->yyastk[$this->yysp-(5-5)], $line, $docComment);
|
||||
}
|
||||
|
||||
protected function yyn34($line, $docComment) {
|
||||
@ -1115,7 +1115,7 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
protected function yyn35($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Stmt_For(array('init' => $this->yyastk[$this->yysp-(9-3)], 'cond' => $this->yyastk[$this->yysp-(9-5)], 'loop' => $this->yyastk[$this->yysp-(9-7)], 'stmts' => is_array($this->yyastk[$this->yysp-(9-9)]) ? $this->yyastk[$this->yysp-(9-9)] : array($this->yyastk[$this->yysp-(9-9)])), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Stmt_For(array('init' => $this->yyastk[$this->yysp-(9-3)], 'cond' => $this->yyastk[$this->yysp-(9-5)], 'loop' => $this->yyastk[$this->yysp-(9-7)], 'stmts' => $this->yyastk[$this->yysp-(9-9)]), $line, $docComment);
|
||||
}
|
||||
|
||||
protected function yyn36($line, $docComment) {
|
||||
@ -1171,19 +1171,19 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
protected function yyn49($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Stmt_Foreach($this->yyastk[$this->yysp-(7-3)], $this->yyastk[$this->yysp-(7-5)], array('keyVar' => null, 'byRef' => false, 'stmts' => is_array($this->yyastk[$this->yysp-(7-7)]) ? $this->yyastk[$this->yysp-(7-7)] : array($this->yyastk[$this->yysp-(7-7)])), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Stmt_Foreach($this->yyastk[$this->yysp-(7-3)], $this->yyastk[$this->yysp-(7-5)], array('keyVar' => null, 'byRef' => false, 'stmts' => $this->yyastk[$this->yysp-(7-7)]), $line, $docComment);
|
||||
}
|
||||
|
||||
protected function yyn50($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Stmt_Foreach($this->yyastk[$this->yysp-(8-3)], $this->yyastk[$this->yysp-(8-6)], array('keyVar' => null, 'byRef' => true, 'stmts' => is_array($this->yyastk[$this->yysp-(8-8)]) ? $this->yyastk[$this->yysp-(8-8)] : array($this->yyastk[$this->yysp-(8-8)])), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Stmt_Foreach($this->yyastk[$this->yysp-(8-3)], $this->yyastk[$this->yysp-(8-6)], array('keyVar' => null, 'byRef' => true, 'stmts' => $this->yyastk[$this->yysp-(8-8)]), $line, $docComment);
|
||||
}
|
||||
|
||||
protected function yyn51($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Stmt_Foreach($this->yyastk[$this->yysp-(10-3)], $this->yyastk[$this->yysp-(10-8)], array('keyVar' => $this->yyastk[$this->yysp-(10-5)], 'byRef' => $this->yyastk[$this->yysp-(10-7)], 'stmts' => is_array($this->yyastk[$this->yysp-(10-10)]) ? $this->yyastk[$this->yysp-(10-10)] : array($this->yyastk[$this->yysp-(10-10)])), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Stmt_Foreach($this->yyastk[$this->yysp-(10-3)], $this->yyastk[$this->yysp-(10-8)], array('keyVar' => $this->yyastk[$this->yysp-(10-5)], 'byRef' => $this->yyastk[$this->yysp-(10-7)], 'stmts' => $this->yyastk[$this->yysp-(10-10)]), $line, $docComment);
|
||||
}
|
||||
|
||||
protected function yyn52($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Stmt_Declare($this->yyastk[$this->yysp-(5-3)], is_array($this->yyastk[$this->yysp-(5-5)]) ? $this->yyastk[$this->yysp-(5-5)] : array($this->yyastk[$this->yysp-(5-5)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Stmt_Declare($this->yyastk[$this->yysp-(5-3)], $this->yyastk[$this->yysp-(5-5)], $line, $docComment);
|
||||
}
|
||||
|
||||
protected function yyn53($line, $docComment) {
|
||||
@ -1291,7 +1291,7 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
protected function yyn79($line, $docComment) {
|
||||
$this->yyval = $this->yyastk[$this->yysp-(1-1)];
|
||||
$this->yyval = is_array($this->yyastk[$this->yysp-(1-1)]) ? $this->yyastk[$this->yysp-(1-1)] : array($this->yyastk[$this->yysp-(1-1)]);
|
||||
}
|
||||
|
||||
protected function yyn80($line, $docComment) {
|
||||
@ -1299,7 +1299,7 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
protected function yyn81($line, $docComment) {
|
||||
$this->yyval = $this->yyastk[$this->yysp-(1-1)];
|
||||
$this->yyval = is_array($this->yyastk[$this->yysp-(1-1)]) ? $this->yyastk[$this->yysp-(1-1)] : array($this->yyastk[$this->yysp-(1-1)]);
|
||||
}
|
||||
|
||||
protected function yyn82($line, $docComment) {
|
||||
@ -1307,7 +1307,7 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
protected function yyn83($line, $docComment) {
|
||||
$this->yyval = $this->yyastk[$this->yysp-(1-1)];
|
||||
$this->yyval = is_array($this->yyastk[$this->yysp-(1-1)]) ? $this->yyastk[$this->yysp-(1-1)] : array($this->yyastk[$this->yysp-(1-1)]);
|
||||
}
|
||||
|
||||
protected function yyn84($line, $docComment) {
|
||||
@ -1359,7 +1359,7 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
protected function yyn96($line, $docComment) {
|
||||
$this->yyval = $this->yyastk[$this->yysp-(1-1)];
|
||||
$this->yyval = is_array($this->yyastk[$this->yysp-(1-1)]) ? $this->yyastk[$this->yysp-(1-1)] : array($this->yyastk[$this->yysp-(1-1)]);
|
||||
}
|
||||
|
||||
protected function yyn97($line, $docComment) {
|
||||
|
Loading…
Reference in New Issue
Block a user