1Insertion of a nullable node
2-----
3<?php
4
5// TODO: The result spacing isn't always optimal. We may want to skip whitespace in some cases.
6
7function
8foo(
9$x,
10&$y
11)
12{}
13
14$foo
15[
16];
17
18[
19    & $value
20];
21
22function
23()
24{};
25
26$x
27?
28:
29$y;
30
31yield
32$v  ;
33yield  ;
34
35break
36;
37continue
38;
39return
40;
41
42class
43X
44{
45    public
46    function y()
47    {}
48
49    private
50        $x
51    ;
52
53    const
54    X
55    = 1;
56}
57
58foreach (
59    $x
60    as
61    $y
62) {}
63
64static
65$var
66;
67
68try {
69} catch (X
70$y) {
71}
72
73if ($cond) { // Foo
74} elseif ($cond2) { // Bar
75}
76-----
77$stmts[0]->returnType = new Node\Name('Foo');
78$stmts[0]->params[0]->type = new Node\Identifier('int');
79$stmts[0]->params[1]->type = new Node\Identifier('array');
80$stmts[0]->params[1]->default = new Expr\ConstFetch(new Node\Name('null'));
81$stmts[1]->expr->dim = new Expr\Variable('a');
82$stmts[2]->expr->items[0]->key = new Scalar\String_('X');
83$stmts[3]->expr->returnType = new Node\Name('Bar');
84$stmts[4]->expr->if = new Expr\Variable('z');
85$stmts[5]->expr->key = new Expr\Variable('k');
86$stmts[6]->expr->value = new Expr\Variable('v');
87$stmts[7]->num = new Scalar\LNumber(2);
88$stmts[8]->num = new Scalar\LNumber(2);
89$stmts[9]->expr = new Expr\Variable('x');
90$stmts[10]->extends = new Node\Name\FullyQualified('Bar');
91$stmts[10]->stmts[0]->returnType = new Node\Name('Y');
92$stmts[10]->stmts[1]->props[0]->default = new Scalar\DNumber(42.0);
93$stmts[10]->stmts[2]->type = new Node\Identifier('int');
94$stmts[11]->keyVar = new Expr\Variable('z');
95$stmts[12]->vars[0]->default = new Scalar\String_('abc');
96$stmts[13]->finally = new Stmt\Finally_([]);
97$stmts[14]->else = new Stmt\Else_([]);
98-----
99<?php
100
101// TODO: The result spacing isn't always optimal. We may want to skip whitespace in some cases.
102
103function
104foo(
105int $x,
106array &$y = null
107): Foo
108{}
109
110$foo
111[$a
112];
113
114[
115    'X' => & $value
116];
117
118function
119(): Bar
120{};
121
122$x
123? $z
124:
125$y;
126
127yield
128$k => $v  ;
129yield $v  ;
130
131break 2
132;
133continue 2
134;
135return $x
136;
137
138class
139X extends \Bar
140{
141    public
142    function y(): Y
143    {}
144
145    private
146        $x = 42.0
147    ;
148
149    const int
150    X
151    = 1;
152}
153
154foreach (
155    $x
156    as
157    $z => $y
158) {}
159
160static
161$var = 'abc'
162;
163
164try {
165} catch (X
166$y) {
167} finally {
168}
169
170if ($cond) { // Foo
171} elseif ($cond2) { // Bar
172} else {
173}
174-----
175<?php
176
177namespace
178{ echo 42; }
179-----
180$stmts[0]->name = new Node\Name('Foo');
181-----
182<?php
183
184namespace Foo
185{ echo 42; }
186-----
187<?php
188try
189{
190}
191catch (Exception)
192{
193}
194-----
195$stmts[0]->catches[0]->var = new Expr\Variable('e');
196-----
197<?php
198try
199{
200}
201catch (Exception $e)
202{
203}
204