@@ -10,9 +10,9 @@ |
||
10 | 10 | |
11 | 11 | public function __construct(?\Throwable $previous = null) |
12 | 12 | { |
13 | - parent::__construct((string) $previous?->getMessage(), (int) ($previous?->getCode() ?? 0), $previous); |
|
14 | - $this->file = (string) $previous?->getFile(); |
|
15 | - $this->line = (int) $previous?->getLine(); |
|
13 | + parent::__construct((string)$previous?->getMessage(), (int)($previous?->getCode() ?? 0), $previous); |
|
14 | + $this->file = (string)$previous?->getFile(); |
|
15 | + $this->line = (int)$previous?->getLine(); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | public function reset(?ContextInterface $context = null): void |
14 | 14 | { |
15 | - if (empty($context)) { |
|
15 | + if (empty($context)){ |
|
16 | 16 | $this->cache = []; |
17 | 17 | return; |
18 | 18 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function resetPath(string $path): void |
27 | 27 | { |
28 | - foreach ($this->cache as &$cache) { |
|
28 | + foreach ($this->cache as &$cache){ |
|
29 | 29 | unset($cache[$path], $cache); |
30 | 30 | } |
31 | 31 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function get(ContextInterface $context, string $path): ViewInterface |
47 | 47 | { |
48 | - if (!$this->has($context, $path)) { |
|
48 | + if (!$this->has($context, $path)){ |
|
49 | 49 | throw new CacheException(\sprintf('No cache is available for %s.', $path)); |
50 | 50 | } |
51 | 51 |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | |
13 | 13 | public function reset(?ContextInterface $context = null): void |
14 | 14 | { |
15 | - if (empty($context)) { |
|
15 | + if (empty($context)) |
|
16 | + { |
|
16 | 17 | $this->cache = []; |
17 | 18 | return; |
18 | 19 | } |
@@ -25,7 +26,8 @@ discard block |
||
25 | 26 | */ |
26 | 27 | public function resetPath(string $path): void |
27 | 28 | { |
28 | - foreach ($this->cache as &$cache) { |
|
29 | + foreach ($this->cache as &$cache) |
|
30 | + { |
|
29 | 31 | unset($cache[$path], $cache); |
30 | 32 | } |
31 | 33 | } |
@@ -45,7 +47,8 @@ discard block |
||
45 | 47 | */ |
46 | 48 | public function get(ContextInterface $context, string $path): ViewInterface |
47 | 49 | { |
48 | - if (!$this->has($context, $path)) { |
|
50 | + if (!$this->has($context, $path)) |
|
51 | + { |
|
49 | 52 | throw new CacheException(\sprintf('No cache is available for %s.', $path)); |
50 | 53 | } |
51 | 54 |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | */ |
30 | 30 | protected function getLogger(?string $channel = null): LoggerInterface |
31 | 31 | { |
32 | - if ($channel !== null) { |
|
32 | + if ($channel !== null){ |
|
33 | 33 | return $this->allocateLogger($channel); |
34 | 34 | } |
35 | 35 | |
36 | - if ($this->logger !== null) { |
|
36 | + if ($this->logger !== null){ |
|
37 | 37 | return $this->logger; |
38 | 38 | } |
39 | 39 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | private function allocateLogger(string $channel): LoggerInterface |
48 | 48 | { |
49 | 49 | $container = ContainerScope::getContainer(); |
50 | - if ($container === null || !$container->has(LogsInterface::class)) { |
|
50 | + if ($container === null || !$container->has(LogsInterface::class)){ |
|
51 | 51 | return $this->logger ?? new NullLogger(); |
52 | 52 | } |
53 | 53 |
@@ -29,11 +29,13 @@ discard block |
||
29 | 29 | */ |
30 | 30 | protected function getLogger(?string $channel = null): LoggerInterface |
31 | 31 | { |
32 | - if ($channel !== null) { |
|
32 | + if ($channel !== null) |
|
33 | + { |
|
33 | 34 | return $this->allocateLogger($channel); |
34 | 35 | } |
35 | 36 | |
36 | - if ($this->logger !== null) { |
|
37 | + if ($this->logger !== null) |
|
38 | + { |
|
37 | 39 | return $this->logger; |
38 | 40 | } |
39 | 41 | |
@@ -47,7 +49,8 @@ discard block |
||
47 | 49 | private function allocateLogger(string $channel): LoggerInterface |
48 | 50 | { |
49 | 51 | $container = ContainerScope::getContainer(); |
50 | - if ($container === null || !$container->has(LogsInterface::class)) { |
|
52 | + if ($container === null || !$container->has(LogsInterface::class)) |
|
53 | + { |
|
51 | 54 | return $this->logger ?? new NullLogger(); |
52 | 55 | } |
53 | 56 |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | { |
14 | 14 | public const INJECTOR = InterfaceLocatorInjector::class; |
15 | 15 | |
16 | - public function getInterfaces(string|null $target = null): array |
|
16 | + public function getInterfaces(string | null $target = null): array |
|
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)){ |
|
19 | 19 | $target = new \ReflectionClass($target); |
20 | 20 | } |
21 | 21 | |
22 | 22 | $result = []; |
23 | - foreach ($this->availableInterfaces() as $interface) { |
|
24 | - try { |
|
23 | + foreach ($this->availableInterfaces() as $interface){ |
|
24 | + try{ |
|
25 | 25 | $reflection = $this->classReflection($interface); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
26 | + }catch (LocatorException $e){ |
|
27 | + if ($this->debug){ |
|
28 | 28 | throw $e; |
29 | 29 | } |
30 | 30 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | continue; |
33 | 33 | } |
34 | 34 | |
35 | - if (!$this->isTargeted($reflection, $target)) { |
|
35 | + if (!$this->isTargeted($reflection, $target)){ |
|
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $interfaces = []; |
53 | 53 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
54 | + foreach ($this->availableReflections() as $reflection){ |
|
55 | 55 | $interfaces = \array_merge($interfaces, $reflection->getInterfaces()); |
56 | 56 | } |
57 | 57 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function isTargeted(\ReflectionClass $class, ?\ReflectionClass $target = null): bool |
65 | 65 | { |
66 | - if (empty($target)) { |
|
66 | + if (empty($target)){ |
|
67 | 67 | return true; |
68 | 68 | } |
69 | 69 |
@@ -15,16 +15,22 @@ discard block |
||
15 | 15 | |
16 | 16 | public function getInterfaces(string|null $target = null): array |
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)) |
|
19 | + { |
|
19 | 20 | $target = new \ReflectionClass($target); |
20 | 21 | } |
21 | 22 | |
22 | 23 | $result = []; |
23 | - foreach ($this->availableInterfaces() as $interface) { |
|
24 | - try { |
|
24 | + foreach ($this->availableInterfaces() as $interface) |
|
25 | + { |
|
26 | + try |
|
27 | + { |
|
25 | 28 | $reflection = $this->classReflection($interface); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
29 | + } |
|
30 | + catch (LocatorException $e) |
|
31 | + { |
|
32 | + if ($this->debug) |
|
33 | + { |
|
28 | 34 | throw $e; |
29 | 35 | } |
30 | 36 | |
@@ -32,7 +38,8 @@ discard block |
||
32 | 38 | continue; |
33 | 39 | } |
34 | 40 | |
35 | - if (!$this->isTargeted($reflection, $target)) { |
|
41 | + if (!$this->isTargeted($reflection, $target)) |
|
42 | + { |
|
36 | 43 | continue; |
37 | 44 | } |
38 | 45 | |
@@ -51,7 +58,8 @@ discard block |
||
51 | 58 | { |
52 | 59 | $interfaces = []; |
53 | 60 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
61 | + foreach ($this->availableReflections() as $reflection) |
|
62 | + { |
|
55 | 63 | $interfaces = \array_merge($interfaces, $reflection->getInterfaces()); |
56 | 64 | } |
57 | 65 | |
@@ -63,7 +71,8 @@ discard block |
||
63 | 71 | */ |
64 | 72 | protected function isTargeted(\ReflectionClass $class, ?\ReflectionClass $target = null): bool |
65 | 73 | { |
66 | - if (empty($target)) { |
|
74 | + if (empty($target)) |
|
75 | + { |
|
67 | 76 | return true; |
68 | 77 | } |
69 | 78 |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | { |
14 | 14 | public const INJECTOR = EnumLocatorInjector::class; |
15 | 15 | |
16 | - public function getEnums(object|string|null $target = null): array |
|
16 | + public function getEnums(object | string | null $target = null): array |
|
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)){ |
|
19 | 19 | $target = new \ReflectionClass($target); |
20 | 20 | } |
21 | 21 | |
22 | 22 | $result = []; |
23 | - foreach ($this->availableEnums() as $enum) { |
|
24 | - try { |
|
23 | + foreach ($this->availableEnums() as $enum){ |
|
24 | + try{ |
|
25 | 25 | $reflection = $this->enumReflection($enum); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
26 | + }catch (LocatorException $e){ |
|
27 | + if ($this->debug){ |
|
28 | 28 | throw $e; |
29 | 29 | } |
30 | 30 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | continue; |
33 | 33 | } |
34 | 34 | |
35 | - if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) { |
|
35 | + if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()){ |
|
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $enums = []; |
53 | 53 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
54 | + foreach ($this->availableReflections() as $reflection){ |
|
55 | 55 | $enums = \array_merge($enums, $reflection->getEnums()); |
56 | 56 | } |
57 | 57 | |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function isTargeted(\ReflectionEnum $enum, ?\ReflectionClass $target = null): bool |
65 | 65 | { |
66 | - if ($target === null) { |
|
66 | + if ($target === null){ |
|
67 | 67 | return true; |
68 | 68 | } |
69 | 69 | |
70 | - if (!$target->isTrait()) { |
|
70 | + if (!$target->isTrait()){ |
|
71 | 71 | //Target is interface or class |
72 | 72 | /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */ |
73 | 73 | return $enum->isSubclassOf($target) || $enum->getName() === $target->getName(); |
@@ -15,16 +15,22 @@ discard block |
||
15 | 15 | |
16 | 16 | public function getEnums(object|string|null $target = null): array |
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)) |
|
19 | + { |
|
19 | 20 | $target = new \ReflectionClass($target); |
20 | 21 | } |
21 | 22 | |
22 | 23 | $result = []; |
23 | - foreach ($this->availableEnums() as $enum) { |
|
24 | - try { |
|
24 | + foreach ($this->availableEnums() as $enum) |
|
25 | + { |
|
26 | + try |
|
27 | + { |
|
25 | 28 | $reflection = $this->enumReflection($enum); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
29 | + } |
|
30 | + catch (LocatorException $e) |
|
31 | + { |
|
32 | + if ($this->debug) |
|
33 | + { |
|
28 | 34 | throw $e; |
29 | 35 | } |
30 | 36 | |
@@ -32,7 +38,8 @@ discard block |
||
32 | 38 | continue; |
33 | 39 | } |
34 | 40 | |
35 | - if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) { |
|
41 | + if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) |
|
42 | + { |
|
36 | 43 | continue; |
37 | 44 | } |
38 | 45 | |
@@ -51,7 +58,8 @@ discard block |
||
51 | 58 | { |
52 | 59 | $enums = []; |
53 | 60 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
61 | + foreach ($this->availableReflections() as $reflection) |
|
62 | + { |
|
55 | 63 | $enums = \array_merge($enums, $reflection->getEnums()); |
56 | 64 | } |
57 | 65 | |
@@ -63,11 +71,13 @@ discard block |
||
63 | 71 | */ |
64 | 72 | protected function isTargeted(\ReflectionEnum $enum, ?\ReflectionClass $target = null): bool |
65 | 73 | { |
66 | - if ($target === null) { |
|
74 | + if ($target === null) |
|
75 | + { |
|
67 | 76 | return true; |
68 | 77 | } |
69 | 78 | |
70 | - if (!$target->isTrait()) { |
|
79 | + if (!$target->isTrait()) |
|
80 | + { |
|
71 | 81 | //Target is interface or class |
72 | 82 | /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */ |
73 | 83 | return $enum->isSubclassOf($target) || $enum->getName() === $target->getName(); |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | { |
14 | 14 | public const INJECTOR = ClassLocatorInjector::class; |
15 | 15 | |
16 | - public function getClasses(object|string|null $target = null): array |
|
16 | + public function getClasses(object | string | null $target = null): array |
|
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)){ |
|
19 | 19 | $target = new \ReflectionClass($target); |
20 | 20 | } |
21 | 21 | |
22 | 22 | $result = []; |
23 | - foreach ($this->availableClasses() as $class) { |
|
24 | - try { |
|
23 | + foreach ($this->availableClasses() as $class){ |
|
24 | + try{ |
|
25 | 25 | $reflection = $this->classReflection($class); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
26 | + }catch (LocatorException $e){ |
|
27 | + if ($this->debug){ |
|
28 | 28 | throw $e; |
29 | 29 | } |
30 | 30 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | continue; |
33 | 33 | } |
34 | 34 | |
35 | - if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) { |
|
35 | + if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()){ |
|
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $classes = []; |
53 | 53 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
54 | + foreach ($this->availableReflections() as $reflection){ |
|
55 | 55 | $classes = \array_merge($classes, $reflection->getClasses()); |
56 | 56 | } |
57 | 57 | |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function isTargeted(\ReflectionClass $class, ?\ReflectionClass $target = null): bool |
65 | 65 | { |
66 | - if (empty($target)) { |
|
66 | + if (empty($target)){ |
|
67 | 67 | return true; |
68 | 68 | } |
69 | 69 | |
70 | - if (!$target->isTrait()) { |
|
70 | + if (!$target->isTrait()){ |
|
71 | 71 | //Target is interface or class |
72 | 72 | return $class->isSubclassOf($target) || $class->getName() === $target->getName(); |
73 | 73 | } |
@@ -15,16 +15,22 @@ discard block |
||
15 | 15 | |
16 | 16 | public function getClasses(object|string|null $target = null): array |
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)) |
|
19 | + { |
|
19 | 20 | $target = new \ReflectionClass($target); |
20 | 21 | } |
21 | 22 | |
22 | 23 | $result = []; |
23 | - foreach ($this->availableClasses() as $class) { |
|
24 | - try { |
|
24 | + foreach ($this->availableClasses() as $class) |
|
25 | + { |
|
26 | + try |
|
27 | + { |
|
25 | 28 | $reflection = $this->classReflection($class); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
29 | + } |
|
30 | + catch (LocatorException $e) |
|
31 | + { |
|
32 | + if ($this->debug) |
|
33 | + { |
|
28 | 34 | throw $e; |
29 | 35 | } |
30 | 36 | |
@@ -32,7 +38,8 @@ discard block |
||
32 | 38 | continue; |
33 | 39 | } |
34 | 40 | |
35 | - if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) { |
|
41 | + if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) |
|
42 | + { |
|
36 | 43 | continue; |
37 | 44 | } |
38 | 45 | |
@@ -51,7 +58,8 @@ discard block |
||
51 | 58 | { |
52 | 59 | $classes = []; |
53 | 60 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
61 | + foreach ($this->availableReflections() as $reflection) |
|
62 | + { |
|
55 | 63 | $classes = \array_merge($classes, $reflection->getClasses()); |
56 | 64 | } |
57 | 65 | |
@@ -63,11 +71,13 @@ discard block |
||
63 | 71 | */ |
64 | 72 | protected function isTargeted(\ReflectionClass $class, ?\ReflectionClass $target = null): bool |
65 | 73 | { |
66 | - if (empty($target)) { |
|
74 | + if (empty($target)) |
|
75 | + { |
|
67 | 76 | return true; |
68 | 77 | } |
69 | 78 | |
70 | - if (!$target->isTrait()) { |
|
79 | + if (!$target->isTrait()) |
|
80 | + { |
|
71 | 81 | //Target is interface or class |
72 | 82 | return $class->isSubclassOf($target) || $class->getName() === $target->getName(); |
73 | 83 | } |
@@ -9,8 +9,8 @@ |
||
9 | 9 | public function __construct(?\Throwable $previous = null, ?string $message = null) |
10 | 10 | { |
11 | 11 | parent::__construct( |
12 | - message: $message ?? 'Unable to set value. The given data was invalid.', |
|
13 | - previous: $previous, |
|
12 | + message : $message ?? 'Unable to set value. The given data was invalid.', |
|
13 | + previous : $previous, |
|
14 | 14 | ); |
15 | 15 | } |
16 | 16 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | protected function compile(string $source, array $visitors = [], ?LoaderInterface $loader = null) |
29 | 29 | { |
30 | - if ($loader === null) { |
|
30 | + if ($loader === null){ |
|
31 | 31 | $loader = new StringLoader(); |
32 | 32 | $loader->set('root', $source); |
33 | 33 | } |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | $builder->getCompiler()->addRenderer(new DynamicRenderer(new DirectiveGroup())); |
63 | 63 | $builder->getCompiler()->addRenderer(new HTMLRenderer()); |
64 | 64 | |
65 | - foreach ($this->getVisitors() as $visitor) { |
|
65 | + foreach ($this->getVisitors() as $visitor){ |
|
66 | 66 | $builder->addVisitor($visitor); |
67 | 67 | } |
68 | 68 | |
69 | - foreach ($visitors as $visitor) { |
|
69 | + foreach ($visitors as $visitor){ |
|
70 | 70 | $builder->addVisitor($visitor); |
71 | 71 | } |
72 | 72 | |
@@ -80,6 +80,6 @@ discard block |
||
80 | 80 | |
81 | 81 | protected function getFixtureLoader(): LoaderInterface |
82 | 82 | { |
83 | - return new DirectoryLoader(__DIR__ . '/../fixtures'); |
|
83 | + return new DirectoryLoader(__DIR__.'/../fixtures'); |
|
84 | 84 | } |
85 | 85 | } |
@@ -27,7 +27,8 @@ discard block |
||
27 | 27 | { |
28 | 28 | protected function compile(string $source, array $visitors = [], ?LoaderInterface $loader = null) |
29 | 29 | { |
30 | - if ($loader === null) { |
|
30 | + if ($loader === null) |
|
31 | + { |
|
31 | 32 | $loader = new StringLoader(); |
32 | 33 | $loader->set('root', $source); |
33 | 34 | } |
@@ -62,11 +63,13 @@ discard block |
||
62 | 63 | $builder->getCompiler()->addRenderer(new DynamicRenderer(new DirectiveGroup())); |
63 | 64 | $builder->getCompiler()->addRenderer(new HTMLRenderer()); |
64 | 65 | |
65 | - foreach ($this->getVisitors() as $visitor) { |
|
66 | + foreach ($this->getVisitors() as $visitor) |
|
67 | + { |
|
66 | 68 | $builder->addVisitor($visitor); |
67 | 69 | } |
68 | 70 | |
69 | - foreach ($visitors as $visitor) { |
|
71 | + foreach ($visitors as $visitor) |
|
72 | + { |
|
70 | 73 | $builder->addVisitor($visitor); |
71 | 74 | } |
72 | 75 |
@@ -24,22 +24,22 @@ discard block |
||
24 | 24 | |
25 | 25 | public function withinContext(?Context $ctx, callable $body): void |
26 | 26 | { |
27 | - if ($ctx === null || $ctx->getPath() === null) { |
|
27 | + if ($ctx === null || $ctx->getPath() === null){ |
|
28 | 28 | $body($this); |
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | - try { |
|
32 | + try{ |
|
33 | 33 | $this->parent = Location::fromContext($ctx, $this->parent); |
34 | 34 | $body($this); |
35 | - } finally { |
|
35 | + }finally{ |
|
36 | 36 | $this->parent = $this->parent->parent; |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | 40 | public function push(string $content, ?Context $ctx = null): void |
41 | 41 | { |
42 | - if ($ctx !== null && $ctx->getPath() !== null) { |
|
42 | + if ($ctx !== null && $ctx->getPath() !== null){ |
|
43 | 43 | $this->locations[\strlen($this->content)] = Location::fromContext($ctx, $this->parent); |
44 | 44 | } |
45 | 45 | |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | $paths = []; |
60 | 60 | |
61 | 61 | // We can scan top level only |
62 | - foreach ($this->locations as $loc) { |
|
63 | - if (!\in_array($loc->path, $paths, true)) { |
|
62 | + foreach ($this->locations as $loc){ |
|
63 | + if (!\in_array($loc->path, $paths, true)){ |
|
64 | 64 | $paths[] = $loc->path; |
65 | 65 | } |
66 | 66 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | { |
76 | 76 | $locations = []; |
77 | 77 | |
78 | - foreach ($this->locations as $offset => $location) { |
|
78 | + foreach ($this->locations as $offset => $location){ |
|
79 | 79 | $locations[$offset] = $location; |
80 | 80 | } |
81 | 81 |
@@ -24,22 +24,27 @@ discard block |
||
24 | 24 | |
25 | 25 | public function withinContext(?Context $ctx, callable $body): void |
26 | 26 | { |
27 | - if ($ctx === null || $ctx->getPath() === null) { |
|
27 | + if ($ctx === null || $ctx->getPath() === null) |
|
28 | + { |
|
28 | 29 | $body($this); |
29 | 30 | return; |
30 | 31 | } |
31 | 32 | |
32 | - try { |
|
33 | + try |
|
34 | + { |
|
33 | 35 | $this->parent = Location::fromContext($ctx, $this->parent); |
34 | 36 | $body($this); |
35 | - } finally { |
|
37 | + } |
|
38 | + finally |
|
39 | + { |
|
36 | 40 | $this->parent = $this->parent->parent; |
37 | 41 | } |
38 | 42 | } |
39 | 43 | |
40 | 44 | public function push(string $content, ?Context $ctx = null): void |
41 | 45 | { |
42 | - if ($ctx !== null && $ctx->getPath() !== null) { |
|
46 | + if ($ctx !== null && $ctx->getPath() !== null) |
|
47 | + { |
|
43 | 48 | $this->locations[\strlen($this->content)] = Location::fromContext($ctx, $this->parent); |
44 | 49 | } |
45 | 50 | |
@@ -59,8 +64,10 @@ discard block |
||
59 | 64 | $paths = []; |
60 | 65 | |
61 | 66 | // We can scan top level only |
62 | - foreach ($this->locations as $loc) { |
|
63 | - if (!\in_array($loc->path, $paths, true)) { |
|
67 | + foreach ($this->locations as $loc) |
|
68 | + { |
|
69 | + if (!\in_array($loc->path, $paths, true)) |
|
70 | + { |
|
64 | 71 | $paths[] = $loc->path; |
65 | 72 | } |
66 | 73 | } |
@@ -75,7 +82,8 @@ discard block |
||
75 | 82 | { |
76 | 83 | $locations = []; |
77 | 84 | |
78 | - foreach ($this->locations as $offset => $location) { |
|
85 | + foreach ($this->locations as $offset => $location) |
|
86 | + { |
|
79 | 87 | $locations[$offset] = $location; |
80 | 88 | } |
81 | 89 |