1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-13 01:47:22 +01:00
PHP-Parser/test/code/parser/expr/assign.test

297 lines
5.9 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;
// 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
)
2016-08-30 22:11:06 +02:00
15: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: a
)
byRef: false
)
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
)
2016-08-30 22:11:06 +02:00
16: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: a
)
byRef: false
)
1: null
2: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: b
)
byRef: false
)
2011-11-27 11:20:35 +01:00
)
)
expr: Expr_Variable(
name: c
)
)
2016-08-30 22:11:06 +02:00
17: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: a
)
byRef: false
)
1: Expr_List(
items: array(
0: null
1: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: c
)
byRef: false
)
)
)
2: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: d
)
byRef: false
2011-11-27 11:20:35 +01:00
)
)
)
expr: Expr_Variable(
name: e
)
)
2016-08-30 22:11:06 +02:00
18: 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
)
2016-08-30 22:11:06 +02:00
19: Expr_PostInc(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
)
2016-08-30 22:11:06 +02:00
20: Expr_PreDec(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
)
2016-08-30 22:11:06 +02:00
21: Expr_PostDec(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
)
)