@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Spiral\Core\ContainerScope; |
10 | 10 | use Spiral\Core\Exception\ScopeException; |
11 | 11 | |
12 | -if (!function_exists('spiral')) { |
|
12 | +if (!function_exists('spiral')){ |
|
13 | 13 | /** |
14 | 14 | * Resolve given alias in current IoC scope. |
15 | 15 | * |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function spiral(string $alias): mixed |
24 | 24 | { |
25 | - if (ContainerScope::getContainer() === null) { |
|
25 | + if (ContainerScope::getContainer() === null){ |
|
26 | 26 | throw new ScopeException('Container scope was not set.'); |
27 | 27 | } |
28 | 28 | |
29 | - try { |
|
29 | + try{ |
|
30 | 30 | return ContainerScope::getContainer()->get($alias); |
31 | - } catch (ContainerExceptionInterface $e) { |
|
31 | + }catch (ContainerExceptionInterface $e){ |
|
32 | 32 | throw new ScopeException($e->getMessage(), $e->getCode(), $e); |
33 | 33 | } |
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | -if (!function_exists('directory')) { |
|
37 | +if (!function_exists('directory')){ |
|
38 | 38 | /** |
39 | 39 | * Get directory alias value. Uses application core from the current global scope. |
40 | 40 | * |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -if (!function_exists('env')) { |
|
53 | +if (!function_exists('env')){ |
|
54 | 54 | /** |
55 | 55 | * Gets the value of an environment variable. Uses application core from the current global scope. |
56 | 56 | * |
@@ -9,7 +9,8 @@ discard block |
||
9 | 9 | use Spiral\Core\ContainerScope; |
10 | 10 | use Spiral\Core\Exception\ScopeException; |
11 | 11 | |
12 | -if (!function_exists('spiral')) { |
|
12 | +if (!function_exists('spiral')) |
|
13 | +{ |
|
13 | 14 | /** |
14 | 15 | * Resolve given alias in current IoC scope. |
15 | 16 | * |
@@ -22,19 +23,24 @@ discard block |
||
22 | 23 | */ |
23 | 24 | function spiral(string $alias): mixed |
24 | 25 | { |
25 | - if (ContainerScope::getContainer() === null) { |
|
26 | + if (ContainerScope::getContainer() === null) |
|
27 | + { |
|
26 | 28 | throw new ScopeException('Container scope was not set.'); |
27 | 29 | } |
28 | 30 | |
29 | - try { |
|
31 | + try |
|
32 | + { |
|
30 | 33 | return ContainerScope::getContainer()->get($alias); |
31 | - } catch (ContainerExceptionInterface $e) { |
|
34 | + } |
|
35 | + catch (ContainerExceptionInterface $e) |
|
36 | + { |
|
32 | 37 | throw new ScopeException($e->getMessage(), $e->getCode(), $e); |
33 | 38 | } |
34 | 39 | } |
35 | 40 | } |
36 | 41 | |
37 | -if (!function_exists('directory')) { |
|
42 | +if (!function_exists('directory')) |
|
43 | +{ |
|
38 | 44 | /** |
39 | 45 | * Get directory alias value. Uses application core from the current global scope. |
40 | 46 | * |
@@ -50,7 +56,8 @@ discard block |
||
50 | 56 | } |
51 | 57 | } |
52 | 58 | |
53 | -if (!function_exists('env')) { |
|
59 | +if (!function_exists('env')) |
|
60 | +{ |
|
54 | 61 | /** |
55 | 62 | * Gets the value of an environment variable. Uses application core from the current global scope. |
56 | 63 | * |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | public function __construct( |
26 | 26 | array $values = [], |
27 | 27 | private bool $overwrite = false |
28 | - ) { |
|
28 | + ){ |
|
29 | 29 | $this->values = $values + $_ENV + $_SERVER; |
30 | 30 | } |
31 | 31 | |
32 | 32 | public function getID(): string |
33 | 33 | { |
34 | - if (empty($this->id)) { |
|
34 | + if (empty($this->id)){ |
|
35 | 35 | $this->id = \md5(\serialize($this->values)); |
36 | 36 | } |
37 | 37 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | public function set(string $name, mixed $value): self |
42 | 42 | { |
43 | - if (\array_key_exists($name, $this->values) && !$this->overwrite) { |
|
43 | + if (\array_key_exists($name, $this->values) && !$this->overwrite){ |
|
44 | 44 | return $this; |
45 | 45 | } |
46 | 46 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | public function get(string $name, mixed $default = null): mixed |
56 | 56 | { |
57 | - if (isset($this->values[$name])) { |
|
57 | + if (isset($this->values[$name])){ |
|
58 | 58 | return $this->normalize($this->values[$name]); |
59 | 59 | } |
60 | 60 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | { |
69 | 69 | $result = []; |
70 | 70 | |
71 | - foreach ($this->values as $key => $value) { |
|
71 | + foreach ($this->values as $key => $value){ |
|
72 | 72 | $result[$key] = $this->normalize($value); |
73 | 73 | } |
74 | 74 | |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | |
78 | 78 | protected function normalize(mixed $value): mixed |
79 | 79 | { |
80 | - if (!\is_string($value)) { |
|
80 | + if (!\is_string($value)){ |
|
81 | 81 | return $value; |
82 | 82 | } |
83 | 83 | |
84 | 84 | $alias = \strtolower($value); |
85 | - if (isset(self::VALUE_MAP[$alias])) { |
|
85 | + if (isset(self::VALUE_MAP[$alias])){ |
|
86 | 86 | return self::VALUE_MAP[$alias]; |
87 | 87 | } |
88 | 88 |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | |
32 | 32 | public function getID(): string |
33 | 33 | { |
34 | - if (empty($this->id)) { |
|
34 | + if (empty($this->id)) |
|
35 | + { |
|
35 | 36 | $this->id = \md5(\serialize($this->values)); |
36 | 37 | } |
37 | 38 | |
@@ -40,7 +41,8 @@ discard block |
||
40 | 41 | |
41 | 42 | public function set(string $name, mixed $value): self |
42 | 43 | { |
43 | - if (\array_key_exists($name, $this->values) && !$this->overwrite) { |
|
44 | + if (\array_key_exists($name, $this->values) && !$this->overwrite) |
|
45 | + { |
|
44 | 46 | return $this; |
45 | 47 | } |
46 | 48 | |
@@ -54,7 +56,8 @@ discard block |
||
54 | 56 | |
55 | 57 | public function get(string $name, mixed $default = null): mixed |
56 | 58 | { |
57 | - if (isset($this->values[$name])) { |
|
59 | + if (isset($this->values[$name])) |
|
60 | + { |
|
58 | 61 | return $this->normalize($this->values[$name]); |
59 | 62 | } |
60 | 63 | |
@@ -68,7 +71,8 @@ discard block |
||
68 | 71 | { |
69 | 72 | $result = []; |
70 | 73 | |
71 | - foreach ($this->values as $key => $value) { |
|
74 | + foreach ($this->values as $key => $value) |
|
75 | + { |
|
72 | 76 | $result[$key] = $this->normalize($value); |
73 | 77 | } |
74 | 78 | |
@@ -77,12 +81,14 @@ discard block |
||
77 | 81 | |
78 | 82 | protected function normalize(mixed $value): mixed |
79 | 83 | { |
80 | - if (!\is_string($value)) { |
|
84 | + if (!\is_string($value)) |
|
85 | + { |
|
81 | 86 | return $value; |
82 | 87 | } |
83 | 88 | |
84 | 89 | $alias = \strtolower($value); |
85 | - if (isset(self::VALUE_MAP[$alias])) { |
|
90 | + if (isset(self::VALUE_MAP[$alias])) |
|
91 | + { |
|
86 | 92 | return self::VALUE_MAP[$alias]; |
87 | 93 | } |
88 | 94 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public function __construct( |
20 | 20 | string $directory, |
21 | 21 | private readonly FilesInterface $files |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | $this->directory = \rtrim($directory, '/'); |
24 | 24 | } |
25 | 25 | |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | { |
31 | 31 | $filename = $this->getFilename($section); |
32 | 32 | |
33 | - if (!\file_exists($filename)) { |
|
33 | + if (!\file_exists($filename)){ |
|
34 | 34 | return null; |
35 | 35 | } |
36 | 36 | |
37 | - try { |
|
37 | + try{ |
|
38 | 38 | return include($filename); |
39 | - } catch (\Throwable) { |
|
39 | + }catch (\Throwable){ |
|
40 | 40 | return null; |
41 | 41 | } |
42 | 42 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | $this->files->write( |
47 | 47 | $this->getFilename($section), |
48 | - '<?php return ' . \var_export($data, true) . ';', |
|
48 | + '<?php return '.\var_export($data, true).';', |
|
49 | 49 | FilesInterface::RUNTIME, |
50 | 50 | true |
51 | 51 | ); |
@@ -30,13 +30,17 @@ |
||
30 | 30 | { |
31 | 31 | $filename = $this->getFilename($section); |
32 | 32 | |
33 | - if (!\file_exists($filename)) { |
|
33 | + if (!\file_exists($filename)) |
|
34 | + { |
|
34 | 35 | return null; |
35 | 36 | } |
36 | 37 | |
37 | - try { |
|
38 | + try |
|
39 | + { |
|
38 | 40 | return include($filename); |
39 | - } catch (\Throwable) { |
|
41 | + } |
|
42 | + catch (\Throwable) |
|
43 | + { |
|
40 | 44 | return null; |
41 | 45 | } |
42 | 46 | } |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | private readonly InvokerInterface $invoker, |
23 | 23 | private readonly BinderInterface $binder, |
24 | 24 | private readonly AttributeReader $reader |
25 | - ) { |
|
25 | + ){ |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function createInjection(\ReflectionClass $class, string $context = null): UnitEnum |
29 | 29 | { |
30 | 30 | $attribute = $this->reader->firstClassMetadata($class, ProvideFrom::class); |
31 | - if ($attribute === null) { |
|
31 | + if ($attribute === null){ |
|
32 | 32 | throw new InjectionException( |
33 | 33 | \sprintf( |
34 | 34 | 'Class `%s` should contain `%s` attribute with defined detector method.', |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | private function validateClass(\ReflectionClass $class, ProvideFrom $attribute): void |
64 | 64 | { |
65 | - if (!$class->isEnum()) { |
|
65 | + if (!$class->isEnum()){ |
|
66 | 66 | throw new InjectionException( |
67 | 67 | \sprintf( |
68 | 68 | 'Class `%s` should be an enum.', |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | ); |
72 | 72 | } |
73 | 73 | |
74 | - if (!$class->hasMethod($attribute->method)) { |
|
74 | + if (!$class->hasMethod($attribute->method)){ |
|
75 | 75 | throw new InjectionException( |
76 | 76 | \sprintf( |
77 | 77 | 'Class `%s` does not contain `%s` method.', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ); |
82 | 82 | } |
83 | 83 | |
84 | - if (!$class->getMethod($attribute->method)->isStatic()) { |
|
84 | + if (!$class->getMethod($attribute->method)->isStatic()){ |
|
85 | 85 | throw new InjectionException( |
86 | 86 | \sprintf( |
87 | 87 | 'Class method `%s::%s` should be static.', |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | public function createInjection(\ReflectionClass $class, string $context = null): UnitEnum |
29 | 29 | { |
30 | 30 | $attribute = $this->reader->firstClassMetadata($class, ProvideFrom::class); |
31 | - if ($attribute === null) { |
|
31 | + if ($attribute === null) |
|
32 | + { |
|
32 | 33 | throw new InjectionException( |
33 | 34 | \sprintf( |
34 | 35 | 'Class `%s` should contain `%s` attribute with defined detector method.', |
@@ -62,7 +63,8 @@ discard block |
||
62 | 63 | */ |
63 | 64 | private function validateClass(\ReflectionClass $class, ProvideFrom $attribute): void |
64 | 65 | { |
65 | - if (!$class->isEnum()) { |
|
66 | + if (!$class->isEnum()) |
|
67 | + { |
|
66 | 68 | throw new InjectionException( |
67 | 69 | \sprintf( |
68 | 70 | 'Class `%s` should be an enum.', |
@@ -71,7 +73,8 @@ discard block |
||
71 | 73 | ); |
72 | 74 | } |
73 | 75 | |
74 | - if (!$class->hasMethod($attribute->method)) { |
|
76 | + if (!$class->hasMethod($attribute->method)) |
|
77 | + { |
|
75 | 78 | throw new InjectionException( |
76 | 79 | \sprintf( |
77 | 80 | 'Class `%s` does not contain `%s` method.', |
@@ -81,7 +84,8 @@ discard block |
||
81 | 84 | ); |
82 | 85 | } |
83 | 86 | |
84 | - if (!$class->getMethod($attribute->method)->isStatic()) { |
|
87 | + if (!$class->getMethod($attribute->method)->isStatic()) |
|
88 | + { |
|
85 | 89 | throw new InjectionException( |
86 | 90 | \sprintf( |
87 | 91 | 'Class method `%s::%s` should be static.', |
@@ -11,6 +11,6 @@ |
||
11 | 11 | { |
12 | 12 | public function __construct( |
13 | 13 | public readonly string $method |
14 | - ) { |
|
14 | + ){ |
|
15 | 15 | } |
16 | 16 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | ContainerInterface $container, |
37 | 37 | private readonly DirectoriesInterface $directories, |
38 | 38 | private readonly BinderInterface $binder |
39 | - ) { |
|
39 | + ){ |
|
40 | 40 | $this->loaders = [ |
41 | 41 | 'php' => $container->get(PhpLoader::class), |
42 | 42 | 'json' => $container->get(JsonLoader::class), |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | public function addLoader(string $ext, FileLoaderInterface $loader): void |
49 | 49 | { |
50 | - if (!isset($this->loaders[$ext]) || $this->loaders[$ext]::class !== $loader::class) { |
|
50 | + if (!isset($this->loaders[$ext]) || $this->loaders[$ext]::class !== $loader::class){ |
|
51 | 51 | $this->loaders[$ext] = $loader; |
52 | 52 | $this->binder->bindSingleton(ConfigManager::class, $this->createConfigManager()); |
53 | 53 | } |
@@ -47,7 +47,8 @@ |
||
47 | 47 | |
48 | 48 | public function addLoader(string $ext, FileLoaderInterface $loader): void |
49 | 49 | { |
50 | - if (!isset($this->loaders[$ext]) || $this->loaders[$ext]::class !== $loader::class) { |
|
50 | + if (!isset($this->loaders[$ext]) || $this->loaders[$ext]::class !== $loader::class) |
|
51 | + { |
|
51 | 52 | $this->loaders[$ext] = $loader; |
52 | 53 | $this->binder->bindSingleton(ConfigManager::class, $this->createConfigManager()); |
53 | 54 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | { |
27 | 27 | $this->dispatcher?->dispatch(new Finalizing($this)); |
28 | 28 | |
29 | - foreach ($this->finalizers as $finalizer) { |
|
29 | + foreach ($this->finalizers as $finalizer){ |
|
30 | 30 | \call_user_func($finalizer, $terminate); |
31 | 31 | } |
32 | 32 | } |
@@ -26,7 +26,8 @@ |
||
26 | 26 | { |
27 | 27 | $this->dispatcher?->dispatch(new Finalizing($this)); |
28 | 28 | |
29 | - foreach ($this->finalizers as $finalizer) { |
|
29 | + foreach ($this->finalizers as $finalizer) |
|
30 | + { |
|
30 | 31 | \call_user_func($finalizer, $terminate); |
31 | 32 | } |
32 | 33 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | protected readonly ExceptionHandlerInterface $exceptionHandler, |
60 | 60 | protected readonly BootloadManagerInterface $bootloader, |
61 | 61 | array $directories |
62 | - ) { |
|
62 | + ){ |
|
63 | 63 | $container->bindSingleton(ExceptionHandlerInterface::class, $exceptionHandler); |
64 | 64 | $container->bindSingleton(ExceptionRendererInterface::class, $exceptionHandler); |
65 | 65 | $container->bindSingleton(ExceptionReporterInterface::class, $exceptionHandler); |
@@ -98,17 +98,17 @@ discard block |
||
98 | 98 | final public static function create( |
99 | 99 | array $directories, |
100 | 100 | bool $handleErrors = true, |
101 | - ExceptionHandlerInterface|string|null $exceptionHandler = null, |
|
101 | + ExceptionHandlerInterface | string | null $exceptionHandler = null, |
|
102 | 102 | Container $container = new Container(), |
103 | 103 | ?BootloadManagerInterface $bootloadManager = null |
104 | 104 | ): static { |
105 | 105 | $exceptionHandler ??= ExceptionHandler::class; |
106 | 106 | |
107 | - if (\is_string($exceptionHandler)) { |
|
107 | + if (\is_string($exceptionHandler)){ |
|
108 | 108 | $exceptionHandler = $container->make($exceptionHandler); |
109 | 109 | } |
110 | 110 | |
111 | - if ($handleErrors) { |
|
111 | + if ($handleErrors){ |
|
112 | 112 | $exceptionHandler->register(); |
113 | 113 | } |
114 | 114 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | $this->fireCallbacks($this->runningCallbacks); |
145 | 145 | |
146 | - try { |
|
146 | + try{ |
|
147 | 147 | // will protect any against env overwrite action |
148 | 148 | $this->container->runScope( |
149 | 149 | [EnvironmentInterface::class => $environment], |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $this->fireCallbacks($this->bootstrappedCallbacks); |
155 | 155 | } |
156 | 156 | ); |
157 | - } catch (\Throwable $e) { |
|
157 | + }catch (\Throwable $e){ |
|
158 | 158 | $this->exceptionHandler->handleGlobalException($e); |
159 | 159 | |
160 | 160 | return null; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function running(Closure ...$callbacks): void |
177 | 177 | { |
178 | - foreach ($callbacks as $callback) { |
|
178 | + foreach ($callbacks as $callback){ |
|
179 | 179 | $this->runningCallbacks[] = $callback; |
180 | 180 | } |
181 | 181 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function booting(Closure ...$callbacks): void |
192 | 192 | { |
193 | - foreach ($callbacks as $callback) { |
|
193 | + foreach ($callbacks as $callback){ |
|
194 | 194 | $this->bootingCallbacks[] = $callback; |
195 | 195 | } |
196 | 196 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function booted(Closure ...$callbacks): void |
207 | 207 | { |
208 | - foreach ($callbacks as $callback) { |
|
208 | + foreach ($callbacks as $callback){ |
|
209 | 209 | $this->bootedCallbacks[] = $callback; |
210 | 210 | } |
211 | 211 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | */ |
222 | 222 | public function bootstrapped(Closure ...$callbacks): void |
223 | 223 | { |
224 | - foreach ($callbacks as $callback) { |
|
224 | + foreach ($callbacks as $callback){ |
|
225 | 225 | $this->bootstrappedCallbacks[] = $callback; |
226 | 226 | } |
227 | 227 | } |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | $eventDispatcher = $this->getEventDispatcher(); |
250 | 250 | $eventDispatcher?->dispatch(new Serving()); |
251 | 251 | |
252 | - foreach ($this->dispatchers as $dispatcher) { |
|
253 | - if ($dispatcher->canServe()) { |
|
252 | + foreach ($this->dispatchers as $dispatcher){ |
|
253 | + if ($dispatcher->canServe()){ |
|
254 | 254 | return $this->container->runScope( |
255 | 255 | [DispatcherInterface::class => $dispatcher], |
256 | 256 | static function () use ($dispatcher, $eventDispatcher): mixed { |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | */ |
292 | 292 | protected function fireCallbacks(array &$callbacks): void |
293 | 293 | { |
294 | - if ($callbacks === []) { |
|
294 | + if ($callbacks === []){ |
|
295 | 295 | return; |
296 | 296 | } |
297 | 297 | |
298 | - do { |
|
298 | + do{ |
|
299 | 299 | $this->container->invoke(\current($callbacks)); |
300 | - } while (\next($callbacks)); |
|
300 | + }while (\next($callbacks)); |
|
301 | 301 | |
302 | 302 | $callbacks = []; |
303 | 303 | } |
@@ -104,11 +104,13 @@ discard block |
||
104 | 104 | ): static { |
105 | 105 | $exceptionHandler ??= ExceptionHandler::class; |
106 | 106 | |
107 | - if (\is_string($exceptionHandler)) { |
|
107 | + if (\is_string($exceptionHandler)) |
|
108 | + { |
|
108 | 109 | $exceptionHandler = $container->make($exceptionHandler); |
109 | 110 | } |
110 | 111 | |
111 | - if ($handleErrors) { |
|
112 | + if ($handleErrors) |
|
113 | + { |
|
112 | 114 | $exceptionHandler->register(); |
113 | 115 | } |
114 | 116 | |
@@ -143,7 +145,8 @@ discard block |
||
143 | 145 | |
144 | 146 | $this->fireCallbacks($this->runningCallbacks); |
145 | 147 | |
146 | - try { |
|
148 | + try |
|
149 | + { |
|
147 | 150 | // will protect any against env overwrite action |
148 | 151 | $this->container->runScope( |
149 | 152 | [EnvironmentInterface::class => $environment], |
@@ -154,7 +157,9 @@ discard block |
||
154 | 157 | $this->fireCallbacks($this->bootstrappedCallbacks); |
155 | 158 | } |
156 | 159 | ); |
157 | - } catch (\Throwable $e) { |
|
160 | + } |
|
161 | + catch (\Throwable $e) |
|
162 | + { |
|
158 | 163 | $this->exceptionHandler->handleGlobalException($e); |
159 | 164 | |
160 | 165 | return null; |
@@ -175,7 +180,8 @@ discard block |
||
175 | 180 | */ |
176 | 181 | public function running(Closure ...$callbacks): void |
177 | 182 | { |
178 | - foreach ($callbacks as $callback) { |
|
183 | + foreach ($callbacks as $callback) |
|
184 | + { |
|
179 | 185 | $this->runningCallbacks[] = $callback; |
180 | 186 | } |
181 | 187 | } |
@@ -190,7 +196,8 @@ discard block |
||
190 | 196 | */ |
191 | 197 | public function booting(Closure ...$callbacks): void |
192 | 198 | { |
193 | - foreach ($callbacks as $callback) { |
|
199 | + foreach ($callbacks as $callback) |
|
200 | + { |
|
194 | 201 | $this->bootingCallbacks[] = $callback; |
195 | 202 | } |
196 | 203 | } |
@@ -205,7 +212,8 @@ discard block |
||
205 | 212 | */ |
206 | 213 | public function booted(Closure ...$callbacks): void |
207 | 214 | { |
208 | - foreach ($callbacks as $callback) { |
|
215 | + foreach ($callbacks as $callback) |
|
216 | + { |
|
209 | 217 | $this->bootedCallbacks[] = $callback; |
210 | 218 | } |
211 | 219 | } |
@@ -221,7 +229,8 @@ discard block |
||
221 | 229 | */ |
222 | 230 | public function bootstrapped(Closure ...$callbacks): void |
223 | 231 | { |
224 | - foreach ($callbacks as $callback) { |
|
232 | + foreach ($callbacks as $callback) |
|
233 | + { |
|
225 | 234 | $this->bootstrappedCallbacks[] = $callback; |
226 | 235 | } |
227 | 236 | } |
@@ -249,8 +258,10 @@ discard block |
||
249 | 258 | $eventDispatcher = $this->getEventDispatcher(); |
250 | 259 | $eventDispatcher?->dispatch(new Serving()); |
251 | 260 | |
252 | - foreach ($this->dispatchers as $dispatcher) { |
|
253 | - if ($dispatcher->canServe()) { |
|
261 | + foreach ($this->dispatchers as $dispatcher) |
|
262 | + { |
|
263 | + if ($dispatcher->canServe()) |
|
264 | + { |
|
254 | 265 | return $this->container->runScope( |
255 | 266 | [DispatcherInterface::class => $dispatcher], |
256 | 267 | static function () use ($dispatcher, $eventDispatcher): mixed { |
@@ -291,11 +302,13 @@ discard block |
||
291 | 302 | */ |
292 | 303 | protected function fireCallbacks(array &$callbacks): void |
293 | 304 | { |
294 | - if ($callbacks === []) { |
|
305 | + if ($callbacks === []) |
|
306 | + { |
|
295 | 307 | return; |
296 | 308 | } |
297 | 309 | |
298 | - do { |
|
310 | + do |
|
311 | + { |
|
299 | 312 | $this->container->invoke(\current($callbacks)); |
300 | 313 | } while (\next($callbacks)); |
301 | 314 |
@@ -14,7 +14,7 @@ |
||
14 | 14 | public function testLazyCommandCreationInCommandLocator(): void |
15 | 15 | { |
16 | 16 | $locator = $this->getCommandLocator( |
17 | - new class() implements ScopedClassesInterface { |
|
17 | + new class() implements ScopedClassesInterface{ |
|
18 | 18 | public function getScopedClasses(string $scope, $target = null): array |
19 | 19 | { |
20 | 20 | return [ |
@@ -14,7 +14,8 @@ |
||
14 | 14 | public function testLazyCommandCreationInCommandLocator(): void |
15 | 15 | { |
16 | 16 | $locator = $this->getCommandLocator( |
17 | - new class() implements ScopedClassesInterface { |
|
17 | + new class() implements ScopedClassesInterface |
|
18 | + { |
|
18 | 19 | public function getScopedClasses(string $scope, $target = null): array |
19 | 20 | { |
20 | 21 | return [ |