@@ -48,23 +48,23 @@ |
||
48 | 48 | |
49 | 49 | private function configureExtensions(ConsoleBootloader $console, ContainerInterface $container): void |
50 | 50 | { |
51 | - if ($container->has(TranslatorInterface::class)) { |
|
51 | + if ($container->has(TranslatorInterface::class)){ |
|
52 | 52 | $this->configureTranslator($console); |
53 | 53 | } |
54 | 54 | |
55 | - if ($container->has(ViewsInterface::class)) { |
|
55 | + if ($container->has(ViewsInterface::class)){ |
|
56 | 56 | $this->configureViews($console); |
57 | 57 | } |
58 | 58 | |
59 | - if ($container->has(EncryptionInterface::class)) { |
|
59 | + if ($container->has(EncryptionInterface::class)){ |
|
60 | 60 | $this->configureEncrypter($console); |
61 | 61 | } |
62 | 62 | |
63 | - if ($container->has(RouterInterface::class)) { |
|
63 | + if ($container->has(RouterInterface::class)){ |
|
64 | 64 | $console->addCommand(Router\ListCommand::class); |
65 | 65 | } |
66 | 66 | |
67 | - if ($container->has(ClassesInterface::class)) { |
|
67 | + if ($container->has(ClassesInterface::class)){ |
|
68 | 68 | $console->addCommand(Tokenizer\InfoCommand::class); |
69 | 69 | $console->addCommand(Tokenizer\ValidateCommand::class); |
70 | 70 | } |
@@ -48,23 +48,28 @@ |
||
48 | 48 | |
49 | 49 | private function configureExtensions(ConsoleBootloader $console, ContainerInterface $container): void |
50 | 50 | { |
51 | - if ($container->has(TranslatorInterface::class)) { |
|
51 | + if ($container->has(TranslatorInterface::class)) |
|
52 | + { |
|
52 | 53 | $this->configureTranslator($console); |
53 | 54 | } |
54 | 55 | |
55 | - if ($container->has(ViewsInterface::class)) { |
|
56 | + if ($container->has(ViewsInterface::class)) |
|
57 | + { |
|
56 | 58 | $this->configureViews($console); |
57 | 59 | } |
58 | 60 | |
59 | - if ($container->has(EncryptionInterface::class)) { |
|
61 | + if ($container->has(EncryptionInterface::class)) |
|
62 | + { |
|
60 | 63 | $this->configureEncrypter($console); |
61 | 64 | } |
62 | 65 | |
63 | - if ($container->has(RouterInterface::class)) { |
|
66 | + if ($container->has(RouterInterface::class)) |
|
67 | + { |
|
64 | 68 | $console->addCommand(Router\ListCommand::class); |
65 | 69 | } |
66 | 70 | |
67 | - if ($container->has(ClassesInterface::class)) { |
|
71 | + if ($container->has(ClassesInterface::class)) |
|
72 | + { |
|
68 | 73 | $console->addCommand(Tokenizer\InfoCommand::class); |
69 | 74 | $console->addCommand(Tokenizer\ValidateCommand::class); |
70 | 75 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | */ |
13 | 13 | class ExtendedContextInjector implements InjectorInterface |
14 | 14 | { |
15 | - public function createInjection(\ReflectionClass $class, \ReflectionParameter|string|null $context = null): object |
|
15 | + public function createInjection(\ReflectionClass $class, \ReflectionParameter | string | null $context = null): object |
|
16 | 16 | { |
17 | 17 | return (object)['context' => $context]; |
18 | 18 | } |
@@ -17,9 +17,9 @@ |
||
17 | 17 | public function __construct( |
18 | 18 | public readonly string $alias, |
19 | 19 | public string $class, |
20 | - public \Stringable|string|null $context = null, |
|
20 | + public \Stringable | string | null $context = null, |
|
21 | 21 | public ?bool $singleton = null, |
22 | 22 | public ?\ReflectionClass $reflection = null, |
23 | - ) { |
|
23 | + ){ |
|
24 | 24 | } |
25 | 25 | } |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | ): int { |
22 | 22 | $this->info('Included directories:'); |
23 | 23 | $grid = $this->table(['Directory', 'Scope']); |
24 | - foreach ($config->getDirectories() as $directory) { |
|
24 | + foreach ($config->getDirectories() as $directory){ |
|
25 | 25 | $grid->addRow([\str_replace($dirs->get('root'), '', $directory), '']); |
26 | 26 | } |
27 | - foreach ($config->getScopes() as $scope => $data) { |
|
28 | - foreach ($data['directories'] ?? [] as $directory) { |
|
27 | + foreach ($config->getScopes() as $scope => $data){ |
|
28 | + foreach ($data['directories'] ?? [] as $directory){ |
|
29 | 29 | $grid->addRow([\str_replace($dirs->get('root'), '', $directory), $scope]); |
30 | 30 | } |
31 | 31 | } |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | |
37 | 37 | $this->info('Excluded directories:'); |
38 | 38 | $grid = $this->table(['Directory', 'Scope']); |
39 | - foreach ($config->getExcludes() as $directory) { |
|
39 | + foreach ($config->getExcludes() as $directory){ |
|
40 | 40 | $grid->addRow([\str_replace($dirs->get('root'), '', $directory), '']); |
41 | 41 | } |
42 | - foreach ($config->getScopes() as $scope => $data) { |
|
43 | - foreach ($data['exclude'] ?? [] as $directory) { |
|
42 | + foreach ($config->getScopes() as $scope => $data){ |
|
43 | + foreach ($data['exclude'] ?? [] as $directory){ |
|
44 | 44 | $grid->addRow([\str_replace($dirs->get('root'), '', $directory), $scope]); |
45 | 45 | } |
46 | 46 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | $this->info('Listeners:'); |
76 | 76 | $grid = $this->table(['Registered Listener', 'File']); |
77 | - foreach ($listeners as $listener) { |
|
77 | + foreach ($listeners as $listener){ |
|
78 | 78 | $grid->addRow([ |
79 | 79 | $listener, |
80 | 80 | \str_replace($dirs->get('root'), '', (new \ReflectionClass($listener))->getFileName()), |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $this->info( |
90 | 90 | \sprintf('Tokenizer cache: %s', $config->isCacheEnabled() ? '<info>enabled</>' : '<error>disabled</>'), |
91 | 91 | ); |
92 | - if (!$config->isCacheEnabled()) { |
|
92 | + if (!$config->isCacheEnabled()){ |
|
93 | 93 | $this->comment('To enable cache, add "TOKENIZER_CACHE_TARGETS=true" to your .env file.'); |
94 | 94 | $this->comment('Read more at https://spiral.dev/docs/advanced-tokenizer/#class-listeners'); |
95 | 95 | } |
@@ -21,11 +21,14 @@ discard block |
||
21 | 21 | ): int { |
22 | 22 | $this->info('Included directories:'); |
23 | 23 | $grid = $this->table(['Directory', 'Scope']); |
24 | - foreach ($config->getDirectories() as $directory) { |
|
24 | + foreach ($config->getDirectories() as $directory) |
|
25 | + { |
|
25 | 26 | $grid->addRow([\str_replace($dirs->get('root'), '', $directory), '']); |
26 | 27 | } |
27 | - foreach ($config->getScopes() as $scope => $data) { |
|
28 | - foreach ($data['directories'] ?? [] as $directory) { |
|
28 | + foreach ($config->getScopes() as $scope => $data) |
|
29 | + { |
|
30 | + foreach ($data['directories'] ?? [] as $directory) |
|
31 | + { |
|
29 | 32 | $grid->addRow([\str_replace($dirs->get('root'), '', $directory), $scope]); |
30 | 33 | } |
31 | 34 | } |
@@ -36,11 +39,14 @@ discard block |
||
36 | 39 | |
37 | 40 | $this->info('Excluded directories:'); |
38 | 41 | $grid = $this->table(['Directory', 'Scope']); |
39 | - foreach ($config->getExcludes() as $directory) { |
|
42 | + foreach ($config->getExcludes() as $directory) |
|
43 | + { |
|
40 | 44 | $grid->addRow([\str_replace($dirs->get('root'), '', $directory), '']); |
41 | 45 | } |
42 | - foreach ($config->getScopes() as $scope => $data) { |
|
43 | - foreach ($data['exclude'] ?? [] as $directory) { |
|
46 | + foreach ($config->getScopes() as $scope => $data) |
|
47 | + { |
|
48 | + foreach ($data['exclude'] ?? [] as $directory) |
|
49 | + { |
|
44 | 50 | $grid->addRow([\str_replace($dirs->get('root'), '', $directory), $scope]); |
45 | 51 | } |
46 | 52 | } |
@@ -74,7 +80,8 @@ discard block |
||
74 | 80 | |
75 | 81 | $this->info('Listeners:'); |
76 | 82 | $grid = $this->table(['Registered Listener', 'File']); |
77 | - foreach ($listeners as $listener) { |
|
83 | + foreach ($listeners as $listener) |
|
84 | + { |
|
78 | 85 | $grid->addRow([ |
79 | 86 | $listener, |
80 | 87 | \str_replace($dirs->get('root'), '', (new \ReflectionClass($listener))->getFileName()), |
@@ -89,7 +96,8 @@ discard block |
||
89 | 96 | $this->info( |
90 | 97 | \sprintf('Tokenizer cache: %s', $config->isCacheEnabled() ? '<info>enabled</>' : '<error>disabled</>'), |
91 | 98 | ); |
92 | - if (!$config->isCacheEnabled()) { |
|
99 | + if (!$config->isCacheEnabled()) |
|
100 | + { |
|
93 | 101 | $this->comment('To enable cache, add "TOKENIZER_CACHE_TARGETS=true" to your .env file.'); |
94 | 102 | $this->comment('Read more at https://spiral.dev/docs/advanced-tokenizer/#class-listeners'); |
95 | 103 | } |
@@ -23,7 +23,8 @@ |
||
23 | 23 | $listeners = \method_exists($registry, 'getListenerClasses') ? $registry->getListenerClasses() : []; |
24 | 24 | |
25 | 25 | $grid = $this->table(['Listener', 'Suggestion']); |
26 | - foreach ($listeners as $class) { |
|
26 | + foreach ($listeners as $class) |
|
27 | + { |
|
27 | 28 | $ref = new \ReflectionClass($class); |
28 | 29 | $attribute = $reader->firstClassMetadata($ref, AbstractTarget::class); |
29 | 30 | $suggestion = match (true) { |
@@ -23,16 +23,16 @@ |
||
23 | 23 | $listeners = \method_exists($registry, 'getListenerClasses') ? $registry->getListenerClasses() : []; |
24 | 24 | |
25 | 25 | $grid = $this->table(['Listener', 'Suggestion']); |
26 | - foreach ($listeners as $class) { |
|
26 | + foreach ($listeners as $class){ |
|
27 | 27 | $ref = new \ReflectionClass($class); |
28 | 28 | $attribute = $reader->firstClassMetadata($ref, AbstractTarget::class); |
29 | 29 | $suggestion = match (true) { |
30 | - $attribute === null => 'Add <comment>#[TargetClass]</comment> or ' . |
|
30 | + $attribute === null => 'Add <comment>#[TargetClass]</comment> or '. |
|
31 | 31 | '<comment>#[TargetAttribute]</comment> attribute to the listener', |
32 | 32 | default => '<fg=green> ✓ </>', |
33 | 33 | }; |
34 | 34 | $grid->addRow([ |
35 | - $class . "\n" . \sprintf('<fg=gray>%s</>', \str_replace($dirs->get('root'), '', $ref->getFileName())), |
|
35 | + $class."\n".\sprintf('<fg=gray>%s</>', \str_replace($dirs->get('root'), '', $ref->getFileName())), |
|
36 | 36 | $suggestion, |
37 | 37 | ]); |
38 | 38 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | ClassesLoaderInterface $loader, |
131 | 131 | ListenerInvoker $invoker, |
132 | 132 | ): void { |
133 | - if ($config->isLoadClassesEnabled()) { |
|
133 | + if ($config->isLoadClassesEnabled()){ |
|
134 | 134 | $this->loadReflections($invoker, $classes->getClasses(...), $loader->loadClasses(...)); |
135 | 135 | } |
136 | 136 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | EnumsLoaderInterface $loader, |
142 | 142 | ListenerInvoker $invoker, |
143 | 143 | ): void { |
144 | - if ($config->isLoadEnumsEnabled()) { |
|
144 | + if ($config->isLoadEnumsEnabled()){ |
|
145 | 145 | $this->loadReflections($invoker, $enums->getEnums(...), $loader->loadEnums(...)); |
146 | 146 | } |
147 | 147 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | InterfacesLoaderInterface $loader, |
153 | 153 | ListenerInvoker $invoker, |
154 | 154 | ): void { |
155 | - if ($config->isLoadInterfacesEnabled()) { |
|
155 | + if ($config->isLoadInterfacesEnabled()){ |
|
156 | 156 | $this->loadReflections($invoker, $interfaces->getInterfaces(...), $loader->loadInterfaces(...)); |
157 | 157 | } |
158 | 158 | } |
@@ -170,15 +170,15 @@ discard block |
||
170 | 170 | |
171 | 171 | // First, we check if the listener has been cached. If it has, we will load the classes/enums/interfaces |
172 | 172 | // from the cache. |
173 | - foreach ($listeners as $i => $listener) { |
|
174 | - if ($loader($listener)) { |
|
173 | + foreach ($listeners as $i => $listener){ |
|
174 | + if ($loader($listener)){ |
|
175 | 175 | unset($listeners[$i]); |
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | 179 | // If there are no listeners left, we don't need to use static analysis at all and save |
180 | 180 | // valuable time. |
181 | - if ($listeners === []) { |
|
181 | + if ($listeners === []){ |
|
182 | 182 | return; |
183 | 183 | } |
184 | 184 | |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | // Please note that this is a very expensive operation and should be avoided if possible. |
187 | 187 | // Use #[TargetClass] or #[TargetAttribute] attributes in your listeners to cache the classes/enums/interfaces. |
188 | 188 | $classes = $reflections(); |
189 | - foreach ($listeners as $listener) { |
|
189 | + foreach ($listeners as $listener){ |
|
190 | 190 | $invoker->invoke($listener, $classes); |
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | 194 | private function finalizeListeners(): void |
195 | 195 | { |
196 | - foreach ($this->listeners as $listener) { |
|
196 | + foreach ($this->listeners as $listener){ |
|
197 | 197 | $listener->finalize(); |
198 | 198 | } |
199 | 199 | // We don't need the listeners anymore, so we will clear them from memory. |
@@ -130,7 +130,8 @@ discard block |
||
130 | 130 | ClassesLoaderInterface $loader, |
131 | 131 | ListenerInvoker $invoker, |
132 | 132 | ): void { |
133 | - if ($config->isLoadClassesEnabled()) { |
|
133 | + if ($config->isLoadClassesEnabled()) |
|
134 | + { |
|
134 | 135 | $this->loadReflections($invoker, $classes->getClasses(...), $loader->loadClasses(...)); |
135 | 136 | } |
136 | 137 | } |
@@ -141,7 +142,8 @@ discard block |
||
141 | 142 | EnumsLoaderInterface $loader, |
142 | 143 | ListenerInvoker $invoker, |
143 | 144 | ): void { |
144 | - if ($config->isLoadEnumsEnabled()) { |
|
145 | + if ($config->isLoadEnumsEnabled()) |
|
146 | + { |
|
145 | 147 | $this->loadReflections($invoker, $enums->getEnums(...), $loader->loadEnums(...)); |
146 | 148 | } |
147 | 149 | } |
@@ -152,7 +154,8 @@ discard block |
||
152 | 154 | InterfacesLoaderInterface $loader, |
153 | 155 | ListenerInvoker $invoker, |
154 | 156 | ): void { |
155 | - if ($config->isLoadInterfacesEnabled()) { |
|
157 | + if ($config->isLoadInterfacesEnabled()) |
|
158 | + { |
|
156 | 159 | $this->loadReflections($invoker, $interfaces->getInterfaces(...), $loader->loadInterfaces(...)); |
157 | 160 | } |
158 | 161 | } |
@@ -170,15 +173,18 @@ discard block |
||
170 | 173 | |
171 | 174 | // First, we check if the listener has been cached. If it has, we will load the classes/enums/interfaces |
172 | 175 | // from the cache. |
173 | - foreach ($listeners as $i => $listener) { |
|
174 | - if ($loader($listener)) { |
|
176 | + foreach ($listeners as $i => $listener) |
|
177 | + { |
|
178 | + if ($loader($listener)) |
|
179 | + { |
|
175 | 180 | unset($listeners[$i]); |
176 | 181 | } |
177 | 182 | } |
178 | 183 | |
179 | 184 | // If there are no listeners left, we don't need to use static analysis at all and save |
180 | 185 | // valuable time. |
181 | - if ($listeners === []) { |
|
186 | + if ($listeners === []) |
|
187 | + { |
|
182 | 188 | return; |
183 | 189 | } |
184 | 190 | |
@@ -186,14 +192,16 @@ discard block |
||
186 | 192 | // Please note that this is a very expensive operation and should be avoided if possible. |
187 | 193 | // Use #[TargetClass] or #[TargetAttribute] attributes in your listeners to cache the classes/enums/interfaces. |
188 | 194 | $classes = $reflections(); |
189 | - foreach ($listeners as $listener) { |
|
195 | + foreach ($listeners as $listener) |
|
196 | + { |
|
190 | 197 | $invoker->invoke($listener, $classes); |
191 | 198 | } |
192 | 199 | } |
193 | 200 | |
194 | 201 | private function finalizeListeners(): void |
195 | 202 | { |
196 | - foreach ($this->listeners as $listener) { |
|
203 | + foreach ($this->listeners as $listener) |
|
204 | + { |
|
197 | 205 | $listener->finalize(); |
198 | 206 | } |
199 | 207 | // We don't need the listeners anymore, so we will clear them from memory. |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | |
48 | 48 | public function getRenderer(?string $format = null): ?ExceptionRendererInterface |
49 | 49 | { |
50 | - if ($format !== null) { |
|
51 | - foreach ($this->renderers as $renderer) { |
|
52 | - if ($renderer->canRender($format)) { |
|
50 | + if ($format !== null){ |
|
51 | + foreach ($this->renderers as $renderer){ |
|
52 | + if ($renderer->canRender($format)){ |
|
53 | 53 | return $renderer; |
54 | 54 | } |
55 | 55 | } |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | |
73 | 73 | public function report(\Throwable $exception): void |
74 | 74 | { |
75 | - if ($this->shouldNotReport($exception)) { |
|
75 | + if ($this->shouldNotReport($exception)){ |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | - foreach ($this->reporters as $reporter) { |
|
80 | - try { |
|
81 | - if ($reporter instanceof ExceptionReporterInterface) { |
|
79 | + foreach ($this->reporters as $reporter){ |
|
80 | + try{ |
|
81 | + if ($reporter instanceof ExceptionReporterInterface){ |
|
82 | 82 | $reporter->report($exception); |
83 | - } else { |
|
83 | + }else{ |
|
84 | 84 | $reporter($exception); |
85 | 85 | } |
86 | - } catch (\Throwable) { |
|
86 | + }catch (\Throwable){ |
|
87 | 87 | // Do nothing |
88 | 88 | } |
89 | 89 | } |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | |
92 | 92 | public function handleGlobalException(\Throwable $e): void |
93 | 93 | { |
94 | - if (\in_array(PHP_SAPI, ['cli', 'cli-server'], true)) { |
|
94 | + if (\in_array(PHP_SAPI, ['cli', 'cli-server'], true)){ |
|
95 | 95 | $this->output ??= \defined('STDERR') ? \STDERR : \fopen('php://stderr', 'wb+'); |
96 | 96 | $format = 'cli'; |
97 | - } else { |
|
97 | + }else{ |
|
98 | 98 | $this->output ??= \defined('STDOUT') ? \STDOUT : \fopen('php://stdout', 'wb+'); |
99 | 99 | $format = 'html'; |
100 | 100 | } |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | $this->report($e); |
104 | 104 | |
105 | 105 | // There is possible an exception on the application termination |
106 | - try { |
|
106 | + try{ |
|
107 | 107 | \fwrite($this->output, $this->render($e, verbosity: $this->verbosity, format: $format)); |
108 | - } catch (\Throwable) { |
|
108 | + }catch (\Throwable){ |
|
109 | 109 | $this->output = null; |
110 | 110 | } |
111 | 111 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | /** |
130 | 130 | * @param ExceptionReporterInterface|Closure(\Throwable):void $reporter |
131 | 131 | */ |
132 | - public function addReporter(ExceptionReporterInterface|Closure $reporter): void |
|
132 | + public function addReporter(ExceptionReporterInterface | Closure $reporter): void |
|
133 | 133 | { |
134 | 134 | $this->reporters[] = $reporter; |
135 | 135 | } |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | */ |
148 | 148 | protected function handleShutdown(): void |
149 | 149 | { |
150 | - if (empty($error = \error_get_last())) { |
|
150 | + if (empty($error = \error_get_last())){ |
|
151 | 151 | return; |
152 | 152 | } |
153 | 153 | |
154 | - try { |
|
154 | + try{ |
|
155 | 155 | $this->handleError($error['type'], $error['message'], $error['file'], $error['line']); |
156 | - } catch (\Throwable $e) { |
|
156 | + }catch (\Throwable $e){ |
|
157 | 157 | $this->handleGlobalException($e); |
158 | 158 | } |
159 | 159 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | string $errfile = '', |
170 | 170 | int $errline = 0, |
171 | 171 | ): bool { |
172 | - if (!(\error_reporting() & $errno)) { |
|
172 | + if (!(\error_reporting() & $errno)){ |
|
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | |
184 | 184 | protected function shouldNotReport(\Throwable $exception): bool |
185 | 185 | { |
186 | - foreach ($this->nonReportableExceptions as $nonReportableException) { |
|
187 | - if ($exception instanceof $nonReportableException) { |
|
186 | + foreach ($this->nonReportableExceptions as $nonReportableException){ |
|
187 | + if ($exception instanceof $nonReportableException){ |
|
188 | 188 | return true; |
189 | 189 | } |
190 | 190 | } |
@@ -47,9 +47,12 @@ discard block |
||
47 | 47 | |
48 | 48 | public function getRenderer(?string $format = null): ?ExceptionRendererInterface |
49 | 49 | { |
50 | - if ($format !== null) { |
|
51 | - foreach ($this->renderers as $renderer) { |
|
52 | - if ($renderer->canRender($format)) { |
|
50 | + if ($format !== null) |
|
51 | + { |
|
52 | + foreach ($this->renderers as $renderer) |
|
53 | + { |
|
54 | + if ($renderer->canRender($format)) |
|
55 | + { |
|
53 | 56 | return $renderer; |
54 | 57 | } |
55 | 58 | } |
@@ -72,18 +75,26 @@ discard block |
||
72 | 75 | |
73 | 76 | public function report(\Throwable $exception): void |
74 | 77 | { |
75 | - if ($this->shouldNotReport($exception)) { |
|
78 | + if ($this->shouldNotReport($exception)) |
|
79 | + { |
|
76 | 80 | return; |
77 | 81 | } |
78 | 82 | |
79 | - foreach ($this->reporters as $reporter) { |
|
80 | - try { |
|
81 | - if ($reporter instanceof ExceptionReporterInterface) { |
|
83 | + foreach ($this->reporters as $reporter) |
|
84 | + { |
|
85 | + try |
|
86 | + { |
|
87 | + if ($reporter instanceof ExceptionReporterInterface) |
|
88 | + { |
|
82 | 89 | $reporter->report($exception); |
83 | - } else { |
|
90 | + } |
|
91 | + else |
|
92 | + { |
|
84 | 93 | $reporter($exception); |
85 | 94 | } |
86 | - } catch (\Throwable) { |
|
95 | + } |
|
96 | + catch (\Throwable) |
|
97 | + { |
|
87 | 98 | // Do nothing |
88 | 99 | } |
89 | 100 | } |
@@ -91,10 +102,13 @@ discard block |
||
91 | 102 | |
92 | 103 | public function handleGlobalException(\Throwable $e): void |
93 | 104 | { |
94 | - if (\in_array(PHP_SAPI, ['cli', 'cli-server'], true)) { |
|
105 | + if (\in_array(PHP_SAPI, ['cli', 'cli-server'], true)) |
|
106 | + { |
|
95 | 107 | $this->output ??= \defined('STDERR') ? \STDERR : \fopen('php://stderr', 'wb+'); |
96 | 108 | $format = 'cli'; |
97 | - } else { |
|
109 | + } |
|
110 | + else |
|
111 | + { |
|
98 | 112 | $this->output ??= \defined('STDOUT') ? \STDOUT : \fopen('php://stdout', 'wb+'); |
99 | 113 | $format = 'html'; |
100 | 114 | } |
@@ -103,9 +117,12 @@ discard block |
||
103 | 117 | $this->report($e); |
104 | 118 | |
105 | 119 | // There is possible an exception on the application termination |
106 | - try { |
|
120 | + try |
|
121 | + { |
|
107 | 122 | \fwrite($this->output, $this->render($e, verbosity: $this->verbosity, format: $format)); |
108 | - } catch (\Throwable) { |
|
123 | + } |
|
124 | + catch (\Throwable) |
|
125 | + { |
|
109 | 126 | $this->output = null; |
110 | 127 | } |
111 | 128 | } |
@@ -147,13 +164,17 @@ discard block |
||
147 | 164 | */ |
148 | 165 | protected function handleShutdown(): void |
149 | 166 | { |
150 | - if (empty($error = \error_get_last())) { |
|
167 | + if (empty($error = \error_get_last())) |
|
168 | + { |
|
151 | 169 | return; |
152 | 170 | } |
153 | 171 | |
154 | - try { |
|
172 | + try |
|
173 | + { |
|
155 | 174 | $this->handleError($error['type'], $error['message'], $error['file'], $error['line']); |
156 | - } catch (\Throwable $e) { |
|
175 | + } |
|
176 | + catch (\Throwable $e) |
|
177 | + { |
|
157 | 178 | $this->handleGlobalException($e); |
158 | 179 | } |
159 | 180 | } |
@@ -169,7 +190,8 @@ discard block |
||
169 | 190 | string $errfile = '', |
170 | 191 | int $errline = 0, |
171 | 192 | ): bool { |
172 | - if (!(\error_reporting() & $errno)) { |
|
193 | + if (!(\error_reporting() & $errno)) |
|
194 | + { |
|
173 | 195 | return false; |
174 | 196 | } |
175 | 197 | |
@@ -183,8 +205,10 @@ discard block |
||
183 | 205 | |
184 | 206 | protected function shouldNotReport(\Throwable $exception): bool |
185 | 207 | { |
186 | - foreach ($this->nonReportableExceptions as $nonReportableException) { |
|
187 | - if ($exception instanceof $nonReportableException) { |
|
208 | + foreach ($this->nonReportableExceptions as $nonReportableException) |
|
209 | + { |
|
210 | + if ($exception instanceof $nonReportableException) |
|
211 | + { |
|
188 | 212 | return true; |
189 | 213 | } |
190 | 214 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | return $name; |
16 | 16 | } |
17 | 17 | |
18 | - public function qux(int|string $age = 42): string|int |
|
18 | + public function qux(int | string $age = 42): string | int |
|
19 | 19 | { |
20 | 20 | return $age; |
21 | 21 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function concat(string $prefix, string &$byLink): array |
39 | 39 | { |
40 | - $byLink = $prefix . $byLink; |
|
40 | + $byLink = $prefix.$byLink; |
|
41 | 41 | return \func_get_args(); |
42 | 42 | } |
43 | 43 | |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | |
49 | 49 | public function concatMultiple(string $prefix, string &...$byLink): array |
50 | 50 | { |
51 | - foreach ($byLink as $k => $link) { |
|
52 | - $byLink[$k] = $prefix . $link; |
|
51 | + foreach ($byLink as $k => $link){ |
|
52 | + $byLink[$k] = $prefix.$link; |
|
53 | 53 | unset($link); |
54 | 54 | } |
55 | 55 |
@@ -48,7 +48,8 @@ |
||
48 | 48 | |
49 | 49 | public function concatMultiple(string $prefix, string &...$byLink): array |
50 | 50 | { |
51 | - foreach ($byLink as $k => $link) { |
|
51 | + foreach ($byLink as $k => $link) |
|
52 | + { |
|
52 | 53 | $byLink[$k] = $prefix . $link; |
53 | 54 | unset($link); |
54 | 55 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | public function baz(string $name, int $age): string; |
14 | 14 | |
15 | - public function qux(string|int $age = 42): string|int; |
|
15 | + public function qux(string | int $age = 42): string | int; |
|
16 | 16 | |
17 | 17 | public function space(mixed $test age = 42): mixed; |
18 | 18 |