@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
25 | 25 | { |
26 | - if (is_array($source)) { |
|
26 | + if (is_array($source)){ |
|
27 | 27 | $source[] = self::OUTPUT; |
28 | 28 | } |
29 | 29 |
@@ -23,7 +23,8 @@ |
||
23 | 23 | */ |
24 | 24 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
25 | 25 | { |
26 | - if (is_array($source)) { |
|
26 | + if (is_array($source)) |
|
27 | + { |
|
27 | 28 | $source[] = self::OUTPUT; |
28 | 29 | } |
29 | 30 |
@@ -52,19 +52,19 @@ |
||
52 | 52 | */ |
53 | 53 | public function leaveNode($node, VisitorContext $ctx) |
54 | 54 | { |
55 | - if (!$node instanceof Block || $node->name === null || !$this->blocks->has($node->name)) { |
|
55 | + if (!$node instanceof Block || $node->name === null || !$this->blocks->has($node->name)){ |
|
56 | 56 | return null; |
57 | 57 | } |
58 | 58 | |
59 | 59 | $inject = $this->blocks->claim($node->name); |
60 | 60 | |
61 | - if ($inject instanceof QuotedValue) { |
|
61 | + if ($inject instanceof QuotedValue){ |
|
62 | 62 | // exclude quotes |
63 | 63 | $inject = $inject->trimvalue(); |
64 | 64 | } |
65 | 65 | |
66 | 66 | // mount block:parent content |
67 | - if ($node->name !== 'parent') { |
|
67 | + if ($node->name !== 'parent'){ |
|
68 | 68 | $traverser = new Traverser(); |
69 | 69 | $traverser->addVisitor(new InjectBlocks(new BlockClaims([ |
70 | 70 | 'parent' => $node->nodes, |
@@ -52,19 +52,22 @@ |
||
52 | 52 | */ |
53 | 53 | public function leaveNode($node, VisitorContext $ctx) |
54 | 54 | { |
55 | - if (!$node instanceof Block || $node->name === null || !$this->blocks->has($node->name)) { |
|
55 | + if (!$node instanceof Block || $node->name === null || !$this->blocks->has($node->name)) |
|
56 | + { |
|
56 | 57 | return null; |
57 | 58 | } |
58 | 59 | |
59 | 60 | $inject = $this->blocks->claim($node->name); |
60 | 61 | |
61 | - if ($inject instanceof QuotedValue) { |
|
62 | + if ($inject instanceof QuotedValue) |
|
63 | + { |
|
62 | 64 | // exclude quotes |
63 | 65 | $inject = $inject->trimvalue(); |
64 | 66 | } |
65 | 67 | |
66 | 68 | // mount block:parent content |
67 | - if ($node->name !== 'parent') { |
|
69 | + if ($node->name !== 'parent') |
|
70 | + { |
|
68 | 71 | $traverser = new Traverser(); |
69 | 72 | $traverser->addVisitor(new InjectBlocks(new BlockClaims([ |
70 | 73 | 'parent' => $node->nodes, |
@@ -58,11 +58,11 @@ |
||
58 | 58 | 'content' => $this->content, |
59 | 59 | ]; |
60 | 60 | |
61 | - if ($this->grammar !== null) { |
|
61 | + if ($this->grammar !== null){ |
|
62 | 62 | $token['type'] = call_user_func([$this->grammar, 'tokenName'], $this->type); |
63 | 63 | } |
64 | 64 | |
65 | - if ($this->tokens !== []) { |
|
65 | + if ($this->tokens !== []){ |
|
66 | 66 | $token['tokens'] = $this->tokens; |
67 | 67 | } |
68 | 68 |
@@ -58,11 +58,13 @@ |
||
58 | 58 | 'content' => $this->content, |
59 | 59 | ]; |
60 | 60 | |
61 | - if ($this->grammar !== null) { |
|
61 | + if ($this->grammar !== null) |
|
62 | + { |
|
62 | 63 | $token['type'] = call_user_func([$this->grammar, 'tokenName'], $this->type); |
63 | 64 | } |
64 | 65 | |
65 | - if ($this->tokens !== []) { |
|
66 | + if ($this->tokens !== []) |
|
67 | + { |
|
66 | 68 | $token['tokens'] = $this->tokens; |
67 | 69 | } |
68 | 70 |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function parse(Buffer $src): \Generator |
61 | 61 | { |
62 | - while ($n = $src->next()) { |
|
63 | - if (!$n instanceof Byte || $n->char !== '<') { |
|
62 | + while ($n = $src->next()){ |
|
63 | + if (!$n instanceof Byte || $n->char !== '<'){ |
|
64 | 64 | yield $n; |
65 | 65 | continue; |
66 | 66 | } |
67 | 67 | |
68 | 68 | // work with isolated token stream! |
69 | 69 | $tag = (clone $this)->parseGrammar($src); |
70 | - if ($tag === null) { |
|
70 | + if ($tag === null){ |
|
71 | 71 | yield $n; |
72 | 72 | $src->replay($n->offset); |
73 | 73 | continue; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $tagName = $this->tagName($tag); |
77 | 77 | |
78 | 78 | // todo: add support for custom tag list |
79 | - if (in_array($tagName, self::VERBATIM_TAGS)) { |
|
79 | + if (in_array($tagName, self::VERBATIM_TAGS)){ |
|
80 | 80 | yield from $tag; |
81 | 81 | yield from $this->parseVerbatim($src, $tagName); |
82 | 82 | continue; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public static function tokenName(int $token): string |
94 | 94 | { |
95 | - switch ($token) { |
|
95 | + switch ($token){ |
|
96 | 96 | case self::TYPE_RAW: |
97 | 97 | return 'HTML:RAW'; |
98 | 98 | case self::TYPE_KEYWORD: |
@@ -127,26 +127,26 @@ discard block |
||
127 | 127 | { |
128 | 128 | $chunks = []; |
129 | 129 | |
130 | - while ($n = $src->next()) { |
|
131 | - if ($n instanceof Token) { |
|
130 | + while ($n = $src->next()){ |
|
131 | + if ($n instanceof Token){ |
|
132 | 132 | $chunks[] = $n; |
133 | 133 | continue; |
134 | 134 | } |
135 | 135 | |
136 | - switch ($n->char) { |
|
136 | + switch ($n->char){ |
|
137 | 137 | case '"': |
138 | 138 | case "'": |
139 | 139 | case '`': |
140 | 140 | $chunks[] = $n; |
141 | 141 | |
142 | 142 | // language inclusions allow nested strings |
143 | - while ($nc = $src->next()) { |
|
143 | + while ($nc = $src->next()){ |
|
144 | 144 | $chunks[] = $nc; |
145 | - if ($nc instanceof Token) { |
|
145 | + if ($nc instanceof Token){ |
|
146 | 146 | continue; |
147 | 147 | } |
148 | 148 | |
149 | - if ($nc->char === $n->char) { |
|
149 | + if ($nc->char === $n->char){ |
|
150 | 150 | break; |
151 | 151 | } |
152 | 152 | } |
@@ -157,22 +157,22 @@ discard block |
||
157 | 157 | $chunks[] = $n; |
158 | 158 | |
159 | 159 | $multiline = false; |
160 | - if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*') { |
|
161 | - if ($src->lookaheadByte(1) === '*') { |
|
160 | + if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*'){ |
|
161 | + if ($src->lookaheadByte(1) === '*'){ |
|
162 | 162 | $multiline = true; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $chunks[] = $src->next(); |
166 | 166 | |
167 | 167 | // language inclusions allow nested strings |
168 | - while ($nc = $src->next()) { |
|
169 | - if ($nc instanceof Token) { |
|
168 | + while ($nc = $src->next()){ |
|
169 | + if ($nc instanceof Token){ |
|
170 | 170 | continue; |
171 | 171 | } |
172 | 172 | |
173 | - if ($nc->char === '<') { |
|
173 | + if ($nc->char === '<'){ |
|
174 | 174 | $tag = (clone $this)->parseGrammar($src); |
175 | - if ($tag === null || $this->tagName($tag) !== $verbatim) { |
|
175 | + if ($tag === null || $this->tagName($tag) !== $verbatim){ |
|
176 | 176 | $src->replay($n->offset); |
177 | 177 | break; |
178 | 178 | } |
@@ -183,12 +183,12 @@ discard block |
||
183 | 183 | |
184 | 184 | $chunks[] = $nc; |
185 | 185 | |
186 | - if ($multiline) { |
|
187 | - if ($nc->char === '*' && $src->lookaheadByte(1) === '/') { |
|
186 | + if ($multiline){ |
|
187 | + if ($nc->char === '*' && $src->lookaheadByte(1) === '/'){ |
|
188 | 188 | $chunks[] = $src->next(); |
189 | 189 | break; |
190 | 190 | } |
191 | - } elseif ($nc->char === "\n") { |
|
191 | + } elseif ($nc->char === "\n"){ |
|
192 | 192 | break; |
193 | 193 | } |
194 | 194 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | case '<': |
200 | 200 | // tag beginning? |
201 | 201 | $tag = (clone $this)->parseGrammar($src); |
202 | - if ($tag === null || $this->tagName($tag) !== $verbatim) { |
|
202 | + if ($tag === null || $this->tagName($tag) !== $verbatim){ |
|
203 | 203 | $chunks[] = $n; |
204 | 204 | $src->replay($n->offset); |
205 | 205 | break; |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | */ |
224 | 224 | private function tagName(array $tag): string |
225 | 225 | { |
226 | - foreach ($tag as $token) { |
|
227 | - if ($token->type === self::TYPE_KEYWORD) { |
|
226 | + foreach ($tag as $token){ |
|
227 | + if ($token->type === self::TYPE_KEYWORD){ |
|
228 | 228 | return strtolower($token->content); |
229 | 229 | } |
230 | 230 | } |
@@ -242,28 +242,28 @@ discard block |
||
242 | 242 | new Token(self::TYPE_OPEN, $src->getOffset(), '<'), |
243 | 243 | ]; |
244 | 244 | |
245 | - if ($src->lookaheadByte() === '/') { |
|
245 | + if ($src->lookaheadByte() === '/'){ |
|
246 | 246 | $this->tokens[0]->type = self::TYPE_OPEN_SHORT; |
247 | 247 | $this->tokens[0]->content .= $src->next()->char; |
248 | 248 | } |
249 | 249 | |
250 | - while ($n = $src->next()) { |
|
251 | - if ($this->attribute !== []) { |
|
250 | + while ($n = $src->next()){ |
|
251 | + if ($this->attribute !== []){ |
|
252 | 252 | $this->attribute[] = $n; |
253 | 253 | |
254 | - if ($n instanceof Byte && $n->char === $this->attribute[0]->char) { |
|
254 | + if ($n instanceof Byte && $n->char === $this->attribute[0]->char){ |
|
255 | 255 | $this->flushAttribute(); |
256 | 256 | } |
257 | 257 | |
258 | 258 | continue; |
259 | 259 | } |
260 | 260 | |
261 | - if ($n instanceof Token) { |
|
261 | + if ($n instanceof Token){ |
|
262 | 262 | $this->keyword[] = $n; |
263 | 263 | continue; |
264 | 264 | } |
265 | 265 | |
266 | - switch ($n->char) { |
|
266 | + switch ($n->char){ |
|
267 | 267 | case '"': |
268 | 268 | case "'": |
269 | 269 | case '`': |
@@ -281,12 +281,12 @@ discard block |
||
281 | 281 | break; |
282 | 282 | |
283 | 283 | case '/': |
284 | - if ($src->lookaheadByte() === '>') { |
|
284 | + if ($src->lookaheadByte() === '>'){ |
|
285 | 285 | $this->flush(); |
286 | 286 | $this->tokens[] = new Token( |
287 | 287 | self::TYPE_CLOSE_SHORT, |
288 | 288 | $n->offset, |
289 | - $n->char . $src->next()->char |
|
289 | + $n->char.$src->next()->char |
|
290 | 290 | ); |
291 | 291 | |
292 | 292 | break 2; |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | break 2; |
306 | 306 | |
307 | 307 | default: |
308 | - if (preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
308 | + if (preg_match(self::REGEXP_WHITESPACE, $n->char)){ |
|
309 | 309 | $this->flushKeyword(); |
310 | 310 | $this->whitespace[] = $n; |
311 | 311 | break; |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $this->flushWhitespace(); |
314 | 314 | |
315 | 315 | |
316 | - if (!preg_match(self::REGEXP_KEYWORD, $n->char)) { |
|
316 | + if (!preg_match(self::REGEXP_KEYWORD, $n->char)){ |
|
317 | 317 | // unexpected char |
318 | 318 | return null; |
319 | 319 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | - if (!$this->isValid()) { |
|
325 | + if (!$this->isValid()){ |
|
326 | 326 | return null; |
327 | 327 | } |
328 | 328 | |
@@ -335,17 +335,17 @@ discard block |
||
335 | 335 | private function isValid(): bool |
336 | 336 | { |
337 | 337 | // tag is too short or does not have name keyword |
338 | - if (count($this->tokens) < 3) { |
|
338 | + if (count($this->tokens) < 3){ |
|
339 | 339 | return false; |
340 | 340 | } |
341 | 341 | |
342 | 342 | $last = $this->tokens[count($this->tokens) - 1]; |
343 | - if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT) { |
|
343 | + if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT){ |
|
344 | 344 | return false; |
345 | 345 | } |
346 | 346 | |
347 | - foreach ($this->tokens as $token) { |
|
348 | - switch ($token->type) { |
|
347 | + foreach ($this->tokens as $token){ |
|
348 | + switch ($token->type){ |
|
349 | 349 | case self::TYPE_WHITESPACE: |
350 | 350 | // ignore |
351 | 351 | continue 2; |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | */ |
377 | 377 | private function flushWhitespace(): void |
378 | 378 | { |
379 | - if ($this->whitespace === []) { |
|
379 | + if ($this->whitespace === []){ |
|
380 | 380 | return; |
381 | 381 | } |
382 | 382 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | */ |
390 | 390 | private function flushKeyword(): void |
391 | 391 | { |
392 | - if ($this->keyword === []) { |
|
392 | + if ($this->keyword === []){ |
|
393 | 393 | return; |
394 | 394 | } |
395 | 395 | |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | private function flushAttribute(): void |
404 | 404 | { |
405 | - if ($this->attribute === []) { |
|
405 | + if ($this->attribute === []){ |
|
406 | 406 | return; |
407 | 407 | } |
408 | 408 |
@@ -59,15 +59,18 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function parse(Buffer $src): \Generator |
61 | 61 | { |
62 | - while ($n = $src->next()) { |
|
63 | - if (!$n instanceof Byte || $n->char !== '<') { |
|
62 | + while ($n = $src->next()) |
|
63 | + { |
|
64 | + if (!$n instanceof Byte || $n->char !== '<') |
|
65 | + { |
|
64 | 66 | yield $n; |
65 | 67 | continue; |
66 | 68 | } |
67 | 69 | |
68 | 70 | // work with isolated token stream! |
69 | 71 | $tag = (clone $this)->parseGrammar($src); |
70 | - if ($tag === null) { |
|
72 | + if ($tag === null) |
|
73 | + { |
|
71 | 74 | yield $n; |
72 | 75 | $src->replay($n->offset); |
73 | 76 | continue; |
@@ -76,7 +79,8 @@ discard block |
||
76 | 79 | $tagName = $this->tagName($tag); |
77 | 80 | |
78 | 81 | // todo: add support for custom tag list |
79 | - if (in_array($tagName, self::VERBATIM_TAGS)) { |
|
82 | + if (in_array($tagName, self::VERBATIM_TAGS)) |
|
83 | + { |
|
80 | 84 | yield from $tag; |
81 | 85 | yield from $this->parseVerbatim($src, $tagName); |
82 | 86 | continue; |
@@ -92,7 +96,8 @@ discard block |
||
92 | 96 | */ |
93 | 97 | public static function tokenName(int $token): string |
94 | 98 | { |
95 | - switch ($token) { |
|
99 | + switch ($token) |
|
100 | + { |
|
96 | 101 | case self::TYPE_RAW: |
97 | 102 | return 'HTML:RAW'; |
98 | 103 | case self::TYPE_KEYWORD: |
@@ -127,26 +132,32 @@ discard block |
||
127 | 132 | { |
128 | 133 | $chunks = []; |
129 | 134 | |
130 | - while ($n = $src->next()) { |
|
131 | - if ($n instanceof Token) { |
|
135 | + while ($n = $src->next()) |
|
136 | + { |
|
137 | + if ($n instanceof Token) |
|
138 | + { |
|
132 | 139 | $chunks[] = $n; |
133 | 140 | continue; |
134 | 141 | } |
135 | 142 | |
136 | - switch ($n->char) { |
|
143 | + switch ($n->char) |
|
144 | + { |
|
137 | 145 | case '"': |
138 | 146 | case "'": |
139 | 147 | case '`': |
140 | 148 | $chunks[] = $n; |
141 | 149 | |
142 | 150 | // language inclusions allow nested strings |
143 | - while ($nc = $src->next()) { |
|
151 | + while ($nc = $src->next()) |
|
152 | + { |
|
144 | 153 | $chunks[] = $nc; |
145 | - if ($nc instanceof Token) { |
|
154 | + if ($nc instanceof Token) |
|
155 | + { |
|
146 | 156 | continue; |
147 | 157 | } |
148 | 158 | |
149 | - if ($nc->char === $n->char) { |
|
159 | + if ($nc->char === $n->char) |
|
160 | + { |
|
150 | 161 | break; |
151 | 162 | } |
152 | 163 | } |
@@ -157,22 +168,28 @@ discard block |
||
157 | 168 | $chunks[] = $n; |
158 | 169 | |
159 | 170 | $multiline = false; |
160 | - if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*') { |
|
161 | - if ($src->lookaheadByte(1) === '*') { |
|
171 | + if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*') |
|
172 | + { |
|
173 | + if ($src->lookaheadByte(1) === '*') |
|
174 | + { |
|
162 | 175 | $multiline = true; |
163 | 176 | } |
164 | 177 | |
165 | 178 | $chunks[] = $src->next(); |
166 | 179 | |
167 | 180 | // language inclusions allow nested strings |
168 | - while ($nc = $src->next()) { |
|
169 | - if ($nc instanceof Token) { |
|
181 | + while ($nc = $src->next()) |
|
182 | + { |
|
183 | + if ($nc instanceof Token) |
|
184 | + { |
|
170 | 185 | continue; |
171 | 186 | } |
172 | 187 | |
173 | - if ($nc->char === '<') { |
|
188 | + if ($nc->char === '<') |
|
189 | + { |
|
174 | 190 | $tag = (clone $this)->parseGrammar($src); |
175 | - if ($tag === null || $this->tagName($tag) !== $verbatim) { |
|
191 | + if ($tag === null || $this->tagName($tag) !== $verbatim) |
|
192 | + { |
|
176 | 193 | $src->replay($n->offset); |
177 | 194 | break; |
178 | 195 | } |
@@ -183,12 +200,16 @@ discard block |
||
183 | 200 | |
184 | 201 | $chunks[] = $nc; |
185 | 202 | |
186 | - if ($multiline) { |
|
187 | - if ($nc->char === '*' && $src->lookaheadByte(1) === '/') { |
|
203 | + if ($multiline) |
|
204 | + { |
|
205 | + if ($nc->char === '*' && $src->lookaheadByte(1) === '/') |
|
206 | + { |
|
188 | 207 | $chunks[] = $src->next(); |
189 | 208 | break; |
190 | 209 | } |
191 | - } elseif ($nc->char === "\n") { |
|
210 | + } |
|
211 | + elseif ($nc->char === "\n") |
|
212 | + { |
|
192 | 213 | break; |
193 | 214 | } |
194 | 215 | } |
@@ -199,7 +220,8 @@ discard block |
||
199 | 220 | case '<': |
200 | 221 | // tag beginning? |
201 | 222 | $tag = (clone $this)->parseGrammar($src); |
202 | - if ($tag === null || $this->tagName($tag) !== $verbatim) { |
|
223 | + if ($tag === null || $this->tagName($tag) !== $verbatim) |
|
224 | + { |
|
203 | 225 | $chunks[] = $n; |
204 | 226 | $src->replay($n->offset); |
205 | 227 | break; |
@@ -223,8 +245,10 @@ discard block |
||
223 | 245 | */ |
224 | 246 | private function tagName(array $tag): string |
225 | 247 | { |
226 | - foreach ($tag as $token) { |
|
227 | - if ($token->type === self::TYPE_KEYWORD) { |
|
248 | + foreach ($tag as $token) |
|
249 | + { |
|
250 | + if ($token->type === self::TYPE_KEYWORD) |
|
251 | + { |
|
228 | 252 | return strtolower($token->content); |
229 | 253 | } |
230 | 254 | } |
@@ -242,28 +266,34 @@ discard block |
||
242 | 266 | new Token(self::TYPE_OPEN, $src->getOffset(), '<'), |
243 | 267 | ]; |
244 | 268 | |
245 | - if ($src->lookaheadByte() === '/') { |
|
269 | + if ($src->lookaheadByte() === '/') |
|
270 | + { |
|
246 | 271 | $this->tokens[0]->type = self::TYPE_OPEN_SHORT; |
247 | 272 | $this->tokens[0]->content .= $src->next()->char; |
248 | 273 | } |
249 | 274 | |
250 | - while ($n = $src->next()) { |
|
251 | - if ($this->attribute !== []) { |
|
275 | + while ($n = $src->next()) |
|
276 | + { |
|
277 | + if ($this->attribute !== []) |
|
278 | + { |
|
252 | 279 | $this->attribute[] = $n; |
253 | 280 | |
254 | - if ($n instanceof Byte && $n->char === $this->attribute[0]->char) { |
|
281 | + if ($n instanceof Byte && $n->char === $this->attribute[0]->char) |
|
282 | + { |
|
255 | 283 | $this->flushAttribute(); |
256 | 284 | } |
257 | 285 | |
258 | 286 | continue; |
259 | 287 | } |
260 | 288 | |
261 | - if ($n instanceof Token) { |
|
289 | + if ($n instanceof Token) |
|
290 | + { |
|
262 | 291 | $this->keyword[] = $n; |
263 | 292 | continue; |
264 | 293 | } |
265 | 294 | |
266 | - switch ($n->char) { |
|
295 | + switch ($n->char) |
|
296 | + { |
|
267 | 297 | case '"': |
268 | 298 | case "'": |
269 | 299 | case '`': |
@@ -281,7 +311,8 @@ discard block |
||
281 | 311 | break; |
282 | 312 | |
283 | 313 | case '/': |
284 | - if ($src->lookaheadByte() === '>') { |
|
314 | + if ($src->lookaheadByte() === '>') |
|
315 | + { |
|
285 | 316 | $this->flush(); |
286 | 317 | $this->tokens[] = new Token( |
287 | 318 | self::TYPE_CLOSE_SHORT, |
@@ -305,7 +336,8 @@ discard block |
||
305 | 336 | break 2; |
306 | 337 | |
307 | 338 | default: |
308 | - if (preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
339 | + if (preg_match(self::REGEXP_WHITESPACE, $n->char)) |
|
340 | + { |
|
309 | 341 | $this->flushKeyword(); |
310 | 342 | $this->whitespace[] = $n; |
311 | 343 | break; |
@@ -313,7 +345,8 @@ discard block |
||
313 | 345 | $this->flushWhitespace(); |
314 | 346 | |
315 | 347 | |
316 | - if (!preg_match(self::REGEXP_KEYWORD, $n->char)) { |
|
348 | + if (!preg_match(self::REGEXP_KEYWORD, $n->char)) |
|
349 | + { |
|
317 | 350 | // unexpected char |
318 | 351 | return null; |
319 | 352 | } |
@@ -322,7 +355,8 @@ discard block |
||
322 | 355 | } |
323 | 356 | } |
324 | 357 | |
325 | - if (!$this->isValid()) { |
|
358 | + if (!$this->isValid()) |
|
359 | + { |
|
326 | 360 | return null; |
327 | 361 | } |
328 | 362 | |
@@ -335,17 +369,21 @@ discard block |
||
335 | 369 | private function isValid(): bool |
336 | 370 | { |
337 | 371 | // tag is too short or does not have name keyword |
338 | - if (count($this->tokens) < 3) { |
|
372 | + if (count($this->tokens) < 3) |
|
373 | + { |
|
339 | 374 | return false; |
340 | 375 | } |
341 | 376 | |
342 | 377 | $last = $this->tokens[count($this->tokens) - 1]; |
343 | - if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT) { |
|
378 | + if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT) |
|
379 | + { |
|
344 | 380 | return false; |
345 | 381 | } |
346 | 382 | |
347 | - foreach ($this->tokens as $token) { |
|
348 | - switch ($token->type) { |
|
383 | + foreach ($this->tokens as $token) |
|
384 | + { |
|
385 | + switch ($token->type) |
|
386 | + { |
|
349 | 387 | case self::TYPE_WHITESPACE: |
350 | 388 | // ignore |
351 | 389 | continue 2; |
@@ -376,7 +414,8 @@ discard block |
||
376 | 414 | */ |
377 | 415 | private function flushWhitespace(): void |
378 | 416 | { |
379 | - if ($this->whitespace === []) { |
|
417 | + if ($this->whitespace === []) |
|
418 | + { |
|
380 | 419 | return; |
381 | 420 | } |
382 | 421 | |
@@ -389,7 +428,8 @@ discard block |
||
389 | 428 | */ |
390 | 429 | private function flushKeyword(): void |
391 | 430 | { |
392 | - if ($this->keyword === []) { |
|
431 | + if ($this->keyword === []) |
|
432 | + { |
|
393 | 433 | return; |
394 | 434 | } |
395 | 435 | |
@@ -402,7 +442,8 @@ discard block |
||
402 | 442 | */ |
403 | 443 | private function flushAttribute(): void |
404 | 444 | { |
405 | - if ($this->attribute === []) { |
|
445 | + if ($this->attribute === []) |
|
446 | + { |
|
406 | 447 | return; |
407 | 448 | } |
408 | 449 |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function parse(Buffer $src): \Generator |
50 | 50 | { |
51 | - while ($n = $src->next()) { |
|
52 | - if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{') { |
|
51 | + while ($n = $src->next()){ |
|
52 | + if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{'){ |
|
53 | 53 | yield $n; |
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | 57 | $binding = (clone $this)->parseGrammar($src, $n->offset); |
58 | - if ($binding === null) { |
|
58 | + if ($binding === null){ |
|
59 | 59 | yield $n; |
60 | 60 | $src->replay($n->offset); |
61 | 61 | continue; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public static function tokenName(int $token): string |
73 | 73 | { |
74 | - switch ($token) { |
|
74 | + switch ($token){ |
|
75 | 75 | case self::TYPE_OPEN_TAG: |
76 | 76 | return 'INLINE:OPEN_TAG'; |
77 | 77 | case self::TYPE_CLOSE_TAG: |
@@ -95,27 +95,27 @@ discard block |
||
95 | 95 | private function parseGrammar(Buffer $src, int $offset): ?array |
96 | 96 | { |
97 | 97 | $this->tokens = [ |
98 | - new Token(self::TYPE_OPEN_TAG, $offset, '$' . $src->next()->char), |
|
98 | + new Token(self::TYPE_OPEN_TAG, $offset, '$'.$src->next()->char), |
|
99 | 99 | ]; |
100 | 100 | |
101 | - while ($n = $src->next()) { |
|
102 | - if (!$n instanceof Byte) { |
|
101 | + while ($n = $src->next()){ |
|
102 | + if (!$n instanceof Byte){ |
|
103 | 103 | // no other grammars are allowed |
104 | 104 | return null; |
105 | 105 | } |
106 | 106 | |
107 | - switch ($n->char) { |
|
107 | + switch ($n->char){ |
|
108 | 108 | case '"': |
109 | 109 | case "'": |
110 | - if ($this->default === null) { |
|
110 | + if ($this->default === null){ |
|
111 | 111 | // " and ' not allowed in names |
112 | 112 | return null; |
113 | 113 | } |
114 | 114 | |
115 | 115 | $this->default[] = $n; |
116 | - while ($nn = $src->next()) { |
|
116 | + while ($nn = $src->next()){ |
|
117 | 117 | $this->default[] = $nn; |
118 | - if ($nn instanceof Byte && $nn->char === $n->char) { |
|
118 | + if ($nn instanceof Byte && $nn->char === $n->char){ |
|
119 | 119 | break; |
120 | 120 | } |
121 | 121 | } |
@@ -148,17 +148,17 @@ discard block |
||
148 | 148 | break; |
149 | 149 | |
150 | 150 | default: |
151 | - if ($this->default !== null) { |
|
151 | + if ($this->default !== null){ |
|
152 | 152 | // default allows spaces |
153 | 153 | $this->default[] = $n; |
154 | 154 | break; |
155 | 155 | } |
156 | 156 | |
157 | - if (preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
157 | + if (preg_match(self::REGEXP_WHITESPACE, $n->char)){ |
|
158 | 158 | break; |
159 | 159 | } |
160 | 160 | |
161 | - if (preg_match(self::REGEXP_KEYWORD, $n->char)) { |
|
161 | + if (preg_match(self::REGEXP_KEYWORD, $n->char)){ |
|
162 | 162 | $this->name[] = $n; |
163 | 163 | break; |
164 | 164 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - if (!$this->isValid()) { |
|
170 | + if (!$this->isValid()){ |
|
171 | 171 | return null; |
172 | 172 | } |
173 | 173 | |
@@ -179,25 +179,25 @@ discard block |
||
179 | 179 | */ |
180 | 180 | private function isValid(): bool |
181 | 181 | { |
182 | - if (count($this->tokens) < 3) { |
|
182 | + if (count($this->tokens) < 3){ |
|
183 | 183 | return false; |
184 | 184 | } |
185 | 185 | |
186 | 186 | $hasName = false; |
187 | 187 | $hasDefault = null; |
188 | - foreach ($this->tokens as $token) { |
|
189 | - if ($token->type === self::TYPE_NAME) { |
|
188 | + foreach ($this->tokens as $token){ |
|
189 | + if ($token->type === self::TYPE_NAME){ |
|
190 | 190 | $hasName = true; |
191 | 191 | continue; |
192 | 192 | } |
193 | 193 | |
194 | - if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null) { |
|
194 | + if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null){ |
|
195 | 195 | $hasDefault = false; |
196 | 196 | continue; |
197 | 197 | } |
198 | 198 | |
199 | - if ($token->type === self::TYPE_DEFAULT) { |
|
200 | - if ($hasDefault === true) { |
|
199 | + if ($token->type === self::TYPE_DEFAULT){ |
|
200 | + if ($hasDefault === true){ |
|
201 | 201 | // multiple default value |
202 | 202 | return false; |
203 | 203 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | private function flushName(): void |
216 | 216 | { |
217 | - if ($this->name === []) { |
|
217 | + if ($this->name === []){ |
|
218 | 218 | return; |
219 | 219 | } |
220 | 220 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | private function flushDefault(): void |
229 | 229 | { |
230 | - if ($this->default === [] || $this->default === null) { |
|
230 | + if ($this->default === [] || $this->default === null){ |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 |
@@ -48,14 +48,17 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function parse(Buffer $src): \Generator |
50 | 50 | { |
51 | - while ($n = $src->next()) { |
|
52 | - if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{') { |
|
51 | + while ($n = $src->next()) |
|
52 | + { |
|
53 | + if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{') |
|
54 | + { |
|
53 | 55 | yield $n; |
54 | 56 | continue; |
55 | 57 | } |
56 | 58 | |
57 | 59 | $binding = (clone $this)->parseGrammar($src, $n->offset); |
58 | - if ($binding === null) { |
|
60 | + if ($binding === null) |
|
61 | + { |
|
59 | 62 | yield $n; |
60 | 63 | $src->replay($n->offset); |
61 | 64 | continue; |
@@ -71,7 +74,8 @@ discard block |
||
71 | 74 | */ |
72 | 75 | public static function tokenName(int $token): string |
73 | 76 | { |
74 | - switch ($token) { |
|
77 | + switch ($token) |
|
78 | + { |
|
75 | 79 | case self::TYPE_OPEN_TAG: |
76 | 80 | return 'INLINE:OPEN_TAG'; |
77 | 81 | case self::TYPE_CLOSE_TAG: |
@@ -98,24 +102,30 @@ discard block |
||
98 | 102 | new Token(self::TYPE_OPEN_TAG, $offset, '$' . $src->next()->char), |
99 | 103 | ]; |
100 | 104 | |
101 | - while ($n = $src->next()) { |
|
102 | - if (!$n instanceof Byte) { |
|
105 | + while ($n = $src->next()) |
|
106 | + { |
|
107 | + if (!$n instanceof Byte) |
|
108 | + { |
|
103 | 109 | // no other grammars are allowed |
104 | 110 | return null; |
105 | 111 | } |
106 | 112 | |
107 | - switch ($n->char) { |
|
113 | + switch ($n->char) |
|
114 | + { |
|
108 | 115 | case '"': |
109 | 116 | case "'": |
110 | - if ($this->default === null) { |
|
117 | + if ($this->default === null) |
|
118 | + { |
|
111 | 119 | // " and ' not allowed in names |
112 | 120 | return null; |
113 | 121 | } |
114 | 122 | |
115 | 123 | $this->default[] = $n; |
116 | - while ($nn = $src->next()) { |
|
124 | + while ($nn = $src->next()) |
|
125 | + { |
|
117 | 126 | $this->default[] = $nn; |
118 | - if ($nn instanceof Byte && $nn->char === $n->char) { |
|
127 | + if ($nn instanceof Byte && $nn->char === $n->char) |
|
128 | + { |
|
119 | 129 | break; |
120 | 130 | } |
121 | 131 | } |
@@ -148,17 +158,20 @@ discard block |
||
148 | 158 | break; |
149 | 159 | |
150 | 160 | default: |
151 | - if ($this->default !== null) { |
|
161 | + if ($this->default !== null) |
|
162 | + { |
|
152 | 163 | // default allows spaces |
153 | 164 | $this->default[] = $n; |
154 | 165 | break; |
155 | 166 | } |
156 | 167 | |
157 | - if (preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
168 | + if (preg_match(self::REGEXP_WHITESPACE, $n->char)) |
|
169 | + { |
|
158 | 170 | break; |
159 | 171 | } |
160 | 172 | |
161 | - if (preg_match(self::REGEXP_KEYWORD, $n->char)) { |
|
173 | + if (preg_match(self::REGEXP_KEYWORD, $n->char)) |
|
174 | + { |
|
162 | 175 | $this->name[] = $n; |
163 | 176 | break; |
164 | 177 | } |
@@ -167,7 +180,8 @@ discard block |
||
167 | 180 | } |
168 | 181 | } |
169 | 182 | |
170 | - if (!$this->isValid()) { |
|
183 | + if (!$this->isValid()) |
|
184 | + { |
|
171 | 185 | return null; |
172 | 186 | } |
173 | 187 | |
@@ -179,25 +193,31 @@ discard block |
||
179 | 193 | */ |
180 | 194 | private function isValid(): bool |
181 | 195 | { |
182 | - if (count($this->tokens) < 3) { |
|
196 | + if (count($this->tokens) < 3) |
|
197 | + { |
|
183 | 198 | return false; |
184 | 199 | } |
185 | 200 | |
186 | 201 | $hasName = false; |
187 | 202 | $hasDefault = null; |
188 | - foreach ($this->tokens as $token) { |
|
189 | - if ($token->type === self::TYPE_NAME) { |
|
203 | + foreach ($this->tokens as $token) |
|
204 | + { |
|
205 | + if ($token->type === self::TYPE_NAME) |
|
206 | + { |
|
190 | 207 | $hasName = true; |
191 | 208 | continue; |
192 | 209 | } |
193 | 210 | |
194 | - if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null) { |
|
211 | + if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null) |
|
212 | + { |
|
195 | 213 | $hasDefault = false; |
196 | 214 | continue; |
197 | 215 | } |
198 | 216 | |
199 | - if ($token->type === self::TYPE_DEFAULT) { |
|
200 | - if ($hasDefault === true) { |
|
217 | + if ($token->type === self::TYPE_DEFAULT) |
|
218 | + { |
|
219 | + if ($hasDefault === true) |
|
220 | + { |
|
201 | 221 | // multiple default value |
202 | 222 | return false; |
203 | 223 | } |
@@ -214,7 +234,8 @@ discard block |
||
214 | 234 | */ |
215 | 235 | private function flushName(): void |
216 | 236 | { |
217 | - if ($this->name === []) { |
|
237 | + if ($this->name === []) |
|
238 | + { |
|
218 | 239 | return; |
219 | 240 | } |
220 | 241 | |
@@ -227,7 +248,8 @@ discard block |
||
227 | 248 | */ |
228 | 249 | private function flushDefault(): void |
229 | 250 | { |
230 | - if ($this->default === [] || $this->default === null) { |
|
251 | + if ($this->default === [] || $this->default === null) |
|
252 | + { |
|
231 | 253 | return; |
232 | 254 | } |
233 | 255 |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function starts(Buffer $src, Byte $n): bool |
121 | 121 | { |
122 | - if (!$this->active) { |
|
122 | + if (!$this->active){ |
|
123 | 123 | return false; |
124 | 124 | } |
125 | 125 | |
126 | - return $this->startSequence === ($n->char . $src->lookaheadByte(strlen($this->startSequence) - 1)); |
|
126 | + return $this->startSequence === ($n->char.$src->lookaheadByte(strlen($this->startSequence) - 1)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -139,30 +139,30 @@ discard block |
||
139 | 139 | new Token( |
140 | 140 | $this->startToken, |
141 | 141 | $n->offset, |
142 | - $n->char . $this->nextBytes($src, strlen($this->startSequence) - 1) |
|
142 | + $n->char.$this->nextBytes($src, strlen($this->startSequence) - 1) |
|
143 | 143 | ), |
144 | 144 | ]; |
145 | 145 | |
146 | - while ($n = $src->next()) { |
|
147 | - if (!$n instanceof Byte) { |
|
146 | + while ($n = $src->next()){ |
|
147 | + if (!$n instanceof Byte){ |
|
148 | 148 | // no other grammars are allowed |
149 | 149 | break; |
150 | 150 | } |
151 | 151 | |
152 | - switch ($n->char) { |
|
152 | + switch ($n->char){ |
|
153 | 153 | case '"': |
154 | 154 | case "'": |
155 | 155 | $this->body[] = $n; |
156 | - while ($nn = $src->next()) { |
|
156 | + while ($nn = $src->next()){ |
|
157 | 157 | $this->body[] = $nn; |
158 | - if ($nn instanceof Byte && $nn->char === $n->char) { |
|
158 | + if ($nn instanceof Byte && $nn->char === $n->char){ |
|
159 | 159 | break; |
160 | 160 | } |
161 | 161 | } |
162 | 162 | break; |
163 | 163 | |
164 | 164 | case $this->endSequence[0]: |
165 | - if (!$this->ends($src, $n)) { |
|
165 | + if (!$this->ends($src, $n)){ |
|
166 | 166 | // still part of body |
167 | 167 | $this->body[] = $n; |
168 | 168 | break; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $this->tokens[] = new Token( |
173 | 173 | $this->endToken, |
174 | 174 | $n->offset, |
175 | - $n->char . $this->nextBytes($src, strlen($this->endSequence) - 1) |
|
175 | + $n->char.$this->nextBytes($src, strlen($this->endSequence) - 1) |
|
176 | 176 | ); |
177 | 177 | |
178 | 178 | break 2; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - if (count($this->tokens) !== 3) { |
|
184 | + if (count($this->tokens) !== 3){ |
|
185 | 185 | return null; |
186 | 186 | } |
187 | 187 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | private function ends(Buffer $src, Byte $n): bool |
199 | 199 | { |
200 | - return $this->endSequence === ($n->char . $src->lookaheadByte(strlen($this->endSequence) - 1)); |
|
200 | + return $this->endSequence === ($n->char.$src->lookaheadByte(strlen($this->endSequence) - 1)); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | private function nextBytes(Buffer $src, int $size): string |
211 | 211 | { |
212 | 212 | $result = ''; |
213 | - for ($i = 0; $i < $size; $i++) { |
|
213 | + for ($i = 0; $i < $size; $i++){ |
|
214 | 214 | $result .= $src->next()->char; |
215 | 215 | } |
216 | 216 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | private function flushBody(): void |
224 | 224 | { |
225 | - if ($this->body === []) { |
|
225 | + if ($this->body === []){ |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 |
@@ -119,7 +119,8 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function starts(Buffer $src, Byte $n): bool |
121 | 121 | { |
122 | - if (!$this->active) { |
|
122 | + if (!$this->active) |
|
123 | + { |
|
123 | 124 | return false; |
124 | 125 | } |
125 | 126 | |
@@ -143,26 +144,32 @@ discard block |
||
143 | 144 | ), |
144 | 145 | ]; |
145 | 146 | |
146 | - while ($n = $src->next()) { |
|
147 | - if (!$n instanceof Byte) { |
|
147 | + while ($n = $src->next()) |
|
148 | + { |
|
149 | + if (!$n instanceof Byte) |
|
150 | + { |
|
148 | 151 | // no other grammars are allowed |
149 | 152 | break; |
150 | 153 | } |
151 | 154 | |
152 | - switch ($n->char) { |
|
155 | + switch ($n->char) |
|
156 | + { |
|
153 | 157 | case '"': |
154 | 158 | case "'": |
155 | 159 | $this->body[] = $n; |
156 | - while ($nn = $src->next()) { |
|
160 | + while ($nn = $src->next()) |
|
161 | + { |
|
157 | 162 | $this->body[] = $nn; |
158 | - if ($nn instanceof Byte && $nn->char === $n->char) { |
|
163 | + if ($nn instanceof Byte && $nn->char === $n->char) |
|
164 | + { |
|
159 | 165 | break; |
160 | 166 | } |
161 | 167 | } |
162 | 168 | break; |
163 | 169 | |
164 | 170 | case $this->endSequence[0]: |
165 | - if (!$this->ends($src, $n)) { |
|
171 | + if (!$this->ends($src, $n)) |
|
172 | + { |
|
166 | 173 | // still part of body |
167 | 174 | $this->body[] = $n; |
168 | 175 | break; |
@@ -181,7 +188,8 @@ discard block |
||
181 | 188 | } |
182 | 189 | } |
183 | 190 | |
184 | - if (count($this->tokens) !== 3) { |
|
191 | + if (count($this->tokens) !== 3) |
|
192 | + { |
|
185 | 193 | return null; |
186 | 194 | } |
187 | 195 | |
@@ -210,7 +218,8 @@ discard block |
||
210 | 218 | private function nextBytes(Buffer $src, int $size): string |
211 | 219 | { |
212 | 220 | $result = ''; |
213 | - for ($i = 0; $i < $size; $i++) { |
|
221 | + for ($i = 0; $i < $size; $i++) |
|
222 | + { |
|
214 | 223 | $result .= $src->next()->char; |
215 | 224 | } |
216 | 225 | |
@@ -222,7 +231,8 @@ discard block |
||
222 | 231 | */ |
223 | 232 | private function flushBody(): void |
224 | 233 | { |
225 | - if ($this->body === []) { |
|
234 | + if ($this->body === []) |
|
235 | + { |
|
226 | 236 | return; |
227 | 237 | } |
228 | 238 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | declare(strict_types=1); |
11 | 11 | |
12 | -if (!function_exists('inject')) { |
|
12 | +if (!function_exists('inject')){ |
|
13 | 13 | /** |
14 | 14 | * Macro function to be replaced by the injected value. |
15 | 15 | * |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | -if (!function_exists('injected')) { |
|
26 | +if (!function_exists('injected')){ |
|
27 | 27 | /** |
28 | 28 | * Return true if block value has been defined. |
29 | 29 | * |
@@ -9,7 +9,8 @@ discard block |
||
9 | 9 | |
10 | 10 | declare(strict_types=1); |
11 | 11 | |
12 | -if (!function_exists('inject')) { |
|
12 | +if (!function_exists('inject')) |
|
13 | +{ |
|
13 | 14 | /** |
14 | 15 | * Macro function to be replaced by the injected value. |
15 | 16 | * |
@@ -23,7 +24,8 @@ discard block |
||
23 | 24 | } |
24 | 25 | } |
25 | 26 | |
26 | -if (!function_exists('injected')) { |
|
27 | +if (!function_exists('injected')) |
|
28 | +{ |
|
27 | 29 | /** |
28 | 30 | * Return true if block value has been defined. |
29 | 31 | * |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | $vendorDir = dirname(dirname($vendorDir)); |
11 | 11 | $vendorID = null; |
12 | 12 | $vendorCount = 0; |
13 | -foreach ($stacktrace as $index => $trace) { |
|
13 | +foreach ($stacktrace as $index => $trace){ |
|
14 | 14 | $args = []; |
15 | - if (isset($trace['args'])) { |
|
15 | + if (isset($trace['args'])){ |
|
16 | 16 | $args = $valueWrapper->wrap($trace['args']); |
17 | 17 | } |
18 | 18 | |
19 | - $function = '<strong>' . $trace['function'] . '</strong>'; |
|
20 | - if (isset($trace['type']) && isset($trace['class'])) { |
|
19 | + $function = '<strong>'.$trace['function'].'</strong>'; |
|
20 | + if (isset($trace['type']) && isset($trace['class'])){ |
|
21 | 21 | $reflection = new ReflectionClass($trace['class']); |
22 | 22 | $function = sprintf( |
23 | 23 | '<span title="%s">%s</span>%s%s', |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | ); |
29 | 29 | } |
30 | 30 | |
31 | - if (!isset($trace['file']) || !file_exists($trace['file'])) { ?> |
|
31 | + if (!isset($trace['file']) || !file_exists($trace['file'])){ ?> |
|
32 | 32 | <div class="container no-trace"> |
33 | 33 | <?= $function ?>(<span class="arguments"><?= implode(', ', $args) ?></span>) |
34 | 34 | </div> |
@@ -37,21 +37,21 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | $isVendor = strpos($trace['file'], $vendorDir) === 0 && $index > 1; |
40 | - if ($isVendor) { |
|
41 | - if ($vendorID === null) { |
|
40 | + if ($isVendor){ |
|
41 | + if ($vendorID === null){ |
|
42 | 42 | $vendorID = $index; |
43 | 43 | $vendorCount++; |
44 | 44 | echo sprintf('<span id="hidden-trace-%s" style="display: none;">', $vendorID); |
45 | - } else { |
|
45 | + }else{ |
|
46 | 46 | $vendorCount++; |
47 | 47 | } |
48 | - } elseif ($vendorID !== null) { |
|
48 | + } elseif ($vendorID !== null){ |
|
49 | 49 | echo '</span>'; |
50 | 50 | echo sprintf( |
51 | 51 | '<div id="%s" class="container" style="cursor: pointer;" onclick="toggle(\'%s\'); toggle(\'%s\');">+ %s vendor frame(s)...</div>', |
52 | - 'toggle-trace-' . $vendorID, |
|
53 | - 'toggle-trace-' . $vendorID, |
|
54 | - 'hidden-trace-' . $vendorID, |
|
52 | + 'toggle-trace-'.$vendorID, |
|
53 | + 'toggle-trace-'.$vendorID, |
|
54 | + 'hidden-trace-'.$vendorID, |
|
55 | 55 | $vendorCount |
56 | 56 | ); |
57 | 57 | $vendorID = null; |
@@ -72,6 +72,6 @@ discard block |
||
72 | 72 | <?php |
73 | 73 | } |
74 | 74 | |
75 | -if ($vendorID !== null) { |
|
75 | +if ($vendorID !== null){ |
|
76 | 76 | echo '</span>'; |
77 | 77 | } |
@@ -10,14 +10,17 @@ discard block |
||
10 | 10 | $vendorDir = dirname(dirname($vendorDir)); |
11 | 11 | $vendorID = null; |
12 | 12 | $vendorCount = 0; |
13 | -foreach ($stacktrace as $index => $trace) { |
|
13 | +foreach ($stacktrace as $index => $trace) |
|
14 | +{ |
|
14 | 15 | $args = []; |
15 | - if (isset($trace['args'])) { |
|
16 | + if (isset($trace['args'])) |
|
17 | + { |
|
16 | 18 | $args = $valueWrapper->wrap($trace['args']); |
17 | 19 | } |
18 | 20 | |
19 | 21 | $function = '<strong>' . $trace['function'] . '</strong>'; |
20 | - if (isset($trace['type']) && isset($trace['class'])) { |
|
22 | + if (isset($trace['type']) && isset($trace['class'])) |
|
23 | + { |
|
21 | 24 | $reflection = new ReflectionClass($trace['class']); |
22 | 25 | $function = sprintf( |
23 | 26 | '<span title="%s">%s</span>%s%s', |
@@ -28,7 +31,9 @@ discard block |
||
28 | 31 | ); |
29 | 32 | } |
30 | 33 | |
31 | - if (!isset($trace['file']) || !file_exists($trace['file'])) { ?> |
|
34 | + if (!isset($trace['file']) || !file_exists($trace['file'])) |
|
35 | + { |
|
36 | +?> |
|
32 | 37 | <div class="container no-trace"> |
33 | 38 | <?= $function ?>(<span class="arguments"><?= implode(', ', $args) ?></span>) |
34 | 39 | </div> |
@@ -37,15 +42,21 @@ discard block |
||
37 | 42 | } |
38 | 43 | |
39 | 44 | $isVendor = strpos($trace['file'], $vendorDir) === 0 && $index > 1; |
40 | - if ($isVendor) { |
|
41 | - if ($vendorID === null) { |
|
45 | + if ($isVendor) |
|
46 | + { |
|
47 | + if ($vendorID === null) |
|
48 | + { |
|
42 | 49 | $vendorID = $index; |
43 | 50 | $vendorCount++; |
44 | 51 | echo sprintf('<span id="hidden-trace-%s" style="display: none;">', $vendorID); |
45 | - } else { |
|
52 | + } |
|
53 | + else |
|
54 | + { |
|
46 | 55 | $vendorCount++; |
47 | 56 | } |
48 | - } elseif ($vendorID !== null) { |
|
57 | + } |
|
58 | + elseif ($vendorID !== null) |
|
59 | + { |
|
49 | 60 | echo '</span>'; |
50 | 61 | echo sprintf( |
51 | 62 | '<div id="%s" class="container" style="cursor: pointer;" onclick="toggle(\'%s\'); toggle(\'%s\');">+ %s vendor frame(s)...</div>', |
@@ -72,6 +83,7 @@ discard block |
||
72 | 83 | <?php |
73 | 84 | } |
74 | 85 | |
75 | -if ($vendorID !== null) { |
|
86 | +if ($vendorID !== null) |
|
87 | +{ |
|
76 | 88 | echo '</span>'; |
77 | 89 | } |
@@ -24,19 +24,19 @@ |
||
24 | 24 | */ |
25 | 25 | public function leaveNode(Node $node): void |
26 | 26 | { |
27 | - if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct') { |
|
28 | - foreach ($node->params as $param) { |
|
29 | - if ($param->type instanceof Node\NullableType) { |
|
30 | - if ($param->type->type instanceof Node\Identifier) { |
|
27 | + if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct'){ |
|
28 | + foreach ($node->params as $param){ |
|
29 | + if ($param->type instanceof Node\NullableType){ |
|
30 | + if ($param->type->type instanceof Node\Identifier){ |
|
31 | 31 | $type = $param->type->type->name; |
32 | - } else { |
|
32 | + }else{ |
|
33 | 33 | $type = implode('\\', $param->type->type->parts); |
34 | 34 | } |
35 | 35 | |
36 | 36 | $type = "?$type"; |
37 | - } elseif ($param->type instanceof Node\Name) { |
|
37 | + } elseif ($param->type instanceof Node\Name){ |
|
38 | 38 | $type = implode('\\', $param->type->parts); |
39 | - } else { |
|
39 | + }else{ |
|
40 | 40 | $type = $param->type->name ?? null; |
41 | 41 | } |
42 | 42 |
@@ -24,19 +24,29 @@ |
||
24 | 24 | */ |
25 | 25 | public function leaveNode(Node $node): void |
26 | 26 | { |
27 | - if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct') { |
|
28 | - foreach ($node->params as $param) { |
|
29 | - if ($param->type instanceof Node\NullableType) { |
|
30 | - if ($param->type->type instanceof Node\Identifier) { |
|
27 | + if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct') |
|
28 | + { |
|
29 | + foreach ($node->params as $param) |
|
30 | + { |
|
31 | + if ($param->type instanceof Node\NullableType) |
|
32 | + { |
|
33 | + if ($param->type->type instanceof Node\Identifier) |
|
34 | + { |
|
31 | 35 | $type = $param->type->type->name; |
32 | - } else { |
|
36 | + } |
|
37 | + else |
|
38 | + { |
|
33 | 39 | $type = implode('\\', $param->type->type->parts); |
34 | 40 | } |
35 | 41 | |
36 | 42 | $type = "?$type"; |
37 | - } elseif ($param->type instanceof Node\Name) { |
|
43 | + } |
|
44 | + elseif ($param->type instanceof Node\Name) |
|
45 | + { |
|
38 | 46 | $type = implode('\\', $param->type->parts); |
39 | - } else { |
|
47 | + } |
|
48 | + else |
|
49 | + { |
|
40 | 50 | $type = $param->type->name ?? null; |
41 | 51 | } |
42 | 52 |