Forbid "=& new" in PHP 7 mode

This commit is contained in:
Nikita Popov 2016-08-30 22:11:06 +02:00
parent 81f7da3b23
commit 13f7321def
4 changed files with 538 additions and 519 deletions

View File

@ -512,7 +512,6 @@ expr:
| list_expr '=' expr { $$ = Expr\Assign[$1, $3]; }
| variable '=' expr { $$ = Expr\Assign[$1, $3]; }
| variable '=' '&' variable { $$ = Expr\AssignRef[$1, $4]; }
| variable '=' '&' new_expr { $$ = Expr\AssignRef[$1, $4]; }
| new_expr { $$ = $1; }
| T_CLONE expr { $$ = Expr\Clone_[$2]; }
| variable T_PLUS_EQUAL expr { $$ = Expr\AssignOp\Plus [$1, $3]; }

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,6 @@ $a = $b *= $c **= $d;
// by ref assign
$a =& $b;
$a =& new B;
// list() assign
list($a) = $b;
@ -191,21 +190,7 @@ array(
0: // by ref assign
)
)
15: Expr_AssignRef(
var: Expr_Variable(
name: a
)
expr: Expr_New(
class: Name(
parts: array(
0: B
)
)
args: array(
)
)
)
16: Expr_Assign(
15: Expr_Assign(
var: Expr_List(
vars: array(
0: Expr_Variable(
@ -223,7 +208,7 @@ array(
0: // list() assign
)
)
17: Expr_Assign(
16: Expr_Assign(
var: Expr_List(
vars: array(
0: Expr_Variable(
@ -239,7 +224,7 @@ array(
name: c
)
)
18: Expr_Assign(
17: Expr_Assign(
var: Expr_List(
vars: array(
0: Expr_Variable(
@ -262,7 +247,7 @@ array(
name: e
)
)
19: Expr_PreInc(
18: Expr_PreInc(
var: Expr_Variable(
name: a
)
@ -270,17 +255,17 @@ array(
0: // inc/dec
)
)
20: Expr_PostInc(
19: Expr_PostInc(
var: Expr_Variable(
name: a
)
)
21: Expr_PreDec(
20: Expr_PreDec(
var: Expr_Variable(
name: a
)
)
22: Expr_PostDec(
21: Expr_PostDec(
var: Expr_Variable(
name: a
)

View File

@ -0,0 +1,39 @@
Assigning new by reference (PHP 5 only)
-----
<?php
$a =& new B;
-----
!!php5
array(
0: Expr_AssignRef(
var: Expr_Variable(
name: a
)
expr: Expr_New(
class: Name(
parts: array(
0: B
)
)
args: array(
)
)
)
)
-----
<?php
$a =& new B;
-----
!!php7
Syntax error, unexpected T_NEW from 2:7 to 2:9
array(
0: Expr_New(
class: Name(
parts: array(
0: B
)
)
args: array(
)
)
)