@@ -257,10 +257,13 @@ |
||
257 | 257 | { |
258 | 258 | $result = []; |
259 | 259 | |
260 | - foreach ($response->getHeaders() as $header) { |
|
261 | - foreach ($header as $headerLine) { |
|
260 | + foreach ($response->getHeaders() as $header) |
|
261 | + { |
|
262 | + foreach ($header as $headerLine) |
|
263 | + { |
|
262 | 264 | $chunk = \explode(';', $headerLine); |
263 | - if (\mb_strpos($chunk[0], '=') === false) { |
|
265 | + if (\mb_strpos($chunk[0], '=') === false) |
|
266 | + { |
|
264 | 267 | continue; |
265 | 268 | } |
266 | 269 |
@@ -25,14 +25,18 @@ discard block |
||
25 | 25 | |
26 | 26 | public function __construct( |
27 | 27 | private readonly CsrfConfig $config, |
28 | - ) {} |
|
28 | + ) { |
|
29 | +} |
|
29 | 30 | |
30 | 31 | public function process(Request $request, RequestHandlerInterface $handler): Response |
31 | 32 | { |
32 | 33 | $cookie = null; |
33 | - if (isset($request->getCookieParams()[$this->config->getCookie()])) { |
|
34 | + if (isset($request->getCookieParams()[$this->config->getCookie()])) |
|
35 | + { |
|
34 | 36 | $token = $request->getCookieParams()[$this->config->getCookie()]; |
35 | - } else { |
|
37 | + } |
|
38 | + else |
|
39 | + { |
|
36 | 40 | //Making new token |
37 | 41 | $token = $this->random($this->config->getTokenLength()); |
38 | 42 | |
@@ -43,7 +47,8 @@ discard block |
||
43 | 47 | //CSRF issues must be handled by Firewall middleware |
44 | 48 | $response = $handler->handle($request->withAttribute(self::ATTRIBUTE, $token)); |
45 | 49 | |
46 | - if (!empty($cookie)) { |
|
50 | + if (!empty($cookie)) |
|
51 | + { |
|
47 | 52 | return $response->withAddedHeader('Set-Cookie', $cookie); |
48 | 53 | } |
49 | 54 | |
@@ -74,11 +79,15 @@ discard block |
||
74 | 79 | */ |
75 | 80 | private function random(int $length = 32): string |
76 | 81 | { |
77 | - try { |
|
78 | - if (empty($string = \random_bytes($length))) { |
|
82 | + try |
|
83 | + { |
|
84 | + if (empty($string = \random_bytes($length))) |
|
85 | + { |
|
79 | 86 | throw new \RuntimeException('Unable to generate random string'); |
80 | 87 | } |
81 | - } catch (\Throwable $e) { |
|
88 | + } |
|
89 | + catch (\Throwable $e) |
|
90 | + { |
|
82 | 91 | throw new \RuntimeException('Unable to generate random string', (int) $e->getCode(), $e); |
83 | 92 | } |
84 | 93 |
@@ -89,7 +89,8 @@ discard block |
||
89 | 89 | |
90 | 90 | public function testClosureFactory(): void |
91 | 91 | { |
92 | - $this->bind(Bucket::class, static function ($data) { |
|
92 | + $this->bind(Bucket::class, static function ($data) |
|
93 | + { |
|
93 | 94 | return new Bucket('via-closure', $data); |
94 | 95 | }); |
95 | 96 | |
@@ -129,7 +130,8 @@ discard block |
||
129 | 130 | $sample = new SampleClass(); |
130 | 131 | |
131 | 132 | $this->bind(Bucket::class, [Factory::class, 'makeBucketWithSample']); |
132 | - $this->bind(SampleClass::class, static function () use ($sample) { |
|
133 | + $this->bind(SampleClass::class, static function () use ($sample) |
|
134 | + { |
|
133 | 135 | return $sample; |
134 | 136 | }); |
135 | 137 |
@@ -35,8 +35,10 @@ |
||
35 | 35 | $map = new \WeakMap(); |
36 | 36 | |
37 | 37 | $fn = function (\WeakMap $map): void { |
38 | - foreach ($this as $key => $value) { |
|
39 | - if (\is_object($value)) { |
|
38 | + foreach ($this as $key => $value) |
|
39 | + { |
|
40 | + if (\is_object($value)) |
|
41 | + { |
|
40 | 42 | $map->offsetSet($value, $key); |
41 | 43 | } |
42 | 44 | } |
@@ -13,12 +13,14 @@ |
||
13 | 13 | { |
14 | 14 | (static function (): void { |
15 | 15 | $container = new Container(); |
16 | - $finalizer = new class { |
|
16 | + $finalizer = new class |
|
17 | + { |
|
17 | 18 | public ?\Closure $closure = null; |
18 | 19 | |
19 | 20 | public function __destruct() |
20 | 21 | { |
21 | - if ($this->closure !== null) { |
|
22 | + if ($this->closure !== null) |
|
23 | + { |
|
22 | 24 | ($this->closure)(); |
23 | 25 | } |
24 | 26 | } |
@@ -32,11 +32,14 @@ discard block |
||
32 | 32 | |
33 | 33 | self::assertNull(ContainerScope::getContainer()); |
34 | 34 | |
35 | - try { |
|
35 | + try |
|
36 | + { |
|
36 | 37 | self::assertTrue(ContainerScope::runScope($container, static function (): never { |
37 | 38 | throw new RuntimeException('exception'); |
38 | 39 | })); |
39 | - } catch (\Throwable $e) { |
|
40 | + } |
|
41 | + catch (\Throwable $e) |
|
42 | + { |
|
40 | 43 | } |
41 | 44 | |
42 | 45 | self::assertInstanceOf(RuntimeException::class, $e); |
@@ -83,14 +86,17 @@ discard block |
||
83 | 86 | return $c->get('bucket')->getName() == 'b' && $c->has('other'); |
84 | 87 | })); |
85 | 88 | |
86 | - try { |
|
89 | + try |
|
90 | + { |
|
87 | 91 | self::assertTrue($c->runScope([ |
88 | 92 | 'bucket' => new Bucket('b'), |
89 | 93 | 'other' => new SampleClass(), |
90 | 94 | ], static function () use ($c): void { |
91 | 95 | throw new RuntimeException('exception'); |
92 | 96 | })); |
93 | - } catch (\Throwable) { |
|
97 | + } |
|
98 | + catch (\Throwable) |
|
99 | + { |
|
94 | 100 | } |
95 | 101 | |
96 | 102 | self::assertSame('a', $c->get('bucket')->getName()); |
@@ -135,7 +141,9 @@ discard block |
||
135 | 141 | public function testHasInstanceAfterMakeWithoutAliasInScope(): void |
136 | 142 | { |
137 | 143 | $container = new Container(); |
138 | - $container->bindSingleton('test', new #[Singleton] class {}); |
|
144 | + $container->bindSingleton('test', new #[Singleton] class |
|
145 | + { |
|
146 | +}); |
|
139 | 147 | $container->make('test'); |
140 | 148 | |
141 | 149 | $container->runScoped(static function (Container $container): void { |
@@ -18,7 +18,8 @@ discard block |
||
18 | 18 | protected readonly MemoryInterface $memory, |
19 | 19 | protected readonly ListenerInvoker $invoker, |
20 | 20 | protected readonly bool $readCache = true, |
21 | - ) {} |
|
21 | + ) { |
|
22 | +} |
|
22 | 23 | |
23 | 24 | protected function doLoad( |
24 | 25 | TokenizationListenerInterface $listener, |
@@ -28,7 +29,8 @@ discard block |
||
28 | 29 | $targets = \iterator_to_array($this->parseAttributes($listener)); |
29 | 30 | |
30 | 31 | // If there are no targets, then listener can't be cached. |
31 | - if ($targets === []) { |
|
32 | + if ($targets === []) |
|
33 | + { |
|
32 | 34 | return false; |
33 | 35 | } |
34 | 36 | |
@@ -37,11 +39,13 @@ discard block |
||
37 | 39 | // We decided to load classes/enums/interfaces for each target separately. |
38 | 40 | // It allows us to cache classes/enums/interfaces for each target separately and if we reuse the |
39 | 41 | // same target in multiple listeners, we will not have to load classes/enums/interfaces for the same target. |
40 | - foreach ($targets as $target) { |
|
42 | + foreach ($targets as $target) |
|
43 | + { |
|
41 | 44 | $cacheKey = $this->cacheKeyPrefix . $target; |
42 | 45 | |
43 | 46 | $classes = $this->readCache ? $this->memory->loadData($cacheKey) : null; |
44 | - if ($classes === null) { |
|
47 | + if ($classes === null) |
|
48 | + { |
|
45 | 49 | $this->memory->saveData($cacheKey, $classes = \call_user_func($locator, $target)); |
46 | 50 | } |
47 | 51 |
@@ -144,7 +144,8 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function getClasses(): array |
146 | 146 | { |
147 | - if (!isset($this->declarations['T_CLASS'])) { |
|
147 | + if (!isset($this->declarations['T_CLASS'])) |
|
148 | + { |
|
148 | 149 | return []; |
149 | 150 | } |
150 | 151 | |
@@ -156,7 +157,8 @@ discard block |
||
156 | 157 | */ |
157 | 158 | public function getEnums(): array |
158 | 159 | { |
159 | - if (!isset($this->declarations['T_ENUM'])) { |
|
160 | + if (!isset($this->declarations['T_ENUM'])) |
|
161 | + { |
|
160 | 162 | return []; |
161 | 163 | } |
162 | 164 | |
@@ -168,7 +170,8 @@ discard block |
||
168 | 170 | */ |
169 | 171 | public function getTraits(): array |
170 | 172 | { |
171 | - if (!isset($this->declarations['T_TRAIT'])) { |
|
173 | + if (!isset($this->declarations['T_TRAIT'])) |
|
174 | + { |
|
172 | 175 | return []; |
173 | 176 | } |
174 | 177 | |
@@ -180,7 +183,8 @@ discard block |
||
180 | 183 | */ |
181 | 184 | public function getInterfaces(): array |
182 | 185 | { |
183 | - if (!isset($this->declarations['T_INTERFACE'])) { |
|
186 | + if (!isset($this->declarations['T_INTERFACE'])) |
|
187 | + { |
|
184 | 188 | return []; |
185 | 189 | } |
186 | 190 | |
@@ -211,7 +215,8 @@ discard block |
||
211 | 215 | */ |
212 | 216 | public function getInvocations(): array |
213 | 217 | { |
214 | - if (empty($this->invocations)) { |
|
218 | + if (empty($this->invocations)) |
|
219 | + { |
|
215 | 220 | $this->locateInvocations($this->getTokens()); |
216 | 221 | } |
217 | 222 | |
@@ -239,12 +244,15 @@ discard block |
||
239 | 244 | */ |
240 | 245 | protected function locateDeclarations(): void |
241 | 246 | { |
242 | - foreach ($this->getTokens() as $tokenID => $token) { |
|
243 | - if (!\in_array($token[self::TOKEN_TYPE], self::$processTokens)) { |
|
247 | + foreach ($this->getTokens() as $tokenID => $token) |
|
248 | + { |
|
249 | + if (!\in_array($token[self::TOKEN_TYPE], self::$processTokens)) |
|
250 | + { |
|
244 | 251 | continue; |
245 | 252 | } |
246 | 253 | |
247 | - switch ($token[self::TOKEN_TYPE]) { |
|
254 | + switch ($token[self::TOKEN_TYPE]) |
|
255 | + { |
|
248 | 256 | case T_NAMESPACE: |
249 | 257 | $this->registerNamespace($tokenID); |
250 | 258 | break; |
@@ -261,17 +269,20 @@ discard block |
||
261 | 269 | case T_TRAIT: |
262 | 270 | case T_INTERFACE: |
263 | 271 | case T_ENUM: |
264 | - if ($this->isClassNameConst($tokenID)) { |
|
272 | + if ($this->isClassNameConst($tokenID)) |
|
273 | + { |
|
265 | 274 | // PHP5.5 ClassName::class constant |
266 | 275 | continue 2; |
267 | 276 | } |
268 | 277 | |
269 | - if ($this->isAnonymousClass($tokenID)) { |
|
278 | + if ($this->isAnonymousClass($tokenID)) |
|
279 | + { |
|
270 | 280 | // PHP7.0 Anonymous classes new class ('foo', 'bar') |
271 | 281 | continue 2; |
272 | 282 | } |
273 | 283 | |
274 | - if (!$this->isCorrectDeclaration($tokenID)) { |
|
284 | + if (!$this->isCorrectDeclaration($tokenID)) |
|
285 | + { |
|
275 | 286 | // PHP8.0 Named parameters ->foo(class: 'bar') |
276 | 287 | continue 2; |
277 | 288 | } |
@@ -288,7 +299,8 @@ discard block |
||
288 | 299 | } |
289 | 300 | |
290 | 301 | //Dropping empty namespace |
291 | - if (isset($this->namespaces[''])) { |
|
302 | + if (isset($this->namespaces[''])) |
|
303 | + { |
|
292 | 304 | $this->namespaces['\\'] = $this->namespaces['']; |
293 | 305 | unset($this->namespaces['']); |
294 | 306 | } |
@@ -302,9 +314,11 @@ discard block |
||
302 | 314 | $namespace = ''; |
303 | 315 | $localID = $tokenID + 1; |
304 | 316 | |
305 | - do { |
|
317 | + do |
|
318 | + { |
|
306 | 319 | $token = $this->tokens[$localID++]; |
307 | - if ($token[self::TOKEN_CODE] === '{') { |
|
320 | + if ($token[self::TOKEN_CODE] === '{') |
|
321 | + { |
|
308 | 322 | break; |
309 | 323 | } |
310 | 324 | |
@@ -319,13 +333,17 @@ discard block |
||
319 | 333 | $namespace = \trim($namespace); |
320 | 334 | |
321 | 335 | $uses = []; |
322 | - if (isset($this->namespaces[$namespace])) { |
|
336 | + if (isset($this->namespaces[$namespace])) |
|
337 | + { |
|
323 | 338 | $uses = $this->namespaces[$namespace]; |
324 | 339 | } |
325 | 340 | |
326 | - if ($this->tokens[$localID][self::TOKEN_CODE] === ';') { |
|
341 | + if ($this->tokens[$localID][self::TOKEN_CODE] === ';') |
|
342 | + { |
|
327 | 343 | $endingID = \count($this->tokens) - 1; |
328 | - } else { |
|
344 | + } |
|
345 | + else |
|
346 | + { |
|
329 | 347 | $endingID = $this->endingToken($tokenID); |
330 | 348 | } |
331 | 349 | |
@@ -345,20 +363,26 @@ discard block |
||
345 | 363 | |
346 | 364 | $class = ''; |
347 | 365 | $localAlias = null; |
348 | - for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] !== ';'; ++$localID) { |
|
349 | - if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS) { |
|
366 | + for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] !== ';'; ++$localID) |
|
367 | + { |
|
368 | + if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS) |
|
369 | + { |
|
350 | 370 | $localAlias = ''; |
351 | 371 | continue; |
352 | 372 | } |
353 | 373 | |
354 | - if ($localAlias === null) { |
|
374 | + if ($localAlias === null) |
|
375 | + { |
|
355 | 376 | $class .= $this->tokens[$localID][self::TOKEN_CODE]; |
356 | - } else { |
|
377 | + } |
|
378 | + else |
|
379 | + { |
|
357 | 380 | $localAlias .= $this->tokens[$localID][self::TOKEN_CODE]; |
358 | 381 | } |
359 | 382 | } |
360 | 383 | |
361 | - if (empty($localAlias)) { |
|
384 | + if (empty($localAlias)) |
|
385 | + { |
|
362 | 386 | $names = \explode('\\', $class); |
363 | 387 | $localAlias = \end($names); |
364 | 388 | } |
@@ -371,9 +395,12 @@ discard block |
||
371 | 395 | */ |
372 | 396 | private function registerFunction(int $tokenID): void |
373 | 397 | { |
374 | - foreach ($this->declarations as $declarations) { |
|
375 | - foreach ($declarations as $location) { |
|
376 | - if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN]) { |
|
398 | + foreach ($this->declarations as $declarations) |
|
399 | + { |
|
400 | + foreach ($declarations as $location) |
|
401 | + { |
|
402 | + if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN]) |
|
403 | + { |
|
377 | 404 | //We are inside class, function is method |
378 | 405 | return; |
379 | 406 | } |
@@ -381,13 +408,15 @@ discard block |
||
381 | 408 | } |
382 | 409 | |
383 | 410 | $localID = $tokenID + 1; |
384 | - while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) { |
|
411 | + while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) |
|
412 | + { |
|
385 | 413 | //Fetching function name |
386 | 414 | ++$localID; |
387 | 415 | } |
388 | 416 | |
389 | 417 | $name = $this->tokens[$localID][self::TOKEN_CODE]; |
390 | - if (!empty($namespace = $this->activeNamespace($tokenID))) { |
|
418 | + if (!empty($namespace = $this->activeNamespace($tokenID))) |
|
419 | + { |
|
391 | 420 | $name = $namespace . self::NS_SEPARATOR . $name; |
392 | 421 | } |
393 | 422 | |
@@ -404,12 +433,14 @@ discard block |
||
404 | 433 | private function registerDeclaration(int $tokenID, int $tokenType): void |
405 | 434 | { |
406 | 435 | $localID = $tokenID + 1; |
407 | - while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) { |
|
436 | + while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) |
|
437 | + { |
|
408 | 438 | ++$localID; |
409 | 439 | } |
410 | 440 | |
411 | 441 | $name = $this->tokens[$localID][self::TOKEN_CODE]; |
412 | - if (!empty($namespace = $this->activeNamespace($tokenID))) { |
|
442 | + if (!empty($namespace = $this->activeNamespace($tokenID))) |
|
443 | + { |
|
413 | 444 | $name = $namespace . self::NS_SEPARATOR . $name; |
414 | 445 | } |
415 | 446 | |
@@ -474,11 +505,13 @@ discard block |
||
474 | 505 | |
475 | 506 | //Tokens used to re-enable token detection |
476 | 507 | $stopTokens = [T_STRING, T_WHITESPACE, T_DOUBLE_COLON, T_OBJECT_OPERATOR, T_NS_SEPARATOR]; |
477 | - foreach ($tokens as $tokenID => $token) { |
|
508 | + foreach ($tokens as $tokenID => $token) |
|
509 | + { |
|
478 | 510 | $tokenType = $token[self::TOKEN_TYPE]; |
479 | 511 | |
480 | 512 | //We are not indexing function declarations or functions called from $objects. |
481 | - if (\in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW])) { |
|
513 | + if (\in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW])) |
|
514 | + { |
|
482 | 515 | if ( |
483 | 516 | empty($argumentsTID) |
484 | 517 | && ( |
@@ -490,8 +523,11 @@ discard block |
||
490 | 523 | $ignore = true; |
491 | 524 | continue; |
492 | 525 | } |
493 | - } elseif ($ignore) { |
|
494 | - if (!\in_array($tokenType, $stopTokens)) { |
|
526 | + } |
|
527 | + elseif ($ignore) |
|
528 | + { |
|
529 | + if (!\in_array($tokenType, $stopTokens)) |
|
530 | + { |
|
495 | 531 | //Returning to search |
496 | 532 | $ignore = false; |
497 | 533 | } |
@@ -499,13 +535,16 @@ discard block |
||
499 | 535 | } |
500 | 536 | |
501 | 537 | //We are inside function, and there is "(", indexing arguments. |
502 | - if (!empty($invocationTID) && ($tokenType === '(' || $tokenType === '[')) { |
|
503 | - if (empty($argumentsTID)) { |
|
538 | + if (!empty($invocationTID) && ($tokenType === '(' || $tokenType === '[')) |
|
539 | + { |
|
540 | + if (empty($argumentsTID)) |
|
541 | + { |
|
504 | 542 | $argumentsTID = $tokenID; |
505 | 543 | } |
506 | 544 | |
507 | 545 | ++$level; |
508 | - if ($level != 1) { |
|
546 | + if ($level != 1) |
|
547 | + { |
|
509 | 548 | //Not arguments beginning, but arguments part |
510 | 549 | $arguments[$tokenID] = $token; |
511 | 550 | } |
@@ -514,16 +553,19 @@ discard block |
||
514 | 553 | } |
515 | 554 | |
516 | 555 | //We are inside function arguments and ")" met. |
517 | - if (!empty($invocationTID) && ($tokenType === ')' || $tokenType === ']')) { |
|
556 | + if (!empty($invocationTID) && ($tokenType === ')' || $tokenType === ']')) |
|
557 | + { |
|
518 | 558 | --$level; |
519 | - if ($level == -1) { |
|
559 | + if ($level == -1) |
|
560 | + { |
|
520 | 561 | $invocationTID = false; |
521 | 562 | $level = 0; |
522 | 563 | continue; |
523 | 564 | } |
524 | 565 | |
525 | 566 | //Function fully indexed, we can process it now. |
526 | - if ($level == 0) { |
|
567 | + if ($level == 0) |
|
568 | + { |
|
527 | 569 | $this->registerInvocation( |
528 | 570 | $invocationTID, |
529 | 571 | $argumentsTID, |
@@ -535,7 +577,9 @@ discard block |
||
535 | 577 | //Closing search |
536 | 578 | $arguments = []; |
537 | 579 | $argumentsTID = $invocationTID = false; |
538 | - } else { |
|
580 | + } |
|
581 | + else |
|
582 | + { |
|
539 | 583 | //Not arguments beginning, but arguments part |
540 | 584 | $arguments[$tokenID] = $token; |
541 | 585 | } |
@@ -544,13 +588,15 @@ discard block |
||
544 | 588 | } |
545 | 589 | |
546 | 590 | //Still inside arguments. |
547 | - if (!empty($invocationTID) && !empty($level)) { |
|
591 | + if (!empty($invocationTID) && !empty($level)) |
|
592 | + { |
|
548 | 593 | $arguments[$tokenID] = $token; |
549 | 594 | continue; |
550 | 595 | } |
551 | 596 | |
552 | 597 | //Nothing valuable to remember, will be parsed later. |
553 | - if (!empty($invocationTID) && \in_array($tokenType, $stopTokens)) { |
|
598 | + if (!empty($invocationTID) && \in_array($tokenType, $stopTokens)) |
|
599 | + { |
|
554 | 600 | continue; |
555 | 601 | } |
556 | 602 | |
@@ -589,7 +635,8 @@ discard block |
||
589 | 635 | |
590 | 636 | [$class, $operator, $name] = $this->fetchContext($invocationID, $argumentsID); |
591 | 637 | |
592 | - if (!empty($operator) && empty($class)) { |
|
638 | + if (!empty($operator) && empty($class)) |
|
639 | + { |
|
593 | 640 | //Non detectable |
594 | 641 | return; |
595 | 642 | } |
@@ -615,17 +662,22 @@ discard block |
||
615 | 662 | $name = \trim($this->getSource($invocationTID, $argumentsTID), '( '); |
616 | 663 | |
617 | 664 | //Let's try to fetch all information we need |
618 | - if (\str_contains($name, '->')) { |
|
665 | + if (\str_contains($name, '->')) |
|
666 | + { |
|
619 | 667 | $operator = '->'; |
620 | - } elseif (\str_contains($name, '::')) { |
|
668 | + } |
|
669 | + elseif (\str_contains($name, '::')) |
|
670 | + { |
|
621 | 671 | $operator = '::'; |
622 | 672 | } |
623 | 673 | |
624 | - if (!empty($operator)) { |
|
674 | + if (!empty($operator)) |
|
675 | + { |
|
625 | 676 | [$class, $name] = \explode($operator, $name); |
626 | 677 | |
627 | 678 | //We now have to clarify class name |
628 | - if (\in_array($class, ['self', 'static', '$this'])) { |
|
679 | + if (\in_array($class, ['self', 'static', '$this'])) |
|
680 | + { |
|
629 | 681 | $class = $this->activeDeclaration($invocationTID); |
630 | 682 | } |
631 | 683 | } |
@@ -638,9 +690,12 @@ discard block |
||
638 | 690 | */ |
639 | 691 | private function activeDeclaration(int $tokenID): string |
640 | 692 | { |
641 | - foreach ($this->declarations as $declarations) { |
|
642 | - foreach ($declarations as $name => $position) { |
|
643 | - if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) { |
|
693 | + foreach ($this->declarations as $declarations) |
|
694 | + { |
|
695 | + foreach ($declarations as $name => $position) |
|
696 | + { |
|
697 | + if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) |
|
698 | + { |
|
644 | 699 | return $name; |
645 | 700 | } |
646 | 701 | } |
@@ -655,8 +710,10 @@ discard block |
||
655 | 710 | */ |
656 | 711 | private function activeNamespace(int $tokenID): string |
657 | 712 | { |
658 | - foreach ($this->namespaces as $namespace => $position) { |
|
659 | - if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) { |
|
713 | + foreach ($this->namespaces as $namespace => $position) |
|
714 | + { |
|
715 | + if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) |
|
716 | + { |
|
660 | 717 | return $namespace; |
661 | 718 | } |
662 | 719 | } |
@@ -677,18 +734,22 @@ discard block |
||
677 | 734 | private function endingToken(int $tokenID): int |
678 | 735 | { |
679 | 736 | $level = null; |
680 | - for ($localID = $tokenID; $localID < $this->countTokens; ++$localID) { |
|
737 | + for ($localID = $tokenID; $localID < $this->countTokens; ++$localID) |
|
738 | + { |
|
681 | 739 | $token = $this->tokens[$localID]; |
682 | - if ($token[self::TOKEN_CODE] === '{') { |
|
740 | + if ($token[self::TOKEN_CODE] === '{') |
|
741 | + { |
|
683 | 742 | ++$level; |
684 | 743 | continue; |
685 | 744 | } |
686 | 745 | |
687 | - if ($token[self::TOKEN_CODE] === '}') { |
|
746 | + if ($token[self::TOKEN_CODE] === '}') |
|
747 | + { |
|
688 | 748 | --$level; |
689 | 749 | } |
690 | 750 | |
691 | - if ($level === 0) { |
|
751 | + if ($level === 0) |
|
752 | + { |
|
692 | 753 | break; |
693 | 754 | } |
694 | 755 | } |
@@ -701,7 +762,8 @@ discard block |
||
701 | 762 | */ |
702 | 763 | private function lineNumber(int $tokenID): int |
703 | 764 | { |
704 | - while (empty($this->tokens[$tokenID][self::TOKEN_LINE])) { |
|
765 | + while (empty($this->tokens[$tokenID][self::TOKEN_LINE])) |
|
766 | + { |
|
705 | 767 | --$tokenID; |
706 | 768 | } |
707 | 769 | |
@@ -714,7 +776,8 @@ discard block |
||
714 | 776 | private function getSource(int $startID, int $endID): string |
715 | 777 | { |
716 | 778 | $result = ''; |
717 | - for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID) { |
|
779 | + for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID) |
|
780 | + { |
|
718 | 781 | //Collecting function usage src |
719 | 782 | $result .= $this->tokens[$tokenID][self::TOKEN_CODE]; |
720 | 783 | } |
@@ -26,9 +26,12 @@ discard block |
||
26 | 26 | |
27 | 27 | $http->setHandler( |
28 | 28 | static function (ServerRequestInterface $request): void { |
29 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
29 | + if ($request->getAttribute('authContext')->getToken() === null) |
|
30 | + { |
|
30 | 31 | echo 'no token'; |
31 | - } else { |
|
32 | + } |
|
33 | + else |
|
34 | + { |
|
32 | 35 | echo $request->getAttribute('authContext')->getToken()->getID(); |
33 | 36 | echo ':'; |
34 | 37 | echo \json_encode($request->getAttribute('authContext')->getToken()->getPayload()); |
@@ -50,9 +53,12 @@ discard block |
||
50 | 53 | |
51 | 54 | $http->setHandler( |
52 | 55 | static function (ServerRequestInterface $request): void { |
53 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
56 | + if ($request->getAttribute('authContext')->getToken() === null) |
|
57 | + { |
|
54 | 58 | echo 'no token'; |
55 | - } else { |
|
59 | + } |
|
60 | + else |
|
61 | + { |
|
56 | 62 | echo $request->getAttribute('authContext')->getToken()->getID(); |
57 | 63 | echo ':'; |
58 | 64 | echo \json_encode($request->getAttribute('authContext')->getToken()->getPayload()); |
@@ -74,9 +80,12 @@ discard block |
||
74 | 80 | |
75 | 81 | $http->setHandler( |
76 | 82 | static function (ServerRequestInterface $request): void { |
77 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
83 | + if ($request->getAttribute('authContext')->getToken() === null) |
|
84 | + { |
|
78 | 85 | echo 'no token'; |
79 | - } else { |
|
86 | + } |
|
87 | + else |
|
88 | + { |
|
80 | 89 | echo $request->getAttribute('authContext')->getToken()->getID(); |
81 | 90 | echo ':'; |
82 | 91 | echo \json_encode($request->getAttribute('authContext')->getToken()->getPayload()); |