Fix parsing of $foo =& new Bar;

By-reference assignments of new expressions are now parsed as AssignRef
(instead of just Assign).

Closes issue #31.
This commit is contained in:
nikic 2012-07-23 11:36:47 +02:00
parent a81cccff7f
commit 5a947e9843
4 changed files with 4 additions and 4 deletions

View File

@ -1,7 +1,7 @@
Version 0.9.3-dev
-----------------
Nothing yet.
* Fix parsing of `$foo =& new Bar`. It is now properly parsed as `AssignRef` (instead of `Assign`).
Version 0.9.2 (07.07.2012)
--------------------------

View File

@ -498,7 +498,7 @@ expr:
| T_LIST '(' assignment_list ')' '=' expr { $$ = Expr_AssignList[$3, $6]; }
| variable '=' expr { $$ = Expr_Assign[$1, $3]; }
| variable '=' '&' variable { $$ = Expr_AssignRef[$1, $4]; }
| variable '=' '&' new_expr { $$ = Expr_Assign[$1, $4]; } /* reference dropped intentially */
| variable '=' '&' new_expr { $$ = Expr_AssignRef[$1, $4]; }
| new_expr { $$ = $1; }
| T_CLONE expr { $$ = Expr_Clone[$2]; }
| variable T_PLUS_EQUAL expr { $$ = Expr_AssignPlus [$1, $3]; }

View File

@ -1765,7 +1765,7 @@ class PHPParser_Parser
}
protected function yyn179($attributes) {
$this->yyval = new PHPParser_Node_Expr_Assign($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-4)], $attributes);
$this->yyval = new PHPParser_Node_Expr_AssignRef($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-4)], $attributes);
}
protected function yyn180($attributes) {

View File

@ -137,7 +137,7 @@ array(
name: b
)
)
13: Expr_Assign(
13: Expr_AssignRef(
var: Expr_Variable(
name: a
)