@@ -30,30 +30,30 @@ discard block |
||
30 | 30 | |
31 | 31 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
32 | 32 | { |
33 | - if (!$node instanceof Template && !$node instanceof Block && !$node instanceof Tag) { |
|
33 | + if (!$node instanceof Template && !$node instanceof Block && !$node instanceof Tag){ |
|
34 | 34 | return null; |
35 | 35 | } |
36 | 36 | |
37 | - if ($node instanceof Tag && \in_array($node->name, self::EXCLUDE)) { |
|
37 | + if ($node instanceof Tag && \in_array($node->name, self::EXCLUDE)){ |
|
38 | 38 | // raw nodes |
39 | 39 | return null; |
40 | 40 | } |
41 | 41 | |
42 | 42 | $level = $this->getLevel($ctx); |
43 | - if ($level === null) { |
|
43 | + if ($level === null){ |
|
44 | 44 | // not available in some contexts |
45 | 45 | return null; |
46 | 46 | } |
47 | 47 | |
48 | - foreach ($node->nodes as $i => $child) { |
|
49 | - if (!$child instanceof Raw) { |
|
48 | + foreach ($node->nodes as $i => $child){ |
|
49 | + if (!$child instanceof Raw){ |
|
50 | 50 | continue; |
51 | 51 | } |
52 | 52 | |
53 | 53 | $position = self::BETWEEN_TAGS; |
54 | - if (!isset($node->nodes[$i + 1])) { |
|
54 | + if (!isset($node->nodes[$i + 1])){ |
|
55 | 55 | $position = self::BEFORE_CLOSE; |
56 | - } elseif ($node->nodes[$i + 1] instanceof PHP) { |
|
56 | + } elseif ($node->nodes[$i + 1] instanceof PHP){ |
|
57 | 57 | $position = self::BEFORE_PHP; |
58 | 58 | } |
59 | 59 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | private function indentContent(string $content, int $level, int $position = self::BETWEEN_TAGS): string |
76 | 76 | { |
77 | - if (!\str_contains($content, "\n")) { |
|
77 | + if (!\str_contains($content, "\n")){ |
|
78 | 78 | // no need to do anything |
79 | 79 | return $content; |
80 | 80 | } |
@@ -82,40 +82,40 @@ discard block |
||
82 | 82 | // we have to apply special rules to the first and the last lines |
83 | 83 | $lines = \explode("\n", $content); |
84 | 84 | |
85 | - foreach ($lines as $i => $line) { |
|
86 | - if (\trim($line) === '' && $i !== 0) { |
|
85 | + foreach ($lines as $i => $line){ |
|
86 | + if (\trim($line) === '' && $i !== 0){ |
|
87 | 87 | unset($lines[$i]); |
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | 91 | $lines = \array_values($lines); |
92 | - if ($lines === []) { |
|
92 | + if ($lines === []){ |
|
93 | 93 | $lines[] = ''; |
94 | 94 | } |
95 | 95 | |
96 | 96 | $result = ''; |
97 | - foreach ($lines as $i => $line) { |
|
98 | - if (\trim($line) !== '') { |
|
97 | + foreach ($lines as $i => $line){ |
|
98 | + if (\trim($line) !== ''){ |
|
99 | 99 | $line = $i === 0 ? \rtrim($line) : \trim($line); |
100 | 100 | } |
101 | 101 | |
102 | - if ($i !== (\count($lines) - 1)) { |
|
103 | - $result .= $line . "\n" . \str_repeat(self::INDENT, $level); |
|
102 | + if ($i !== (\count($lines) - 1)){ |
|
103 | + $result .= $line."\n".\str_repeat(self::INDENT, $level); |
|
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | |
107 | 107 | // working with last line |
108 | - if ($position === self::BEFORE_PHP) { |
|
109 | - $result .= $line . "\n"; |
|
108 | + if ($position === self::BEFORE_PHP){ |
|
109 | + $result .= $line."\n"; |
|
110 | 110 | break; |
111 | 111 | } |
112 | 112 | |
113 | - if ($position === self::BEFORE_CLOSE) { |
|
114 | - $result .= $line . "\n" . \str_repeat(self::INDENT, max($level - 1, 0)); |
|
113 | + if ($position === self::BEFORE_CLOSE){ |
|
114 | + $result .= $line."\n".\str_repeat(self::INDENT, max($level - 1, 0)); |
|
115 | 115 | break; |
116 | 116 | } |
117 | 117 | |
118 | - $result .= $line . "\n" . \str_repeat(self::INDENT, $level); |
|
118 | + $result .= $line."\n".\str_repeat(self::INDENT, $level); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | return $result; |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | private function getLevel(VisitorContext $ctx): ?int |
125 | 125 | { |
126 | 126 | $level = 0; |
127 | - foreach ($ctx->getScope() as $node) { |
|
128 | - if ($node instanceof Attr) { |
|
127 | + foreach ($ctx->getScope() as $node){ |
|
128 | + if ($node instanceof Attr){ |
|
129 | 129 | return null; |
130 | 130 | } |
131 | 131 | |
132 | - if ($node instanceof Block || $node instanceof Template) { |
|
132 | + if ($node instanceof Block || $node instanceof Template){ |
|
133 | 133 | continue; |
134 | 134 | } |
135 | 135 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | private function normalizeEndings(string $string, bool $joinMultiple = true): string |
150 | 150 | { |
151 | - if (!$joinMultiple) { |
|
151 | + if (!$joinMultiple){ |
|
152 | 152 | return \str_replace("\r\n", "\n", $string); |
153 | 153 | } |
154 | 154 |
@@ -30,30 +30,38 @@ discard block |
||
30 | 30 | |
31 | 31 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
32 | 32 | { |
33 | - if (!$node instanceof Template && !$node instanceof Block && !$node instanceof Tag) { |
|
33 | + if (!$node instanceof Template && !$node instanceof Block && !$node instanceof Tag) |
|
34 | + { |
|
34 | 35 | return null; |
35 | 36 | } |
36 | 37 | |
37 | - if ($node instanceof Tag && \in_array($node->name, self::EXCLUDE)) { |
|
38 | + if ($node instanceof Tag && \in_array($node->name, self::EXCLUDE)) |
|
39 | + { |
|
38 | 40 | // raw nodes |
39 | 41 | return null; |
40 | 42 | } |
41 | 43 | |
42 | 44 | $level = $this->getLevel($ctx); |
43 | - if ($level === null) { |
|
45 | + if ($level === null) |
|
46 | + { |
|
44 | 47 | // not available in some contexts |
45 | 48 | return null; |
46 | 49 | } |
47 | 50 | |
48 | - foreach ($node->nodes as $i => $child) { |
|
49 | - if (!$child instanceof Raw) { |
|
51 | + foreach ($node->nodes as $i => $child) |
|
52 | + { |
|
53 | + if (!$child instanceof Raw) |
|
54 | + { |
|
50 | 55 | continue; |
51 | 56 | } |
52 | 57 | |
53 | 58 | $position = self::BETWEEN_TAGS; |
54 | - if (!isset($node->nodes[$i + 1])) { |
|
59 | + if (!isset($node->nodes[$i + 1])) |
|
60 | + { |
|
55 | 61 | $position = self::BEFORE_CLOSE; |
56 | - } elseif ($node->nodes[$i + 1] instanceof PHP) { |
|
62 | + } |
|
63 | + elseif ($node->nodes[$i + 1] instanceof PHP) |
|
64 | + { |
|
57 | 65 | $position = self::BEFORE_PHP; |
58 | 66 | } |
59 | 67 | |
@@ -74,7 +82,8 @@ discard block |
||
74 | 82 | |
75 | 83 | private function indentContent(string $content, int $level, int $position = self::BETWEEN_TAGS): string |
76 | 84 | { |
77 | - if (!\str_contains($content, "\n")) { |
|
85 | + if (!\str_contains($content, "\n")) |
|
86 | + { |
|
78 | 87 | // no need to do anything |
79 | 88 | return $content; |
80 | 89 | } |
@@ -82,35 +91,43 @@ discard block |
||
82 | 91 | // we have to apply special rules to the first and the last lines |
83 | 92 | $lines = \explode("\n", $content); |
84 | 93 | |
85 | - foreach ($lines as $i => $line) { |
|
86 | - if (\trim($line) === '' && $i !== 0) { |
|
94 | + foreach ($lines as $i => $line) |
|
95 | + { |
|
96 | + if (\trim($line) === '' && $i !== 0) |
|
97 | + { |
|
87 | 98 | unset($lines[$i]); |
88 | 99 | } |
89 | 100 | } |
90 | 101 | |
91 | 102 | $lines = \array_values($lines); |
92 | - if ($lines === []) { |
|
103 | + if ($lines === []) |
|
104 | + { |
|
93 | 105 | $lines[] = ''; |
94 | 106 | } |
95 | 107 | |
96 | 108 | $result = ''; |
97 | - foreach ($lines as $i => $line) { |
|
98 | - if (\trim($line) !== '') { |
|
109 | + foreach ($lines as $i => $line) |
|
110 | + { |
|
111 | + if (\trim($line) !== '') |
|
112 | + { |
|
99 | 113 | $line = $i === 0 ? \rtrim($line) : \trim($line); |
100 | 114 | } |
101 | 115 | |
102 | - if ($i !== (\count($lines) - 1)) { |
|
116 | + if ($i !== (\count($lines) - 1)) |
|
117 | + { |
|
103 | 118 | $result .= $line . "\n" . \str_repeat(self::INDENT, $level); |
104 | 119 | continue; |
105 | 120 | } |
106 | 121 | |
107 | 122 | // working with last line |
108 | - if ($position === self::BEFORE_PHP) { |
|
123 | + if ($position === self::BEFORE_PHP) |
|
124 | + { |
|
109 | 125 | $result .= $line . "\n"; |
110 | 126 | break; |
111 | 127 | } |
112 | 128 | |
113 | - if ($position === self::BEFORE_CLOSE) { |
|
129 | + if ($position === self::BEFORE_CLOSE) |
|
130 | + { |
|
114 | 131 | $result .= $line . "\n" . \str_repeat(self::INDENT, max($level - 1, 0)); |
115 | 132 | break; |
116 | 133 | } |
@@ -124,12 +141,15 @@ discard block |
||
124 | 141 | private function getLevel(VisitorContext $ctx): ?int |
125 | 142 | { |
126 | 143 | $level = 0; |
127 | - foreach ($ctx->getScope() as $node) { |
|
128 | - if ($node instanceof Attr) { |
|
144 | + foreach ($ctx->getScope() as $node) |
|
145 | + { |
|
146 | + if ($node instanceof Attr) |
|
147 | + { |
|
129 | 148 | return null; |
130 | 149 | } |
131 | 150 | |
132 | - if ($node instanceof Block || $node instanceof Template) { |
|
151 | + if ($node instanceof Block || $node instanceof Template) |
|
152 | + { |
|
133 | 153 | continue; |
134 | 154 | } |
135 | 155 | |
@@ -148,7 +168,8 @@ discard block |
||
148 | 168 | */ |
149 | 169 | private function normalizeEndings(string $string, bool $joinMultiple = true): string |
150 | 170 | { |
151 | - if (!$joinMultiple) { |
|
171 | + if (!$joinMultiple) |
|
172 | + { |
|
152 | 173 | return \str_replace("\r\n", "\n", $string); |
153 | 174 | } |
154 | 175 |
@@ -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]) |
@@ -40,7 +40,7 @@ |
||
40 | 40 | $finalizer->shouldReceive('addFinalizer')->once(); |
41 | 41 | |
42 | 42 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
43 | - new class() implements LoaderInterface { |
|
43 | + new class() implements LoaderInterface{ |
|
44 | 44 | public function has(string $section): bool |
45 | 45 | { |
46 | 46 | return false; |
@@ -40,7 +40,8 @@ |
||
40 | 40 | $finalizer->shouldReceive('addFinalizer')->once(); |
41 | 41 | |
42 | 42 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
43 | - new class() implements LoaderInterface { |
|
43 | + new class() implements LoaderInterface |
|
44 | + { |
|
44 | 45 | public function has(string $section): bool |
45 | 46 | { |
46 | 47 | return false; |
@@ -25,7 +25,7 @@ |
||
25 | 25 | public function testLoggerShouldBeReset() |
26 | 26 | { |
27 | 27 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
28 | - new class() implements LoaderInterface { |
|
28 | + new class() implements LoaderInterface{ |
|
29 | 29 | public function has(string $section): bool |
30 | 30 | { |
31 | 31 | return false; |
@@ -25,7 +25,8 @@ |
||
25 | 25 | public function testLoggerShouldBeReset() |
26 | 26 | { |
27 | 27 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
28 | - new class() implements LoaderInterface { |
|
28 | + new class() implements LoaderInterface |
|
29 | + { |
|
29 | 30 | public function has(string $section): bool |
30 | 31 | { |
31 | 32 | return false; |
@@ -54,7 +54,8 @@ discard block |
||
54 | 54 | $logger = $factory->getLogger(); |
55 | 55 | |
56 | 56 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
57 | - new class() implements LoaderInterface { |
|
57 | + new class() implements LoaderInterface |
|
58 | + { |
|
58 | 59 | public function has(string $section): bool |
59 | 60 | { |
60 | 61 | return false; |
@@ -80,7 +81,8 @@ discard block |
||
80 | 81 | public function testFinalizerShouldResetDefaultLogger() |
81 | 82 | { |
82 | 83 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
83 | - new class() implements LoaderInterface { |
|
84 | + new class() implements LoaderInterface |
|
85 | + { |
|
84 | 86 | public function has(string $section): bool |
85 | 87 | { |
86 | 88 | return false; |
@@ -120,7 +122,8 @@ discard block |
||
120 | 122 | public function testFinalizerShouldNotResetLoggerWhenApplicationTerminating() |
121 | 123 | { |
122 | 124 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
123 | - new class() implements LoaderInterface { |
|
125 | + new class() implements LoaderInterface |
|
126 | + { |
|
124 | 127 | public function has(string $section): bool |
125 | 128 | { |
126 | 129 | return false; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $logger = $factory->getLogger(); |
55 | 55 | |
56 | 56 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
57 | - new class() implements LoaderInterface { |
|
57 | + new class() implements LoaderInterface{ |
|
58 | 58 | public function has(string $section): bool |
59 | 59 | { |
60 | 60 | return false; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | public function testFinalizerShouldResetDefaultLogger() |
81 | 81 | { |
82 | 82 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
83 | - new class() implements LoaderInterface { |
|
83 | + new class() implements LoaderInterface{ |
|
84 | 84 | public function has(string $section): bool |
85 | 85 | { |
86 | 86 | return false; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | public function testFinalizerShouldNotResetLoggerWhenApplicationTerminating() |
121 | 121 | { |
122 | 122 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
123 | - new class() implements LoaderInterface { |
|
123 | + new class() implements LoaderInterface{ |
|
124 | 124 | public function has(string $section): bool |
125 | 125 | { |
126 | 126 | return false; |
@@ -40,7 +40,7 @@ |
||
40 | 40 | $finalizer->shouldReceive('addFinalizer')->once(); |
41 | 41 | |
42 | 42 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
43 | - new class() implements LoaderInterface { |
|
43 | + new class() implements LoaderInterface{ |
|
44 | 44 | public function has(string $section): bool |
45 | 45 | { |
46 | 46 | return false; |
@@ -40,7 +40,8 @@ |
||
40 | 40 | $finalizer->shouldReceive('addFinalizer')->once(); |
41 | 41 | |
42 | 42 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
43 | - new class() implements LoaderInterface { |
|
43 | + new class() implements LoaderInterface |
|
44 | + { |
|
44 | 45 | public function has(string $section): bool |
45 | 46 | { |
46 | 47 | return false; |
@@ -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 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | private readonly MonologConfig $config, |
28 | 28 | ListenerRegistryInterface $listenerRegistry, |
29 | 29 | private readonly FactoryInterface $factory |
30 | - ) { |
|
30 | + ){ |
|
31 | 31 | $this->eventHandler = new EventHandler($listenerRegistry, $config->getEventLevel()); |
32 | 32 | } |
33 | 33 | |
@@ -35,8 +35,8 @@ 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 | + if ($this->default !== null){ |
|
40 | 40 | // we should use only one default logger per system |
41 | 41 | return $this->default; |
42 | 42 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | public function reset(): void |
65 | 65 | { |
66 | - if ($this->default instanceof ResettableInterface) { |
|
66 | + if ($this->default instanceof ResettableInterface){ |
|
67 | 67 | $this->default->reset(); |
68 | 68 | } |
69 | 69 | } |
@@ -79,15 +79,15 @@ discard block |
||
79 | 79 | // always include default handler |
80 | 80 | $handlers = []; |
81 | 81 | |
82 | - foreach ($this->config->getHandlers($channel) as $handler) { |
|
83 | - if (!$handler instanceof Autowire) { |
|
82 | + foreach ($this->config->getHandlers($channel) as $handler){ |
|
83 | + if (!$handler instanceof Autowire){ |
|
84 | 84 | $handlers[] = $handler; |
85 | 85 | continue; |
86 | 86 | } |
87 | 87 | |
88 | - try { |
|
88 | + try{ |
|
89 | 89 | $handlers[] = $handler->resolve($this->factory); |
90 | - } catch (ContainerExceptionInterface $e) { |
|
90 | + }catch (ContainerExceptionInterface $e){ |
|
91 | 91 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
92 | 92 | } |
93 | 93 | } |
@@ -105,20 +105,20 @@ discard block |
||
105 | 105 | protected function getProcessors(string $channel): array |
106 | 106 | { |
107 | 107 | $processors = []; |
108 | - foreach ($this->config->getProcessors($channel) as $processor) { |
|
109 | - if (!$processor instanceof Autowire) { |
|
108 | + foreach ($this->config->getProcessors($channel) as $processor){ |
|
109 | + if (!$processor instanceof Autowire){ |
|
110 | 110 | $processors[] = $processor; |
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
114 | - try { |
|
114 | + try{ |
|
115 | 115 | $processors[] = $processor->resolve($this->factory); |
116 | - } catch (ContainerExceptionInterface $e) { |
|
116 | + }catch (ContainerExceptionInterface $e){ |
|
117 | 117 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | - if ($processors === []) { |
|
121 | + if ($processors === []){ |
|
122 | 122 | $processors[] = new PsrLogMessageProcessor(); |
123 | 123 | } |
124 | 124 |
@@ -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 |
@@ -29,7 +29,8 @@ |
||
29 | 29 | $record['context'] |
30 | 30 | ); |
31 | 31 | |
32 | - foreach ($this->listenerRegistry->getListeners() as $listener) { |
|
32 | + foreach ($this->listenerRegistry->getListeners() as $listener) |
|
33 | + { |
|
33 | 34 | $listener($e); |
34 | 35 | } |
35 | 36 |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | private readonly ListenerRegistryInterface $listenerRegistry, |
17 | 17 | int $level = Logger::DEBUG, |
18 | 18 | bool $bubble = true |
19 | - ) { |
|
19 | + ){ |
|
20 | 20 | parent::__construct($level, $bubble); |
21 | 21 | } |
22 | 22 | |
23 | - public function handle(array|LogRecord $record): bool |
|
23 | + public function handle(array | LogRecord $record): bool |
|
24 | 24 | { |
25 | 25 | $e = new LogEvent( |
26 | 26 | $record['datetime'], |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $record['context'] |
31 | 31 | ); |
32 | 32 | |
33 | - foreach ($this->listenerRegistry->getListeners() as $listener) { |
|
33 | + foreach ($this->listenerRegistry->getListeners() as $listener){ |
|
34 | 34 | $listener($e); |
35 | 35 | } |
36 | 36 |