Mercurial > hg > isophonics-drupal-site
comparison vendor/nikic/php-parser/test/code/formatPreservation/insertionOfNullable.test @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
12:7a779792577d | 13:5fb285c0d0e3 |
---|---|
1 Insertion 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 | |
7 function | |
8 foo( | |
9 $x, | |
10 &$y | |
11 ) | |
12 {} | |
13 | |
14 $foo | |
15 [ | |
16 ]; | |
17 | |
18 [ | |
19 $value | |
20 ]; | |
21 | |
22 function | |
23 () | |
24 {}; | |
25 | |
26 $x | |
27 ? | |
28 : | |
29 $y; | |
30 | |
31 yield | |
32 $v ; | |
33 yield ; | |
34 | |
35 break | |
36 ; | |
37 continue | |
38 ; | |
39 return | |
40 ; | |
41 | |
42 class | |
43 X | |
44 { | |
45 public | |
46 function y() | |
47 {} | |
48 | |
49 private | |
50 $x | |
51 ; | |
52 } | |
53 | |
54 foreach ( | |
55 $x | |
56 as | |
57 $y | |
58 ) {} | |
59 | |
60 static | |
61 $var | |
62 ; | |
63 | |
64 try { | |
65 } catch (X | |
66 $y) { | |
67 } | |
68 | |
69 if ($cond) { // Foo | |
70 } elseif ($cond2) { // Bar | |
71 } | |
72 ----- | |
73 $stmts[0]->returnType = new Node\Name('Foo'); | |
74 $stmts[0]->params[0]->type = new Node\Identifier('int'); | |
75 $stmts[0]->params[1]->type = new Node\Identifier('array'); | |
76 $stmts[0]->params[1]->default = new Expr\ConstFetch(new Node\Name('null')); | |
77 $stmts[1]->expr->dim = new Expr\Variable('a'); | |
78 $stmts[2]->expr->items[0]->key = new Scalar\String_('X'); | |
79 $stmts[3]->expr->returnType = new Node\Name('Bar'); | |
80 $stmts[4]->expr->if = new Expr\Variable('z'); | |
81 $stmts[5]->expr->key = new Expr\Variable('k'); | |
82 $stmts[6]->expr->value = new Expr\Variable('v'); | |
83 $stmts[7]->num = new Scalar\LNumber(2); | |
84 $stmts[8]->num = new Scalar\LNumber(2); | |
85 $stmts[9]->expr = new Expr\Variable('x'); | |
86 $stmts[10]->extends = new Node\Name\FullyQualified('Bar'); | |
87 $stmts[10]->stmts[0]->returnType = new Node\Name('Y'); | |
88 $stmts[10]->stmts[1]->props[0]->default = new Scalar\DNumber(42.0); | |
89 $stmts[11]->keyVar = new Expr\Variable('z'); | |
90 $stmts[12]->vars[0]->default = new Scalar\String_('abc'); | |
91 $stmts[13]->finally = new Stmt\Finally_([]); | |
92 $stmts[14]->else = new Stmt\Else_([]); | |
93 ----- | |
94 <?php | |
95 | |
96 // TODO: The result spacing isn't always optimal. We may want to skip whitespace in some cases. | |
97 | |
98 function | |
99 foo( | |
100 int $x, | |
101 array &$y = null | |
102 ) : Foo | |
103 {} | |
104 | |
105 $foo | |
106 [$a | |
107 ]; | |
108 | |
109 [ | |
110 'X' => $value | |
111 ]; | |
112 | |
113 function | |
114 () : Bar | |
115 {}; | |
116 | |
117 $x | |
118 ? $z | |
119 : | |
120 $y; | |
121 | |
122 yield | |
123 $k => $v ; | |
124 yield $v ; | |
125 | |
126 break 2 | |
127 ; | |
128 continue 2 | |
129 ; | |
130 return $x | |
131 ; | |
132 | |
133 class | |
134 X extends \Bar | |
135 { | |
136 public | |
137 function y() : Y | |
138 {} | |
139 | |
140 private | |
141 $x = 42.0 | |
142 ; | |
143 } | |
144 | |
145 foreach ( | |
146 $x | |
147 as | |
148 $z => $y | |
149 ) {} | |
150 | |
151 static | |
152 $var = 'abc' | |
153 ; | |
154 | |
155 try { | |
156 } catch (X | |
157 $y) { | |
158 } finally { | |
159 } | |
160 | |
161 if ($cond) { // Foo | |
162 } elseif ($cond2) { // Bar | |
163 } else { | |
164 } | |
165 ----- | |
166 <?php | |
167 | |
168 namespace | |
169 { echo 42; } | |
170 ----- | |
171 $stmts[0]->name = new Node\Name('Foo'); | |
172 ----- | |
173 <?php | |
174 | |
175 namespace Foo | |
176 { echo 42; } |