@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | { |
20 | 20 | public function __construct( |
21 | 21 | private readonly ?ScopeInterface $scope = new Container(), |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -28,33 +28,33 @@ discard block |
||
28 | 28 | final protected function runScope(SpanInterface $span, callable $callback): mixed |
29 | 29 | { |
30 | 30 | $container = ContainerScope::getContainer(); |
31 | - if ($container === null) { |
|
31 | + if ($container === null){ |
|
32 | 32 | return $this->scope->runScope([ |
33 | 33 | SpanInterface::class => $span, |
34 | 34 | TracerInterface::class => $this, |
35 | 35 | ], static fn (InvokerInterface $invoker): mixed => $invoker->invoke($callback)); |
36 | 36 | } |
37 | 37 | |
38 | - if ($container instanceof Container) { |
|
38 | + if ($container instanceof Container){ |
|
39 | 39 | $invoker = $container; |
40 | 40 | $binder = $container; |
41 | - } else { |
|
41 | + }else{ |
|
42 | 42 | /** @var InvokerInterface $invoker */ |
43 | 43 | $invoker = $container->get(InvokerInterface::class); |
44 | 44 | /** @var BinderInterface $binder */ |
45 | 45 | $binder = $container->get(BinderInterface::class); |
46 | 46 | } |
47 | 47 | |
48 | - try { |
|
48 | + try{ |
|
49 | 49 | $prevSpan = $container->get(SpanInterface::class); |
50 | - } catch (\Throwable) { |
|
50 | + }catch (\Throwable){ |
|
51 | 51 | $prevSpan = null; |
52 | 52 | } |
53 | 53 | |
54 | 54 | $binder->bindSingleton(SpanInterface::class, $span); |
55 | - try { |
|
55 | + try{ |
|
56 | 56 | return $invoker->invoke($callback); |
57 | - } finally { |
|
57 | + }finally{ |
|
58 | 58 | $prevSpan === null |
59 | 59 | ? $binder->removeBinding(SpanInterface::class) |
60 | 60 | : $binder->bindSingleton(SpanInterface::class, $prevSpan); |
@@ -28,33 +28,43 @@ |
||
28 | 28 | final protected function runScope(SpanInterface $span, callable $callback): mixed |
29 | 29 | { |
30 | 30 | $container = ContainerScope::getContainer(); |
31 | - if ($container === null) { |
|
31 | + if ($container === null) |
|
32 | + { |
|
32 | 33 | return $this->scope->runScope([ |
33 | 34 | SpanInterface::class => $span, |
34 | 35 | TracerInterface::class => $this, |
35 | 36 | ], static fn (InvokerInterface $invoker): mixed => $invoker->invoke($callback)); |
36 | 37 | } |
37 | 38 | |
38 | - if ($container instanceof Container) { |
|
39 | + if ($container instanceof Container) |
|
40 | + { |
|
39 | 41 | $invoker = $container; |
40 | 42 | $binder = $container; |
41 | - } else { |
|
43 | + } |
|
44 | + else |
|
45 | + { |
|
42 | 46 | /** @var InvokerInterface $invoker */ |
43 | 47 | $invoker = $container->get(InvokerInterface::class); |
44 | 48 | /** @var BinderInterface $binder */ |
45 | 49 | $binder = $container->get(BinderInterface::class); |
46 | 50 | } |
47 | 51 | |
48 | - try { |
|
52 | + try |
|
53 | + { |
|
49 | 54 | $prevSpan = $container->get(SpanInterface::class); |
50 | - } catch (\Throwable) { |
|
55 | + } |
|
56 | + catch (\Throwable) |
|
57 | + { |
|
51 | 58 | $prevSpan = null; |
52 | 59 | } |
53 | 60 | |
54 | 61 | $binder->bindSingleton(SpanInterface::class, $span); |
55 | - try { |
|
62 | + try |
|
63 | + { |
|
56 | 64 | return $invoker->invoke($callback); |
57 | - } finally { |
|
65 | + } |
|
66 | + finally |
|
67 | + { |
|
58 | 68 | $prevSpan === null |
59 | 69 | ? $binder->removeBinding(SpanInterface::class) |
60 | 70 | : $binder->bindSingleton(SpanInterface::class, $prevSpan); |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | |
48 | 48 | public function parse(Buffer $src): \Generator |
49 | 49 | { |
50 | - while ($n = $src->next()) { |
|
51 | - if (!$n instanceof Byte || $n->char !== '<') { |
|
50 | + while ($n = $src->next()){ |
|
51 | + if (!$n instanceof Byte || $n->char !== '<'){ |
|
52 | 52 | yield $n; |
53 | 53 | continue; |
54 | 54 | } |
55 | 55 | |
56 | 56 | // work with isolated token stream! |
57 | 57 | $tag = (clone $this)->parseGrammar($src); |
58 | - if ($tag === null) { |
|
58 | + if ($tag === null){ |
|
59 | 59 | yield $n; |
60 | 60 | $src->replay($n->offset); |
61 | 61 | continue; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $tagName = $this->tagName($tag); |
65 | 65 | |
66 | 66 | // todo: add support for custom tag list |
67 | - if (\in_array($tagName, self::VERBATIM_TAGS)) { |
|
67 | + if (\in_array($tagName, self::VERBATIM_TAGS)){ |
|
68 | 68 | yield from $tag; |
69 | 69 | yield from $this->parseVerbatim($src, $tagName); |
70 | 70 | continue; |
@@ -98,26 +98,26 @@ discard block |
||
98 | 98 | { |
99 | 99 | $chunks = []; |
100 | 100 | |
101 | - while ($n = $src->next()) { |
|
102 | - if ($n instanceof Token) { |
|
101 | + while ($n = $src->next()){ |
|
102 | + if ($n instanceof Token){ |
|
103 | 103 | $chunks[] = $n; |
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | |
107 | - switch ($n->char) { |
|
107 | + switch ($n->char){ |
|
108 | 108 | case '"': |
109 | 109 | case "'": |
110 | 110 | case '`': |
111 | 111 | $chunks[] = $n; |
112 | 112 | |
113 | 113 | // language inclusions allow nested strings |
114 | - while ($nc = $src->next()) { |
|
114 | + while ($nc = $src->next()){ |
|
115 | 115 | $chunks[] = $nc; |
116 | - if ($nc instanceof Token) { |
|
116 | + if ($nc instanceof Token){ |
|
117 | 117 | continue; |
118 | 118 | } |
119 | 119 | |
120 | - if ($nc->char === $n->char) { |
|
120 | + if ($nc->char === $n->char){ |
|
121 | 121 | break; |
122 | 122 | } |
123 | 123 | } |
@@ -128,22 +128,22 @@ discard block |
||
128 | 128 | $chunks[] = $n; |
129 | 129 | |
130 | 130 | $multiline = false; |
131 | - if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*') { |
|
132 | - if ($src->lookaheadByte(1) === '*') { |
|
131 | + if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*'){ |
|
132 | + if ($src->lookaheadByte(1) === '*'){ |
|
133 | 133 | $multiline = true; |
134 | 134 | } |
135 | 135 | |
136 | 136 | $chunks[] = $src->next(); |
137 | 137 | |
138 | 138 | // language inclusions allow nested strings |
139 | - while ($nc = $src->next()) { |
|
140 | - if ($nc instanceof Token) { |
|
139 | + while ($nc = $src->next()){ |
|
140 | + if ($nc instanceof Token){ |
|
141 | 141 | continue; |
142 | 142 | } |
143 | 143 | |
144 | - if ($nc->char === '<') { |
|
144 | + if ($nc->char === '<'){ |
|
145 | 145 | $tag = (clone $this)->parseGrammar($src); |
146 | - if ($tag === null || $this->tagName($tag) !== $verbatim) { |
|
146 | + if ($tag === null || $this->tagName($tag) !== $verbatim){ |
|
147 | 147 | $src->replay($n->offset); |
148 | 148 | break; |
149 | 149 | } |
@@ -154,12 +154,12 @@ discard block |
||
154 | 154 | |
155 | 155 | $chunks[] = $nc; |
156 | 156 | |
157 | - if ($multiline) { |
|
158 | - if ($nc->char === '*' && $src->lookaheadByte(1) === '/') { |
|
157 | + if ($multiline){ |
|
158 | + if ($nc->char === '*' && $src->lookaheadByte(1) === '/'){ |
|
159 | 159 | $chunks[] = $src->next(); |
160 | 160 | break; |
161 | 161 | } |
162 | - } elseif ($nc->char === "\n") { |
|
162 | + } elseif ($nc->char === "\n"){ |
|
163 | 163 | break; |
164 | 164 | } |
165 | 165 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | case '<': |
171 | 171 | // tag beginning? |
172 | 172 | $tag = (clone $this)->parseGrammar($src); |
173 | - if ($tag === null || $this->tagName($tag) !== $verbatim) { |
|
173 | + if ($tag === null || $this->tagName($tag) !== $verbatim){ |
|
174 | 174 | $chunks[] = $n; |
175 | 175 | $src->replay($n->offset); |
176 | 176 | break; |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | |
191 | 191 | private function tagName(array $tag): string |
192 | 192 | { |
193 | - foreach ($tag as $token) { |
|
194 | - if ($token->type === self::TYPE_KEYWORD) { |
|
195 | - return \strtolower((string) $token->content); |
|
193 | + foreach ($tag as $token){ |
|
194 | + if ($token->type === self::TYPE_KEYWORD){ |
|
195 | + return \strtolower((string)$token->content); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -210,28 +210,28 @@ discard block |
||
210 | 210 | new Token(self::TYPE_OPEN, $src->getOffset(), '<'), |
211 | 211 | ]; |
212 | 212 | |
213 | - if ($src->lookaheadByte() === '/') { |
|
213 | + if ($src->lookaheadByte() === '/'){ |
|
214 | 214 | $this->tokens[0]->type = self::TYPE_OPEN_SHORT; |
215 | 215 | $this->tokens[0]->content .= $src->next()->char; |
216 | 216 | } |
217 | 217 | |
218 | - while ($n = $src->next()) { |
|
219 | - if ($this->attribute !== []) { |
|
218 | + while ($n = $src->next()){ |
|
219 | + if ($this->attribute !== []){ |
|
220 | 220 | $this->attribute[] = $n; |
221 | 221 | |
222 | - if ($n instanceof Byte && $n->char === $this->attribute[0]->char) { |
|
222 | + if ($n instanceof Byte && $n->char === $this->attribute[0]->char){ |
|
223 | 223 | $this->flushAttribute(); |
224 | 224 | } |
225 | 225 | |
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | |
229 | - if ($n instanceof Token) { |
|
229 | + if ($n instanceof Token){ |
|
230 | 230 | $this->keyword[] = $n; |
231 | 231 | continue; |
232 | 232 | } |
233 | 233 | |
234 | - switch ($n->char) { |
|
234 | + switch ($n->char){ |
|
235 | 235 | case '"': |
236 | 236 | case "'": |
237 | 237 | case '`': |
@@ -249,12 +249,12 @@ discard block |
||
249 | 249 | break; |
250 | 250 | |
251 | 251 | case '/': |
252 | - if ($src->lookaheadByte() === '>') { |
|
252 | + if ($src->lookaheadByte() === '>'){ |
|
253 | 253 | $this->flush(); |
254 | 254 | $this->tokens[] = new Token( |
255 | 255 | self::TYPE_CLOSE_SHORT, |
256 | 256 | $n->offset, |
257 | - $n->char . $src->next()->char |
|
257 | + $n->char.$src->next()->char |
|
258 | 258 | ); |
259 | 259 | |
260 | 260 | break 2; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | break 2; |
274 | 274 | |
275 | 275 | default: |
276 | - if (\preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
276 | + if (\preg_match(self::REGEXP_WHITESPACE, $n->char)){ |
|
277 | 277 | $this->flushKeyword(); |
278 | 278 | $this->whitespace[] = $n; |
279 | 279 | break; |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $this->flushWhitespace(); |
282 | 282 | |
283 | 283 | |
284 | - if (!\preg_match(self::REGEXP_KEYWORD, $n->char)) { |
|
284 | + if (!\preg_match(self::REGEXP_KEYWORD, $n->char)){ |
|
285 | 285 | // unexpected char |
286 | 286 | return null; |
287 | 287 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | - if (!$this->isValid()) { |
|
293 | + if (!$this->isValid()){ |
|
294 | 294 | return null; |
295 | 295 | } |
296 | 296 | |
@@ -300,17 +300,17 @@ discard block |
||
300 | 300 | private function isValid(): bool |
301 | 301 | { |
302 | 302 | // tag is too short or does not have name keyword |
303 | - if (\count($this->tokens) < 3) { |
|
303 | + if (\count($this->tokens) < 3){ |
|
304 | 304 | return false; |
305 | 305 | } |
306 | 306 | |
307 | 307 | $last = $this->tokens[\count($this->tokens) - 1]; |
308 | - if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT) { |
|
308 | + if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT){ |
|
309 | 309 | return false; |
310 | 310 | } |
311 | 311 | |
312 | - foreach ($this->tokens as $token) { |
|
313 | - switch ($token->type) { |
|
312 | + foreach ($this->tokens as $token){ |
|
313 | + switch ($token->type){ |
|
314 | 314 | case self::TYPE_WHITESPACE: |
315 | 315 | // ignore |
316 | 316 | continue 2; |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | */ |
342 | 342 | private function flushWhitespace(): void |
343 | 343 | { |
344 | - if ($this->whitespace === []) { |
|
344 | + if ($this->whitespace === []){ |
|
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | */ |
355 | 355 | private function flushKeyword(): void |
356 | 356 | { |
357 | - if ($this->keyword === []) { |
|
357 | + if ($this->keyword === []){ |
|
358 | 358 | return; |
359 | 359 | } |
360 | 360 | |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | */ |
368 | 368 | private function flushAttribute(): void |
369 | 369 | { |
370 | - if ($this->attribute === []) { |
|
370 | + if ($this->attribute === []){ |
|
371 | 371 | return; |
372 | 372 | } |
373 | 373 |
@@ -47,15 +47,18 @@ discard block |
||
47 | 47 | |
48 | 48 | public function parse(Buffer $src): \Generator |
49 | 49 | { |
50 | - while ($n = $src->next()) { |
|
51 | - if (!$n instanceof Byte || $n->char !== '<') { |
|
50 | + while ($n = $src->next()) |
|
51 | + { |
|
52 | + if (!$n instanceof Byte || $n->char !== '<') |
|
53 | + { |
|
52 | 54 | yield $n; |
53 | 55 | continue; |
54 | 56 | } |
55 | 57 | |
56 | 58 | // work with isolated token stream! |
57 | 59 | $tag = (clone $this)->parseGrammar($src); |
58 | - if ($tag === null) { |
|
60 | + if ($tag === null) |
|
61 | + { |
|
59 | 62 | yield $n; |
60 | 63 | $src->replay($n->offset); |
61 | 64 | continue; |
@@ -64,7 +67,8 @@ discard block |
||
64 | 67 | $tagName = $this->tagName($tag); |
65 | 68 | |
66 | 69 | // todo: add support for custom tag list |
67 | - if (\in_array($tagName, self::VERBATIM_TAGS)) { |
|
70 | + if (\in_array($tagName, self::VERBATIM_TAGS)) |
|
71 | + { |
|
68 | 72 | yield from $tag; |
69 | 73 | yield from $this->parseVerbatim($src, $tagName); |
70 | 74 | continue; |
@@ -98,26 +102,32 @@ discard block |
||
98 | 102 | { |
99 | 103 | $chunks = []; |
100 | 104 | |
101 | - while ($n = $src->next()) { |
|
102 | - if ($n instanceof Token) { |
|
105 | + while ($n = $src->next()) |
|
106 | + { |
|
107 | + if ($n instanceof Token) |
|
108 | + { |
|
103 | 109 | $chunks[] = $n; |
104 | 110 | continue; |
105 | 111 | } |
106 | 112 | |
107 | - switch ($n->char) { |
|
113 | + switch ($n->char) |
|
114 | + { |
|
108 | 115 | case '"': |
109 | 116 | case "'": |
110 | 117 | case '`': |
111 | 118 | $chunks[] = $n; |
112 | 119 | |
113 | 120 | // language inclusions allow nested strings |
114 | - while ($nc = $src->next()) { |
|
121 | + while ($nc = $src->next()) |
|
122 | + { |
|
115 | 123 | $chunks[] = $nc; |
116 | - if ($nc instanceof Token) { |
|
124 | + if ($nc instanceof Token) |
|
125 | + { |
|
117 | 126 | continue; |
118 | 127 | } |
119 | 128 | |
120 | - if ($nc->char === $n->char) { |
|
129 | + if ($nc->char === $n->char) |
|
130 | + { |
|
121 | 131 | break; |
122 | 132 | } |
123 | 133 | } |
@@ -128,22 +138,28 @@ discard block |
||
128 | 138 | $chunks[] = $n; |
129 | 139 | |
130 | 140 | $multiline = false; |
131 | - if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*') { |
|
132 | - if ($src->lookaheadByte(1) === '*') { |
|
141 | + if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*') |
|
142 | + { |
|
143 | + if ($src->lookaheadByte(1) === '*') |
|
144 | + { |
|
133 | 145 | $multiline = true; |
134 | 146 | } |
135 | 147 | |
136 | 148 | $chunks[] = $src->next(); |
137 | 149 | |
138 | 150 | // language inclusions allow nested strings |
139 | - while ($nc = $src->next()) { |
|
140 | - if ($nc instanceof Token) { |
|
151 | + while ($nc = $src->next()) |
|
152 | + { |
|
153 | + if ($nc instanceof Token) |
|
154 | + { |
|
141 | 155 | continue; |
142 | 156 | } |
143 | 157 | |
144 | - if ($nc->char === '<') { |
|
158 | + if ($nc->char === '<') |
|
159 | + { |
|
145 | 160 | $tag = (clone $this)->parseGrammar($src); |
146 | - if ($tag === null || $this->tagName($tag) !== $verbatim) { |
|
161 | + if ($tag === null || $this->tagName($tag) !== $verbatim) |
|
162 | + { |
|
147 | 163 | $src->replay($n->offset); |
148 | 164 | break; |
149 | 165 | } |
@@ -154,12 +170,16 @@ discard block |
||
154 | 170 | |
155 | 171 | $chunks[] = $nc; |
156 | 172 | |
157 | - if ($multiline) { |
|
158 | - if ($nc->char === '*' && $src->lookaheadByte(1) === '/') { |
|
173 | + if ($multiline) |
|
174 | + { |
|
175 | + if ($nc->char === '*' && $src->lookaheadByte(1) === '/') |
|
176 | + { |
|
159 | 177 | $chunks[] = $src->next(); |
160 | 178 | break; |
161 | 179 | } |
162 | - } elseif ($nc->char === "\n") { |
|
180 | + } |
|
181 | + elseif ($nc->char === "\n") |
|
182 | + { |
|
163 | 183 | break; |
164 | 184 | } |
165 | 185 | } |
@@ -170,7 +190,8 @@ discard block |
||
170 | 190 | case '<': |
171 | 191 | // tag beginning? |
172 | 192 | $tag = (clone $this)->parseGrammar($src); |
173 | - if ($tag === null || $this->tagName($tag) !== $verbatim) { |
|
193 | + if ($tag === null || $this->tagName($tag) !== $verbatim) |
|
194 | + { |
|
174 | 195 | $chunks[] = $n; |
175 | 196 | $src->replay($n->offset); |
176 | 197 | break; |
@@ -190,8 +211,10 @@ discard block |
||
190 | 211 | |
191 | 212 | private function tagName(array $tag): string |
192 | 213 | { |
193 | - foreach ($tag as $token) { |
|
194 | - if ($token->type === self::TYPE_KEYWORD) { |
|
214 | + foreach ($tag as $token) |
|
215 | + { |
|
216 | + if ($token->type === self::TYPE_KEYWORD) |
|
217 | + { |
|
195 | 218 | return \strtolower((string) $token->content); |
196 | 219 | } |
197 | 220 | } |
@@ -210,28 +233,34 @@ discard block |
||
210 | 233 | new Token(self::TYPE_OPEN, $src->getOffset(), '<'), |
211 | 234 | ]; |
212 | 235 | |
213 | - if ($src->lookaheadByte() === '/') { |
|
236 | + if ($src->lookaheadByte() === '/') |
|
237 | + { |
|
214 | 238 | $this->tokens[0]->type = self::TYPE_OPEN_SHORT; |
215 | 239 | $this->tokens[0]->content .= $src->next()->char; |
216 | 240 | } |
217 | 241 | |
218 | - while ($n = $src->next()) { |
|
219 | - if ($this->attribute !== []) { |
|
242 | + while ($n = $src->next()) |
|
243 | + { |
|
244 | + if ($this->attribute !== []) |
|
245 | + { |
|
220 | 246 | $this->attribute[] = $n; |
221 | 247 | |
222 | - if ($n instanceof Byte && $n->char === $this->attribute[0]->char) { |
|
248 | + if ($n instanceof Byte && $n->char === $this->attribute[0]->char) |
|
249 | + { |
|
223 | 250 | $this->flushAttribute(); |
224 | 251 | } |
225 | 252 | |
226 | 253 | continue; |
227 | 254 | } |
228 | 255 | |
229 | - if ($n instanceof Token) { |
|
256 | + if ($n instanceof Token) |
|
257 | + { |
|
230 | 258 | $this->keyword[] = $n; |
231 | 259 | continue; |
232 | 260 | } |
233 | 261 | |
234 | - switch ($n->char) { |
|
262 | + switch ($n->char) |
|
263 | + { |
|
235 | 264 | case '"': |
236 | 265 | case "'": |
237 | 266 | case '`': |
@@ -249,7 +278,8 @@ discard block |
||
249 | 278 | break; |
250 | 279 | |
251 | 280 | case '/': |
252 | - if ($src->lookaheadByte() === '>') { |
|
281 | + if ($src->lookaheadByte() === '>') |
|
282 | + { |
|
253 | 283 | $this->flush(); |
254 | 284 | $this->tokens[] = new Token( |
255 | 285 | self::TYPE_CLOSE_SHORT, |
@@ -273,7 +303,8 @@ discard block |
||
273 | 303 | break 2; |
274 | 304 | |
275 | 305 | default: |
276 | - if (\preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
306 | + if (\preg_match(self::REGEXP_WHITESPACE, $n->char)) |
|
307 | + { |
|
277 | 308 | $this->flushKeyword(); |
278 | 309 | $this->whitespace[] = $n; |
279 | 310 | break; |
@@ -281,7 +312,8 @@ discard block |
||
281 | 312 | $this->flushWhitespace(); |
282 | 313 | |
283 | 314 | |
284 | - if (!\preg_match(self::REGEXP_KEYWORD, $n->char)) { |
|
315 | + if (!\preg_match(self::REGEXP_KEYWORD, $n->char)) |
|
316 | + { |
|
285 | 317 | // unexpected char |
286 | 318 | return null; |
287 | 319 | } |
@@ -290,7 +322,8 @@ discard block |
||
290 | 322 | } |
291 | 323 | } |
292 | 324 | |
293 | - if (!$this->isValid()) { |
|
325 | + if (!$this->isValid()) |
|
326 | + { |
|
294 | 327 | return null; |
295 | 328 | } |
296 | 329 | |
@@ -300,17 +333,21 @@ discard block |
||
300 | 333 | private function isValid(): bool |
301 | 334 | { |
302 | 335 | // tag is too short or does not have name keyword |
303 | - if (\count($this->tokens) < 3) { |
|
336 | + if (\count($this->tokens) < 3) |
|
337 | + { |
|
304 | 338 | return false; |
305 | 339 | } |
306 | 340 | |
307 | 341 | $last = $this->tokens[\count($this->tokens) - 1]; |
308 | - if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT) { |
|
342 | + if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT) |
|
343 | + { |
|
309 | 344 | return false; |
310 | 345 | } |
311 | 346 | |
312 | - foreach ($this->tokens as $token) { |
|
313 | - switch ($token->type) { |
|
347 | + foreach ($this->tokens as $token) |
|
348 | + { |
|
349 | + switch ($token->type) |
|
350 | + { |
|
314 | 351 | case self::TYPE_WHITESPACE: |
315 | 352 | // ignore |
316 | 353 | continue 2; |
@@ -341,7 +378,8 @@ discard block |
||
341 | 378 | */ |
342 | 379 | private function flushWhitespace(): void |
343 | 380 | { |
344 | - if ($this->whitespace === []) { |
|
381 | + if ($this->whitespace === []) |
|
382 | + { |
|
345 | 383 | return; |
346 | 384 | } |
347 | 385 | |
@@ -354,7 +392,8 @@ discard block |
||
354 | 392 | */ |
355 | 393 | private function flushKeyword(): void |
356 | 394 | { |
357 | - if ($this->keyword === []) { |
|
395 | + if ($this->keyword === []) |
|
396 | + { |
|
358 | 397 | return; |
359 | 398 | } |
360 | 399 | |
@@ -367,7 +406,8 @@ discard block |
||
367 | 406 | */ |
368 | 407 | private function flushAttribute(): void |
369 | 408 | { |
370 | - if ($this->attribute === []) { |
|
409 | + if ($this->attribute === []) |
|
410 | + { |
|
371 | 411 | return; |
372 | 412 | } |
373 | 413 |