1abc1
2-----
3<?php
4echo
5    1
6        +
7            2
8                +
9                    3;
10-----
11$stmts[0]->exprs[0]->left->right->value = 42;
12-----
13<?php
14echo
15    1
16        +
17            42
18                +
19                    3;
20-----
21<?php
22function foo($a)
23    { return $a; }
24-----
25$stmts[0]->name = new Node\Identifier('bar');
26-----
27<?php
28function bar($a)
29    { return $a; }
30-----
31<?php
32function
33foo() {
34    call(
35        $bar
36    );
37}
38-----
39// This triggers a fallback
40$stmts[0]->byRef = true;
41-----
42<?php
43function &foo()
44{
45    call(
46        $bar
47    );
48}
49-----
50<?php
51function
52foo() {
53echo "Start
54End";
55}
56-----
57// This triggers a fallback
58$stmts[0]->byRef = true;
59-----
60<?php
61function &foo()
62{
63    echo "Start
64End";
65}
66-----
67<?php
68function test() {
69    call1(
70        $bar
71    );
72}
73call2(
74    $foo
75);
76-----
77$tmp = $stmts[0]->stmts[0];
78$stmts[0]->stmts[0] = $stmts[1];
79$stmts[1] = $tmp;
80-----
81<?php
82function test() {
83    call2(
84        $foo
85    );
86}
87call1(
88    $bar
89);
90-----
91<?php
92x;
93function test() {
94    call1(
95        $bar
96    );
97}
98call2(
99    $foo
100);
101-----
102$tmp = $stmts[1]->stmts[0];
103$stmts[1]->stmts[0] = $stmts[2];
104$stmts[2] = $tmp;
105// Same test, but also removing first statement, triggering fallback
106array_splice($stmts, 0, 1, []);
107-----
108<?php
109function test() {
110    call2(
111        $foo
112    );
113}
114call1(
115    $bar
116);
117-----
118<?php
119    echo 1;
120-----
121$stmts[0] = new Stmt\Expression(
122    new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b')));
123-----
124<?php
125    $a = $b;
126-----
127<?php
128echo$a;
129-----
130$stmts[0]->exprs[0] = new Expr\ConstFetch(new Node\Name('C'));
131-----
132<?php
133echo C;
134-----
135<?php
136function foo() {
137    foo();
138    /*
139     * bar
140     */
141    baz();
142}
143
144{
145    $x;
146}
147-----
148$tmp = $stmts[0];
149$stmts[0] = $stmts[1];
150$stmts[1] = $tmp;
151/* TODO This used to do two replacement operations, but with the node list diffing this is a
152 * remove, keep, add (which probably makes more sense). As such, this currently triggers a
153 * fallback. */
154-----
155<?php
156{
157    $x;
158}
159function foo() {
160    foo();
161    /*
162     * bar
163     */
164    baz();
165}
166-----
167<?php
168echo "${foo}bar";
169echo "${foo['baz']}bar";
170-----
171$stmts[0]->exprs[0]->parts[0] = new Expr\Variable('bar');
172$stmts[1]->exprs[0]->parts[0] = new Expr\Variable('bar');
173-----
174<?php
175echo "{$bar}bar";
176echo "{$bar}bar";
177-----
178<?php
179[$a
180,$b
181,
182,] = $b;
183-----
184/* Nothing */
185-----
186<?php
187[$a
188,$b
189,
190,] = $b;
191