@@ -8,7 +8,7 @@ |
||
8 | 8 | |
9 | 9 | final class NullBroadcast implements BroadcastInterface |
10 | 10 | { |
11 | - public function publish(iterable|string|\Stringable $topics, iterable|string $messages): void |
|
11 | + public function publish(iterable | string | \Stringable $topics, iterable | string $messages): void |
|
12 | 12 | { |
13 | 13 | // Do nothing |
14 | 14 | } |
@@ -26,5 +26,5 @@ |
||
26 | 26 | * @param MessagesList $messages |
27 | 27 | * @throws BroadcastException |
28 | 28 | */ |
29 | - public function publish(iterable|string|\Stringable $topics, iterable|string $messages): void; |
|
29 | + public function publish(iterable | string | \Stringable $topics, iterable | string $messages): void; |
|
30 | 30 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | public function get(array $values): array |
27 | 27 | { |
28 | 28 | $output = []; |
29 | - foreach ($values as $key => $value) { |
|
29 | + foreach ($values as $key => $value){ |
|
30 | 30 | $output[$key] = self::TYPE_DEFAULTS[\gettype($value)] ?? null; |
31 | 31 | } |
32 | 32 |
@@ -26,7 +26,8 @@ |
||
26 | 26 | public function get(array $values): array |
27 | 27 | { |
28 | 28 | $output = []; |
29 | - foreach ($values as $key => $value) { |
|
29 | + foreach ($values as $key => $value) |
|
30 | + { |
|
30 | 31 | $output[$key] = self::TYPE_DEFAULTS[\gettype($value)] ?? null; |
31 | 32 | } |
32 | 33 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public function getAnnotation(mixed $value): string |
28 | 28 | { |
29 | - if (\is_array($value)) { |
|
29 | + if (\is_array($value)){ |
|
30 | 30 | return $this->arrayAnnotationString($value); |
31 | 31 | } |
32 | 32 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | private function arrayAnnotationString(array $value): string |
42 | 42 | { |
43 | 43 | $types = []; |
44 | - foreach ($value as $item) { |
|
44 | + foreach ($value as $item){ |
|
45 | 45 | $types[] = \gettype($item); |
46 | 46 | } |
47 | 47 | $types = \array_unique($types); |
@@ -26,7 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | public function getAnnotation(mixed $value): string |
28 | 28 | { |
29 | - if (\is_array($value)) { |
|
29 | + if (\is_array($value)) |
|
30 | + { |
|
30 | 31 | return $this->arrayAnnotationString($value); |
31 | 32 | } |
32 | 33 | |
@@ -41,7 +42,8 @@ discard block |
||
41 | 42 | private function arrayAnnotationString(array $value): string |
42 | 43 | { |
43 | 44 | $types = []; |
44 | - foreach ($value as $item) { |
|
45 | + foreach ($value as $item) |
|
46 | + { |
|
45 | 47 | $types[] = \gettype($item); |
46 | 48 | } |
47 | 49 | $types = \array_unique($types); |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | { |
23 | 23 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
24 | 24 | { |
25 | - if (!$node instanceof Tag) { |
|
25 | + if (!$node instanceof Tag){ |
|
26 | 26 | return null; |
27 | 27 | } |
28 | 28 | |
29 | 29 | $flatten = []; |
30 | - foreach ($node->nodes as $child) { |
|
31 | - if ($child instanceof Block || $child instanceof Template || $child instanceof Aggregate) { |
|
32 | - foreach ($child->nodes as $childNode) { |
|
30 | + foreach ($node->nodes as $child){ |
|
31 | + if ($child instanceof Block || $child instanceof Template || $child instanceof Aggregate){ |
|
32 | + foreach ($child->nodes as $childNode){ |
|
33 | 33 | $flatten[] = $childNode; |
34 | 34 | } |
35 | 35 | continue; |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | private function mergeRaw(array $nodes): array |
52 | 52 | { |
53 | 53 | $result = []; |
54 | - foreach ($nodes as $node) { |
|
54 | + foreach ($nodes as $node){ |
|
55 | 55 | if ( |
56 | 56 | $node instanceof Raw |
57 | 57 | && isset($result[\count($result) - 1]) |
58 | 58 | && $result[\count($result) - 1] instanceof Raw |
59 | - ) { |
|
59 | + ){ |
|
60 | 60 | $result[\count($result) - 1]->content .= $node->content; |
61 | 61 | continue; |
62 | 62 | } |
@@ -22,14 +22,18 @@ discard block |
||
22 | 22 | { |
23 | 23 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
24 | 24 | { |
25 | - if (!$node instanceof Tag) { |
|
25 | + if (!$node instanceof Tag) |
|
26 | + { |
|
26 | 27 | return null; |
27 | 28 | } |
28 | 29 | |
29 | 30 | $flatten = []; |
30 | - foreach ($node->nodes as $child) { |
|
31 | - if ($child instanceof Block || $child instanceof Template || $child instanceof Aggregate) { |
|
32 | - foreach ($child->nodes as $childNode) { |
|
31 | + foreach ($node->nodes as $child) |
|
32 | + { |
|
33 | + if ($child instanceof Block || $child instanceof Template || $child instanceof Aggregate) |
|
34 | + { |
|
35 | + foreach ($child->nodes as $childNode) |
|
36 | + { |
|
33 | 37 | $flatten[] = $childNode; |
34 | 38 | } |
35 | 39 | continue; |
@@ -51,7 +55,8 @@ discard block |
||
51 | 55 | private function mergeRaw(array $nodes): array |
52 | 56 | { |
53 | 57 | $result = []; |
54 | - foreach ($nodes as $node) { |
|
58 | + foreach ($nodes as $node) |
|
59 | + { |
|
55 | 60 | if ( |
56 | 61 | $node instanceof Raw |
57 | 62 | && isset($result[\count($result) - 1]) |
@@ -35,18 +35,18 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function getHandlers(string $channel): \Generator |
37 | 37 | { |
38 | - if (empty($this->config['handlers'][$channel])) { |
|
38 | + if (empty($this->config['handlers'][$channel])){ |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
42 | - foreach ($this->config['handlers'][$channel] as $handler) { |
|
43 | - if (\is_object($handler) && !$handler instanceof Autowire) { |
|
42 | + foreach ($this->config['handlers'][$channel] as $handler){ |
|
43 | + if (\is_object($handler) && !$handler instanceof Autowire){ |
|
44 | 44 | yield $handler; |
45 | 45 | continue; |
46 | 46 | } |
47 | 47 | |
48 | 48 | $wire = $this->wire($handler); |
49 | - if (\is_null($wire)) { |
|
49 | + if (\is_null($wire)){ |
|
50 | 50 | throw new ConfigException(\sprintf('Invalid handler definition for channel `%s`.', $channel)); |
51 | 51 | } |
52 | 52 | |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | |
57 | 57 | public function getProcessors(string $channel): \Generator |
58 | 58 | { |
59 | - if (empty($this->config['processors'][$channel])) { |
|
59 | + if (empty($this->config['processors'][$channel])){ |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | - foreach ($this->config['processors'][$channel] as $processor) { |
|
64 | - if (\is_object($processor) && !$processor instanceof Autowire) { |
|
63 | + foreach ($this->config['processors'][$channel] as $processor){ |
|
64 | + if (\is_object($processor) && !$processor instanceof Autowire){ |
|
65 | 65 | yield $processor; |
66 | 66 | continue; |
67 | 67 | } |
68 | 68 | |
69 | 69 | $wire = $this->wire($processor); |
70 | - if (\is_null($wire)) { |
|
70 | + if (\is_null($wire)){ |
|
71 | 71 | throw new ConfigException(\sprintf('Invalid processor definition for channel `%s`.', $channel)); |
72 | 72 | } |
73 | 73 | |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | - private function wire(Autowire|string|array $definition): ?Autowire |
|
78 | + private function wire(Autowire | string | array $definition): ?Autowire |
|
79 | 79 | { |
80 | - if ($definition instanceof Autowire) { |
|
80 | + if ($definition instanceof Autowire){ |
|
81 | 81 | return $definition; |
82 | 82 | } |
83 | 83 | |
84 | - if (\is_string($definition)) { |
|
84 | + if (\is_string($definition)){ |
|
85 | 85 | return new Autowire($definition); |
86 | 86 | } |
87 | 87 | |
88 | - if (isset($definition['class'])) { |
|
88 | + if (isset($definition['class'])){ |
|
89 | 89 | return new Autowire($definition['class'], $definition['options'] ?? []); |
90 | 90 | } |
91 | 91 |
@@ -35,18 +35,22 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function getHandlers(string $channel): \Generator |
37 | 37 | { |
38 | - if (empty($this->config['handlers'][$channel])) { |
|
38 | + if (empty($this->config['handlers'][$channel])) |
|
39 | + { |
|
39 | 40 | return; |
40 | 41 | } |
41 | 42 | |
42 | - foreach ($this->config['handlers'][$channel] as $handler) { |
|
43 | - if (\is_object($handler) && !$handler instanceof Autowire) { |
|
43 | + foreach ($this->config['handlers'][$channel] as $handler) |
|
44 | + { |
|
45 | + if (\is_object($handler) && !$handler instanceof Autowire) |
|
46 | + { |
|
44 | 47 | yield $handler; |
45 | 48 | continue; |
46 | 49 | } |
47 | 50 | |
48 | 51 | $wire = $this->wire($handler); |
49 | - if (\is_null($wire)) { |
|
52 | + if (\is_null($wire)) |
|
53 | + { |
|
50 | 54 | throw new ConfigException(\sprintf('Invalid handler definition for channel `%s`.', $channel)); |
51 | 55 | } |
52 | 56 | |
@@ -56,18 +60,22 @@ discard block |
||
56 | 60 | |
57 | 61 | public function getProcessors(string $channel): \Generator |
58 | 62 | { |
59 | - if (empty($this->config['processors'][$channel])) { |
|
63 | + if (empty($this->config['processors'][$channel])) |
|
64 | + { |
|
60 | 65 | return; |
61 | 66 | } |
62 | 67 | |
63 | - foreach ($this->config['processors'][$channel] as $processor) { |
|
64 | - if (\is_object($processor) && !$processor instanceof Autowire) { |
|
68 | + foreach ($this->config['processors'][$channel] as $processor) |
|
69 | + { |
|
70 | + if (\is_object($processor) && !$processor instanceof Autowire) |
|
71 | + { |
|
65 | 72 | yield $processor; |
66 | 73 | continue; |
67 | 74 | } |
68 | 75 | |
69 | 76 | $wire = $this->wire($processor); |
70 | - if (\is_null($wire)) { |
|
77 | + if (\is_null($wire)) |
|
78 | + { |
|
71 | 79 | throw new ConfigException(\sprintf('Invalid processor definition for channel `%s`.', $channel)); |
72 | 80 | } |
73 | 81 | |
@@ -77,15 +85,18 @@ discard block |
||
77 | 85 | |
78 | 86 | private function wire(Autowire|string|array $definition): ?Autowire |
79 | 87 | { |
80 | - if ($definition instanceof Autowire) { |
|
88 | + if ($definition instanceof Autowire) |
|
89 | + { |
|
81 | 90 | return $definition; |
82 | 91 | } |
83 | 92 | |
84 | - if (\is_string($definition)) { |
|
93 | + if (\is_string($definition)) |
|
94 | + { |
|
85 | 95 | return new Autowire($definition); |
86 | 96 | } |
87 | 97 | |
88 | - if (isset($definition['class'])) { |
|
98 | + if (isset($definition['class'])) |
|
99 | + { |
|
89 | 100 | return new Autowire($definition['class'], $definition['options'] ?? []); |
90 | 101 | } |
91 | 102 |
@@ -35,8 +35,10 @@ discard block |
||
35 | 35 | { |
36 | 36 | $default = $this->config->getDefault(); |
37 | 37 | |
38 | - if ($channel === null || $channel === $default) { |
|
39 | - if ($this->default !== null) { |
|
38 | + if ($channel === null || $channel === $default) |
|
39 | + { |
|
40 | + if ($this->default !== null) |
|
41 | + { |
|
40 | 42 | // we should use only one default logger per system |
41 | 43 | return $this->default; |
42 | 44 | } |
@@ -63,7 +65,8 @@ discard block |
||
63 | 65 | |
64 | 66 | public function reset(): void |
65 | 67 | { |
66 | - if ($this->default instanceof ResettableInterface) { |
|
68 | + if ($this->default instanceof ResettableInterface) |
|
69 | + { |
|
67 | 70 | $this->default->reset(); |
68 | 71 | } |
69 | 72 | } |
@@ -79,15 +82,20 @@ discard block |
||
79 | 82 | // always include default handler |
80 | 83 | $handlers = []; |
81 | 84 | |
82 | - foreach ($this->config->getHandlers($channel) as $handler) { |
|
83 | - if (!$handler instanceof Autowire) { |
|
85 | + foreach ($this->config->getHandlers($channel) as $handler) |
|
86 | + { |
|
87 | + if (!$handler instanceof Autowire) |
|
88 | + { |
|
84 | 89 | $handlers[] = $handler; |
85 | 90 | continue; |
86 | 91 | } |
87 | 92 | |
88 | - try { |
|
93 | + try |
|
94 | + { |
|
89 | 95 | $handlers[] = $handler->resolve($this->factory); |
90 | - } catch (ContainerExceptionInterface $e) { |
|
96 | + } |
|
97 | + catch (ContainerExceptionInterface $e) |
|
98 | + { |
|
91 | 99 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
92 | 100 | } |
93 | 101 | } |
@@ -105,20 +113,26 @@ discard block |
||
105 | 113 | protected function getProcessors(string $channel): array |
106 | 114 | { |
107 | 115 | $processors = []; |
108 | - foreach ($this->config->getProcessors($channel) as $processor) { |
|
109 | - if (!$processor instanceof Autowire) { |
|
116 | + foreach ($this->config->getProcessors($channel) as $processor) |
|
117 | + { |
|
118 | + if (!$processor instanceof Autowire) |
|
119 | + { |
|
110 | 120 | $processors[] = $processor; |
111 | 121 | continue; |
112 | 122 | } |
113 | 123 | |
114 | - try { |
|
124 | + try |
|
125 | + { |
|
115 | 126 | $processors[] = $processor->resolve($this->factory); |
116 | - } catch (ContainerExceptionInterface $e) { |
|
127 | + } |
|
128 | + catch (ContainerExceptionInterface $e) |
|
129 | + { |
|
117 | 130 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
118 | 131 | } |
119 | 132 | } |
120 | 133 | |
121 | - if ($processors === []) { |
|
134 | + if ($processors === []) |
|
135 | + { |
|
122 | 136 | $processors[] = new PsrLogMessageProcessor(); |
123 | 137 | } |
124 | 138 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | private readonly MonologConfig $config, |
32 | 32 | ListenerRegistryInterface $listenerRegistry, |
33 | 33 | private readonly FactoryInterface $factory, |
34 | - ) { |
|
34 | + ){ |
|
35 | 35 | $this->eventHandler = new EventHandler($listenerRegistry, $config->getEventLevel()); |
36 | 36 | } |
37 | 37 | |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | { |
40 | 40 | $default = $this->config->getDefault(); |
41 | 41 | |
42 | - if ($channel === null || $channel === $default) { |
|
43 | - if ($this->default !== null) { |
|
42 | + if ($channel === null || $channel === $default){ |
|
43 | + if ($this->default !== null){ |
|
44 | 44 | // we should use only one default logger per system |
45 | 45 | return $this->default; |
46 | 46 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | public function reset(): void |
71 | 71 | { |
72 | - if ($this->default instanceof ResettableInterface) { |
|
72 | + if ($this->default instanceof ResettableInterface){ |
|
73 | 73 | $this->default->reset(); |
74 | 74 | } |
75 | 75 | } |
@@ -84,15 +84,15 @@ discard block |
||
84 | 84 | // always include default handler |
85 | 85 | $handlers = []; |
86 | 86 | |
87 | - foreach ($this->config->getHandlers($channel) as $handler) { |
|
88 | - if (!$handler instanceof Autowire) { |
|
87 | + foreach ($this->config->getHandlers($channel) as $handler){ |
|
88 | + if (!$handler instanceof Autowire){ |
|
89 | 89 | $handlers[] = $handler; |
90 | 90 | continue; |
91 | 91 | } |
92 | 92 | |
93 | - try { |
|
93 | + try{ |
|
94 | 94 | $handlers[] = $handler->resolve($this->factory); |
95 | - } catch (ContainerExceptionInterface $e) { |
|
95 | + }catch (ContainerExceptionInterface $e){ |
|
96 | 96 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
97 | 97 | } |
98 | 98 | } |
@@ -110,20 +110,20 @@ discard block |
||
110 | 110 | protected function getProcessors(string $channel): array |
111 | 111 | { |
112 | 112 | $processors = []; |
113 | - foreach ($this->config->getProcessors($channel) as $processor) { |
|
114 | - if (!$processor instanceof Autowire) { |
|
113 | + foreach ($this->config->getProcessors($channel) as $processor){ |
|
114 | + if (!$processor instanceof Autowire){ |
|
115 | 115 | $processors[] = $processor; |
116 | 116 | continue; |
117 | 117 | } |
118 | 118 | |
119 | - try { |
|
119 | + try{ |
|
120 | 120 | $processors[] = $processor->resolve($this->factory); |
121 | - } catch (ContainerExceptionInterface $e) { |
|
121 | + }catch (ContainerExceptionInterface $e){ |
|
122 | 122 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - if ($processors === []) { |
|
126 | + if ($processors === []){ |
|
127 | 127 | $processors[] = new PsrLogMessageProcessor(); |
128 | 128 | } |
129 | 129 |
@@ -79,7 +79,8 @@ |
||
79 | 79 | */ |
80 | 80 | private function wire(Autowire|string $item): Autowire |
81 | 81 | { |
82 | - if ($item instanceof Autowire) { |
|
82 | + if ($item instanceof Autowire) |
|
83 | + { |
|
83 | 84 | return $item; |
84 | 85 | } |
85 | 86 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | public function getGlobalVariables(): array |
29 | 29 | { |
30 | - return (array) ($this->config['globalVariables'] ?? []); |
|
30 | + return (array)($this->config['globalVariables'] ?? []); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function isCacheEnabled(): bool |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function getCacheDirectory(): string |
39 | 39 | { |
40 | - return \rtrim($this->config['cache']['directory'] ?? '', '/') . '/'; |
|
40 | + return \rtrim($this->config['cache']['directory'] ?? '', '/').'/'; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function getNamespaces(): array |
47 | 47 | { |
48 | - return (array) ($this->config['namespaces'] ?? []); |
|
48 | + return (array)($this->config['namespaces'] ?? []); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | return \array_map( |
59 | 59 | fn(mixed $dependency): Autowire => $this->wire($dependency), |
60 | - (array) ($this->config['dependencies'] ?? []), |
|
60 | + (array)($this->config['dependencies'] ?? []), |
|
61 | 61 | ); |
62 | 62 | } |
63 | 63 | |
@@ -70,16 +70,16 @@ discard block |
||
70 | 70 | { |
71 | 71 | return \array_map( |
72 | 72 | fn(mixed $engine): Autowire => $this->wire($engine), |
73 | - (array) ($this->config['engines'] ?? []), |
|
73 | + (array)($this->config['engines'] ?? []), |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @param Autowire|class-string $item |
79 | 79 | */ |
80 | - private function wire(Autowire|string $item): Autowire |
|
80 | + private function wire(Autowire | string $item): Autowire |
|
81 | 81 | { |
82 | - if ($item instanceof Autowire) { |
|
82 | + if ($item instanceof Autowire){ |
|
83 | 83 | return $item; |
84 | 84 | } |
85 | 85 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | public function getID(): string |
21 | 21 | { |
22 | 22 | $calculated = ''; |
23 | - foreach ($this->dependencies as $dependency) { |
|
23 | + foreach ($this->dependencies as $dependency){ |
|
24 | 24 | $calculated .= \sprintf('[%s=%s]', $dependency->getName(), $dependency->getValue()); |
25 | 25 | } |
26 | 26 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | public function resolveValue(string $dependency): mixed |
49 | 49 | { |
50 | - if (!isset($this->dependencies[$dependency])) { |
|
50 | + if (!isset($this->dependencies[$dependency])){ |
|
51 | 51 | throw new ContextException(\sprintf('Undefined context dependency \'%s\'.', $dependency)); |
52 | 52 | } |
53 | 53 |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | public function getID(): string |
21 | 21 | { |
22 | 22 | $calculated = ''; |
23 | - foreach ($this->dependencies as $dependency) { |
|
23 | + foreach ($this->dependencies as $dependency) |
|
24 | + { |
|
24 | 25 | $calculated .= \sprintf('[%s=%s]', $dependency->getName(), $dependency->getValue()); |
25 | 26 | } |
26 | 27 | |
@@ -47,7 +48,8 @@ discard block |
||
47 | 48 | |
48 | 49 | public function resolveValue(string $dependency): mixed |
49 | 50 | { |
50 | - if (!isset($this->dependencies[$dependency])) { |
|
51 | + if (!isset($this->dependencies[$dependency])) |
|
52 | + { |
|
51 | 53 | throw new ContextException(\sprintf('Undefined context dependency \'%s\'.', $dependency)); |
52 | 54 | } |
53 | 55 |