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

381 lines
8.7 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;
$a ??= $b;
2014-03-26 19:18:16 +01:00
// 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(
2017-01-19 22:25:22 +01:00
0: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: a
comments: array(
0: // simple assign
)
)
expr: Expr_Variable(
name: b
)
comments: array(
0: // simple assign
)
2011-11-27 11:20:35 +01:00
)
comments: array(
0: // simple assign
)
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
1: Stmt_Expression(
expr: Expr_AssignOp_BitwiseAnd(
var: Expr_Variable(
name: a
comments: array(
0: // combined assign
)
)
expr: Expr_Variable(
name: b
)
comments: array(
0: // combined assign
)
2011-11-27 11:20:35 +01:00
)
comments: array(
0: // combined assign
)
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
2: Stmt_Expression(
expr: Expr_AssignOp_BitwiseOr(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
3: Stmt_Expression(
expr: Expr_AssignOp_BitwiseXor(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
4: Stmt_Expression(
expr: Expr_AssignOp_Concat(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
5: Stmt_Expression(
expr: Expr_AssignOp_Div(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
6: Stmt_Expression(
expr: Expr_AssignOp_Minus(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
7: Stmt_Expression(
expr: Expr_AssignOp_Mod(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
8: Stmt_Expression(
expr: Expr_AssignOp_Mul(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
9: Stmt_Expression(
expr: Expr_AssignOp_Plus(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
10: Stmt_Expression(
expr: Expr_AssignOp_ShiftLeft(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
11: Stmt_Expression(
expr: Expr_AssignOp_ShiftRight(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
2014-03-26 19:18:16 +01:00
)
)
2017-01-19 22:25:22 +01:00
12: Stmt_Expression(
expr: Expr_AssignOp_Pow(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
2014-03-26 19:18:16 +01:00
)
2017-01-19 22:25:22 +01:00
)
13: Stmt_Expression(
expr: Expr_AssignOp_Coalesce(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
14: Stmt_Expression(
2017-01-19 22:25:22 +01:00
expr: Expr_Assign(
2014-03-26 19:18:16 +01:00
var: Expr_Variable(
2017-01-19 22:25:22 +01:00
name: a
comments: array(
0: // chained assign
)
2014-03-26 19:18:16 +01:00
)
2017-01-19 22:25:22 +01:00
expr: Expr_AssignOp_Mul(
2014-03-26 19:18:16 +01:00
var: Expr_Variable(
2017-01-19 22:25:22 +01:00
name: b
2014-03-26 19:18:16 +01:00
)
2017-01-19 22:25:22 +01:00
expr: Expr_AssignOp_Pow(
var: Expr_Variable(
name: c
)
expr: Expr_Variable(
name: d
)
2014-03-26 19:18:16 +01:00
)
)
2017-01-19 22:25:22 +01:00
comments: array(
0: // chained assign
)
2014-03-26 19:18:16 +01:00
)
comments: array(
0: // chained assign
)
2014-03-26 19:18:16 +01:00
)
15: Stmt_Expression(
2017-01-19 22:25:22 +01:00
expr: Expr_AssignRef(
var: Expr_Variable(
name: a
comments: array(
0: // by ref assign
)
)
expr: Expr_Variable(
name: b
)
comments: array(
0: // by ref assign
)
2011-11-27 11:20:35 +01:00
)
comments: array(
0: // by ref assign
)
2011-11-27 11:20:35 +01:00
)
16: Stmt_Expression(
2017-01-19 22:25:22 +01:00
expr: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: a
)
byRef: false
2019-05-09 15:11:00 +02:00
unpack: false
)
2017-01-19 22:25:22 +01:00
)
comments: array(
0: // list() assign
)
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
expr: Expr_Variable(
name: b
)
comments: array(
0: // list() assign
)
2011-11-27 11:20:35 +01:00
)
comments: array(
0: // list() assign
)
2011-11-27 11:20:35 +01:00
)
17: Stmt_Expression(
2017-01-19 22:25:22 +01:00
expr: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: a
)
byRef: false
2019-05-09 15:11:00 +02:00
unpack: false
)
2017-01-19 22:25:22 +01:00
1: null
2: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: b
)
byRef: false
2019-05-09 15:11:00 +02:00
unpack: false
)
)
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
expr: Expr_Variable(
name: c
)
2011-11-27 11:20:35 +01:00
)
)
18: Stmt_Expression(
2017-01-19 22:25:22 +01:00
expr: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: a
)
byRef: false
2019-05-09 15:11:00 +02:00
unpack: false
)
2017-01-19 22:25:22 +01:00
1: Expr_ArrayItem(
key: null
value: Expr_List(
items: array(
0: null
1: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: c
)
byRef: false
2019-05-09 15:11:00 +02:00
unpack: false
)
)
)
2017-01-19 22:25:22 +01:00
byRef: false
2019-05-09 15:11:00 +02:00
unpack: false
)
2017-01-19 22:25:22 +01:00
2: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: d
)
byRef: false
2019-05-09 15:11:00 +02:00
unpack: false
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
expr: Expr_Variable(
name: e
)
2011-11-27 11:20:35 +01:00
)
)
19: Stmt_Expression(
2017-01-19 22:25:22 +01:00
expr: Expr_PreInc(
var: Expr_Variable(
name: a
)
comments: array(
0: // inc/dec
)
2011-11-27 11:20:35 +01:00
)
comments: array(
0: // inc/dec
)
2011-11-27 11:20:35 +01:00
)
20: Stmt_Expression(
2017-01-19 22:25:22 +01:00
expr: Expr_PostInc(
var: Expr_Variable(
name: a
)
2011-11-27 11:20:35 +01:00
)
)
21: Stmt_Expression(
2017-01-19 22:25:22 +01:00
expr: Expr_PreDec(
var: Expr_Variable(
name: a
)
2011-11-27 11:20:35 +01:00
)
)
22: Stmt_Expression(
2017-01-19 22:25:22 +01:00
expr: Expr_PostDec(
var: Expr_Variable(
name: a
)
2011-11-27 11:20:35 +01:00
)
)
)