1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-11 17:09:41 +01:00
PHP-Parser/test/code/parser/expr/assign.test

288 lines
5.4 KiB
Plaintext
Raw Normal View History

2011-11-27 11:20:35 +01:00
Assignments
-----
<?php
// simple assign
$a = $b;
// combined assign
$a &= $b;
$a |= $b;
$a ^= $b;
$a .= $b;
$a /= $b;
$a -= $b;
$a %= $b;
$a *= $b;
$a += $b;
$a <<= $b;
$a >>= $b;
2014-03-26 19:18:16 +01:00
$a **= $b;
// chained assign
$a = $b *= $c **= $d;
2011-11-27 11:20:35 +01:00
// by ref assign
$a =& $b;
$a =& new B;
// list() assign
list($a) = $b;
list($a, , $b) = $c;
list($a, list(, $c), $d) = $e;
// inc/dec
++$a;
$a++;
--$a;
$a--;
-----
array(
0: Expr_Assign(
var: Expr_Variable(
name: a
comments: array(
0: // simple assign
)
2011-11-27 11:20:35 +01:00
)
expr: Expr_Variable(
name: b
)
comments: array(
0: // simple assign
)
2011-11-27 11:20:35 +01:00
)
1: Expr_AssignOp_BitwiseAnd(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
comments: array(
0: // combined assign
)
2011-11-27 11:20:35 +01:00
)
expr: Expr_Variable(
name: b
)
comments: array(
0: // combined assign
)
2011-11-27 11:20:35 +01:00
)
2: Expr_AssignOp_BitwiseOr(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
3: Expr_AssignOp_BitwiseXor(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
4: Expr_AssignOp_Concat(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
5: Expr_AssignOp_Div(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
6: Expr_AssignOp_Minus(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
7: Expr_AssignOp_Mod(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
8: Expr_AssignOp_Mul(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
9: Expr_AssignOp_Plus(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
10: Expr_AssignOp_ShiftLeft(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
11: Expr_AssignOp_ShiftRight(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
2014-03-26 19:18:16 +01:00
12: Expr_AssignOp_Pow(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
13: Expr_Assign(
var: Expr_Variable(
name: a
comments: array(
0: // chained assign
)
2014-03-26 19:18:16 +01:00
)
expr: Expr_AssignOp_Mul(
var: Expr_Variable(
name: b
)
expr: Expr_AssignOp_Pow(
var: Expr_Variable(
name: c
)
expr: Expr_Variable(
name: d
)
)
)
comments: array(
0: // chained assign
)
2014-03-26 19:18:16 +01:00
)
14: Expr_AssignRef(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
comments: array(
0: // by ref assign
)
2011-11-27 11:20:35 +01:00
)
expr: Expr_Variable(
name: b
)
comments: array(
0: // by ref assign
)
2011-11-27 11:20:35 +01:00
)
2014-03-26 19:18:16 +01:00
15: Expr_AssignRef(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
expr: Expr_New(
class: Name(
parts: array(
0: B
)
)
args: array(
)
)
)
2014-03-26 19:18:16 +01:00
16: Expr_Assign(
var: Expr_List(
vars: array(
0: Expr_Variable(
name: a
)
2011-11-27 11:20:35 +01:00
)
comments: array(
0: // list() assign
)
2011-11-27 11:20:35 +01:00
)
expr: Expr_Variable(
name: b
)
comments: array(
0: // list() assign
)
2011-11-27 11:20:35 +01:00
)
2014-03-26 19:18:16 +01:00
17: Expr_Assign(
var: Expr_List(
vars: array(
0: Expr_Variable(
name: a
)
1: null
2: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
expr: Expr_Variable(
name: c
)
)
2014-03-26 19:18:16 +01:00
18: Expr_Assign(
var: Expr_List(
vars: array(
0: Expr_Variable(
name: a
)
1: Expr_List(
vars: array(
0: null
1: Expr_Variable(
name: c
)
)
)
2: Expr_Variable(
name: d
2011-11-27 11:20:35 +01:00
)
)
)
expr: Expr_Variable(
name: e
)
)
2014-03-26 19:18:16 +01:00
19: Expr_PreInc(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
comments: array(
0: // inc/dec
)
2011-11-27 11:20:35 +01:00
)
2014-03-26 19:18:16 +01:00
20: Expr_PostInc(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
)
2014-03-26 19:18:16 +01:00
21: Expr_PreDec(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
)
2014-03-26 19:18:16 +01:00
22: Expr_PostDec(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
)
)