@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | protected readonly ContainerInterface $container, |
24 | 24 | protected readonly BinderInterface $binder, |
25 | 25 | protected readonly ClassesRegistry $bootloaders = new ClassesRegistry() |
26 | - ) { |
|
26 | + ){ |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -33,34 +33,34 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function init(array $classes): \Generator |
35 | 35 | { |
36 | - foreach ($classes as $bootloader => $options) { |
|
36 | + foreach ($classes as $bootloader => $options){ |
|
37 | 37 | // default bootload syntax as simple array |
38 | - if (\is_string($options) || $options instanceof BootloaderInterface) { |
|
38 | + if (\is_string($options) || $options instanceof BootloaderInterface){ |
|
39 | 39 | $bootloader = $options; |
40 | 40 | $options = []; |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Replace class aliases with source classes |
44 | - try { |
|
44 | + try{ |
|
45 | 45 | $ref = (new \ReflectionClass($bootloader)); |
46 | 46 | $className = $ref->getName(); |
47 | - } catch (\ReflectionException) { |
|
47 | + }catch (\ReflectionException){ |
|
48 | 48 | throw new ClassNotFoundException( |
49 | 49 | \sprintf('Bootloader class `%s` is not exist.', $bootloader) |
50 | 50 | ); |
51 | 51 | } |
52 | 52 | |
53 | - if ($this->bootloaders->isBooted($className) || $ref->isAbstract()) { |
|
53 | + if ($this->bootloaders->isBooted($className) || $ref->isAbstract()){ |
|
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | 57 | $this->bootloaders->register($className); |
58 | 58 | |
59 | - if (!$bootloader instanceof BootloaderInterface) { |
|
59 | + if (!$bootloader instanceof BootloaderInterface){ |
|
60 | 60 | $bootloader = $this->container->get($bootloader); |
61 | 61 | } |
62 | 62 | |
63 | - if (!$this->isBootloader($bootloader)) { |
|
63 | + if (!$this->isBootloader($bootloader)){ |
|
64 | 64 | continue; |
65 | 65 | } |
66 | 66 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | protected function initBootloader(BootloaderInterface $bootloader): iterable |
82 | 82 | { |
83 | - if ($bootloader instanceof DependedInterface) { |
|
83 | + if ($bootloader instanceof DependedInterface){ |
|
84 | 84 | yield from $this->init($this->getDependencies($bootloader)); |
85 | 85 | } |
86 | 86 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | */ |
99 | 99 | protected function initBindings(array $bindings, array $singletons): void |
100 | 100 | { |
101 | - foreach ($bindings as $aliases => $resolver) { |
|
101 | + foreach ($bindings as $aliases => $resolver){ |
|
102 | 102 | $this->binder->bind($aliases, $resolver); |
103 | 103 | } |
104 | 104 | |
105 | - foreach ($singletons as $aliases => $resolver) { |
|
105 | + foreach ($singletons as $aliases => $resolver){ |
|
106 | 106 | $this->binder->bindSingleton($aliases, $resolver); |
107 | 107 | } |
108 | 108 | } |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | |
116 | 116 | $methodsDeps = []; |
117 | 117 | |
118 | - foreach (Methods::cases() as $method) { |
|
119 | - if ($reflectionClass->hasMethod($method->value)) { |
|
118 | + foreach (Methods::cases() as $method){ |
|
119 | + if ($reflectionClass->hasMethod($method->value)){ |
|
120 | 120 | $methodsDeps[] = $this->findBootloaderClassesInMethod( |
121 | 121 | $reflectionClass->getMethod($method->value) |
122 | 122 | ); |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | protected function findBootloaderClassesInMethod(\ReflectionMethod $method): array |
130 | 130 | { |
131 | 131 | $args = []; |
132 | - foreach ($method->getParameters() as $parameter) { |
|
132 | + foreach ($method->getParameters() as $parameter){ |
|
133 | 133 | $type = $parameter->getType(); |
134 | - if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type)) { |
|
134 | + if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type)){ |
|
135 | 135 | $args[] = $type->getName(); |
136 | 136 | } |
137 | 137 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @psalm-pure |
154 | 154 | * @psalm-assert-if-true TClass $class |
155 | 155 | */ |
156 | - protected function isBootloader(string|object $class): bool |
|
156 | + protected function isBootloader(string | object $class): bool |
|
157 | 157 | { |
158 | 158 | return \is_subclass_of($class, BootloaderInterface::class); |
159 | 159 | } |
@@ -33,34 +33,42 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function init(array $classes): \Generator |
35 | 35 | { |
36 | - foreach ($classes as $bootloader => $options) { |
|
36 | + foreach ($classes as $bootloader => $options) |
|
37 | + { |
|
37 | 38 | // default bootload syntax as simple array |
38 | - if (\is_string($options) || $options instanceof BootloaderInterface) { |
|
39 | + if (\is_string($options) || $options instanceof BootloaderInterface) |
|
40 | + { |
|
39 | 41 | $bootloader = $options; |
40 | 42 | $options = []; |
41 | 43 | } |
42 | 44 | |
43 | 45 | // Replace class aliases with source classes |
44 | - try { |
|
46 | + try |
|
47 | + { |
|
45 | 48 | $ref = (new \ReflectionClass($bootloader)); |
46 | 49 | $className = $ref->getName(); |
47 | - } catch (\ReflectionException) { |
|
50 | + } |
|
51 | + catch (\ReflectionException) |
|
52 | + { |
|
48 | 53 | throw new ClassNotFoundException( |
49 | 54 | \sprintf('Bootloader class `%s` is not exist.', $bootloader) |
50 | 55 | ); |
51 | 56 | } |
52 | 57 | |
53 | - if ($this->bootloaders->isBooted($className) || $ref->isAbstract()) { |
|
58 | + if ($this->bootloaders->isBooted($className) || $ref->isAbstract()) |
|
59 | + { |
|
54 | 60 | continue; |
55 | 61 | } |
56 | 62 | |
57 | 63 | $this->bootloaders->register($className); |
58 | 64 | |
59 | - if (!$bootloader instanceof BootloaderInterface) { |
|
65 | + if (!$bootloader instanceof BootloaderInterface) |
|
66 | + { |
|
60 | 67 | $bootloader = $this->container->get($bootloader); |
61 | 68 | } |
62 | 69 | |
63 | - if (!$this->isBootloader($bootloader)) { |
|
70 | + if (!$this->isBootloader($bootloader)) |
|
71 | + { |
|
64 | 72 | continue; |
65 | 73 | } |
66 | 74 | |
@@ -80,7 +88,8 @@ discard block |
||
80 | 88 | */ |
81 | 89 | protected function initBootloader(BootloaderInterface $bootloader): iterable |
82 | 90 | { |
83 | - if ($bootloader instanceof DependedInterface) { |
|
91 | + if ($bootloader instanceof DependedInterface) |
|
92 | + { |
|
84 | 93 | yield from $this->init($this->getDependencies($bootloader)); |
85 | 94 | } |
86 | 95 | |
@@ -98,11 +107,13 @@ discard block |
||
98 | 107 | */ |
99 | 108 | protected function initBindings(array $bindings, array $singletons): void |
100 | 109 | { |
101 | - foreach ($bindings as $aliases => $resolver) { |
|
110 | + foreach ($bindings as $aliases => $resolver) |
|
111 | + { |
|
102 | 112 | $this->binder->bind($aliases, $resolver); |
103 | 113 | } |
104 | 114 | |
105 | - foreach ($singletons as $aliases => $resolver) { |
|
115 | + foreach ($singletons as $aliases => $resolver) |
|
116 | + { |
|
106 | 117 | $this->binder->bindSingleton($aliases, $resolver); |
107 | 118 | } |
108 | 119 | } |
@@ -115,8 +126,10 @@ discard block |
||
115 | 126 | |
116 | 127 | $methodsDeps = []; |
117 | 128 | |
118 | - foreach (Methods::cases() as $method) { |
|
119 | - if ($reflectionClass->hasMethod($method->value)) { |
|
129 | + foreach (Methods::cases() as $method) |
|
130 | + { |
|
131 | + if ($reflectionClass->hasMethod($method->value)) |
|
132 | + { |
|
120 | 133 | $methodsDeps[] = $this->findBootloaderClassesInMethod( |
121 | 134 | $reflectionClass->getMethod($method->value) |
122 | 135 | ); |
@@ -129,9 +142,11 @@ discard block |
||
129 | 142 | protected function findBootloaderClassesInMethod(\ReflectionMethod $method): array |
130 | 143 | { |
131 | 144 | $args = []; |
132 | - foreach ($method->getParameters() as $parameter) { |
|
145 | + foreach ($method->getParameters() as $parameter) |
|
146 | + { |
|
133 | 147 | $type = $parameter->getType(); |
134 | - if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type)) { |
|
148 | + if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type)) |
|
149 | + { |
|
135 | 150 | $args[] = $type->getName(); |
136 | 151 | } |
137 | 152 | } |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | SampleBootWithMethodBoot::class, |
29 | 29 | SampleBoot::class, |
30 | 30 | ], [ |
31 | - static function(Container $container, SampleBoot $boot) { |
|
31 | + static function (Container $container, SampleBoot $boot){ |
|
32 | 32 | $container->bind('efg', $boot); |
33 | 33 | } |
34 | 34 | ], [ |
35 | - static function(Container $container, SampleBoot $boot) { |
|
35 | + static function (Container $container, SampleBoot $boot){ |
|
36 | 36 | $container->bind('ghi', $boot); |
37 | 37 | } |
38 | 38 | ]); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $bootloader = $this->getBootloadManager($container); |
88 | 88 | |
89 | 89 | $bootloader->bootload([ |
90 | - new class () extends Bootloader { |
|
90 | + new class () extends Bootloader{ |
|
91 | 91 | public const BINDINGS = ['abc' => self::class]; |
92 | 92 | public const SINGLETONS = ['single' => self::class]; |
93 | 93 |
@@ -28,11 +28,13 @@ discard block |
||
28 | 28 | SampleBootWithMethodBoot::class, |
29 | 29 | SampleBoot::class, |
30 | 30 | ], [ |
31 | - static function(Container $container, SampleBoot $boot) { |
|
31 | + static function(Container $container, SampleBoot $boot) |
|
32 | + { |
|
32 | 33 | $container->bind('efg', $boot); |
33 | 34 | } |
34 | 35 | ], [ |
35 | - static function(Container $container, SampleBoot $boot) { |
|
36 | + static function(Container $container, SampleBoot $boot) |
|
37 | + { |
|
36 | 38 | $container->bind('ghi', $boot); |
37 | 39 | } |
38 | 40 | ]); |
@@ -87,7 +89,8 @@ discard block |
||
87 | 89 | $bootloader = $this->getBootloadManager($container); |
88 | 90 | |
89 | 91 | $bootloader->bootload([ |
90 | - new class () extends Bootloader { |
|
92 | + new class () extends Bootloader |
|
93 | + { |
|
91 | 94 | public const BINDINGS = ['abc' => self::class]; |
92 | 95 | public const SINGLETONS = ['single' => self::class]; |
93 | 96 |
@@ -12,7 +12,7 @@ |
||
12 | 12 | private readonly InvokerStrategyInterface $invoker, |
13 | 13 | ScopeInterface $scope, |
14 | 14 | InitializerInterface $initializer |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | parent::__construct($scope, $initializer); |
17 | 17 | } |
18 | 18 |
@@ -16,7 +16,7 @@ |
||
16 | 16 | public function __construct( |
17 | 17 | private readonly ScopeInterface $scope, |
18 | 18 | protected readonly InitializerInterface $initializer |
19 | - ) { |
|
19 | + ){ |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function getClasses(): array |
@@ -21,7 +21,7 @@ |
||
21 | 21 | private readonly ResolverInterface $resolver, |
22 | 22 | InitializerInterface $initializer, |
23 | 23 | ?InvokerStrategyInterface $invokerStrategy = null |
24 | - ) { |
|
24 | + ){ |
|
25 | 25 | parent::__construct($scope, $initializer); |
26 | 26 | |
27 | 27 | $this->invokerStrategy = $invokerStrategy ?? new DefaultStrategy( |
@@ -14,20 +14,20 @@ discard block |
||
14 | 14 | private readonly InitializerInterface $initializer, |
15 | 15 | private readonly InvokerInterface $invoker, |
16 | 16 | private readonly ResolverInterface $resolver |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function invokeBootloaders(array $classes, array $bootingCallbacks, array $bootedCallbacks): void |
21 | 21 | { |
22 | 22 | $bootloaders = \iterator_to_array($this->initializer->init($classes)); |
23 | 23 | |
24 | - foreach ($bootloaders as $data) { |
|
24 | + foreach ($bootloaders as $data){ |
|
25 | 25 | $this->invokeBootloader($data['bootloader'], Methods::INIT, $data['options']); |
26 | 26 | } |
27 | 27 | |
28 | 28 | $this->fireCallbacks($bootingCallbacks); |
29 | 29 | |
30 | - foreach ($bootloaders as $data) { |
|
30 | + foreach ($bootloaders as $data){ |
|
31 | 31 | $this->invokeBootloader($data['bootloader'], Methods::BOOT, $data['options']); |
32 | 32 | } |
33 | 33 | |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | private function invokeBootloader(BootloaderInterface $bootloader, Methods $method, array $options): void |
38 | 38 | { |
39 | 39 | $refl = new \ReflectionClass($bootloader); |
40 | - if (!$refl->hasMethod($method->value)) { |
|
40 | + if (!$refl->hasMethod($method->value)){ |
|
41 | 41 | return; |
42 | 42 | } |
43 | 43 | |
44 | 44 | $method = $refl->getMethod($method->value); |
45 | 45 | |
46 | 46 | $args = $this->resolver->resolveArguments($method); |
47 | - if (!isset($args['boot'])) { |
|
47 | + if (!isset($args['boot'])){ |
|
48 | 48 | $args['boot'] = $options; |
49 | 49 | } |
50 | 50 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | private function fireCallbacks(array $callbacks): void |
58 | 58 | { |
59 | - foreach ($callbacks as $callback) { |
|
59 | + foreach ($callbacks as $callback){ |
|
60 | 60 | $this->invoker->invoke($callback); |
61 | 61 | } |
62 | 62 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | protected readonly ExceptionHandlerInterface $exceptionHandler, |
64 | 64 | protected readonly BootloadManagerInterface $bootloader, |
65 | 65 | array $directories |
66 | - ) { |
|
66 | + ){ |
|
67 | 67 | $container->bindSingleton(ExceptionHandlerInterface::class, $exceptionHandler); |
68 | 68 | $container->bindSingleton(ExceptionRendererInterface::class, $exceptionHandler); |
69 | 69 | $container->bindSingleton(ExceptionReporterInterface::class, $exceptionHandler); |
@@ -102,24 +102,24 @@ discard block |
||
102 | 102 | final public static function create( |
103 | 103 | array $directories, |
104 | 104 | bool $handleErrors = true, |
105 | - ExceptionHandlerInterface|string|null $exceptionHandler = null, |
|
105 | + ExceptionHandlerInterface | string | null $exceptionHandler = null, |
|
106 | 106 | Container $container = new Container(), |
107 | 107 | ?BootloadManagerInterface $bootloadManager = null |
108 | 108 | ): static { |
109 | 109 | $exceptionHandler ??= ExceptionHandler::class; |
110 | 110 | |
111 | - if (\is_string($exceptionHandler)) { |
|
111 | + if (\is_string($exceptionHandler)){ |
|
112 | 112 | $exceptionHandler = $container->make($exceptionHandler); |
113 | 113 | } |
114 | 114 | |
115 | - if ($handleErrors) { |
|
115 | + if ($handleErrors){ |
|
116 | 116 | $exceptionHandler->register(); |
117 | 117 | } |
118 | 118 | |
119 | - if (!$container->has(InitializerInterface::class)) { |
|
119 | + if (!$container->has(InitializerInterface::class)){ |
|
120 | 120 | $container->bind(InitializerInterface::class, Initializer::class); |
121 | 121 | } |
122 | - if (!$container->has(InvokerStrategyInterface::class)) { |
|
122 | + if (!$container->has(InvokerStrategyInterface::class)){ |
|
123 | 123 | $container->bind(InvokerStrategyInterface::class, DefaultStrategy::class); |
124 | 124 | } |
125 | 125 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | $this->fireCallbacks($this->runningCallbacks); |
156 | 156 | |
157 | - try { |
|
157 | + try{ |
|
158 | 158 | // will protect any against env overwrite action |
159 | 159 | $this->container->runScope( |
160 | 160 | [EnvironmentInterface::class => $environment], |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $this->fireCallbacks($this->bootstrappedCallbacks); |
166 | 166 | } |
167 | 167 | ); |
168 | - } catch (\Throwable $e) { |
|
168 | + }catch (\Throwable $e){ |
|
169 | 169 | $this->exceptionHandler->handleGlobalException($e); |
170 | 170 | |
171 | 171 | return null; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function running(Closure ...$callbacks): void |
188 | 188 | { |
189 | - foreach ($callbacks as $callback) { |
|
189 | + foreach ($callbacks as $callback){ |
|
190 | 190 | $this->runningCallbacks[] = $callback; |
191 | 191 | } |
192 | 192 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function booting(Closure ...$callbacks): void |
203 | 203 | { |
204 | - foreach ($callbacks as $callback) { |
|
204 | + foreach ($callbacks as $callback){ |
|
205 | 205 | $this->bootingCallbacks[] = $callback; |
206 | 206 | } |
207 | 207 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function booted(Closure ...$callbacks): void |
218 | 218 | { |
219 | - foreach ($callbacks as $callback) { |
|
219 | + foreach ($callbacks as $callback){ |
|
220 | 220 | $this->bootedCallbacks[] = $callback; |
221 | 221 | } |
222 | 222 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function bootstrapped(Closure ...$callbacks): void |
234 | 234 | { |
235 | - foreach ($callbacks as $callback) { |
|
235 | + foreach ($callbacks as $callback){ |
|
236 | 236 | $this->bootstrappedCallbacks[] = $callback; |
237 | 237 | } |
238 | 238 | } |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | $eventDispatcher = $this->getEventDispatcher(); |
261 | 261 | $eventDispatcher?->dispatch(new Serving()); |
262 | 262 | |
263 | - foreach ($this->dispatchers as $dispatcher) { |
|
264 | - if ($dispatcher->canServe()) { |
|
263 | + foreach ($this->dispatchers as $dispatcher){ |
|
264 | + if ($dispatcher->canServe()){ |
|
265 | 265 | return $this->container->runScope( |
266 | 266 | [DispatcherInterface::class => $dispatcher], |
267 | 267 | static function () use ($dispatcher, $eventDispatcher): mixed { |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | */ |
303 | 303 | protected function fireCallbacks(array &$callbacks): void |
304 | 304 | { |
305 | - if ($callbacks === []) { |
|
305 | + if ($callbacks === []){ |
|
306 | 306 | return; |
307 | 307 | } |
308 | 308 | |
309 | - do { |
|
309 | + do{ |
|
310 | 310 | $this->container->invoke(\current($callbacks)); |
311 | - } while (\next($callbacks)); |
|
311 | + }while (\next($callbacks)); |
|
312 | 312 | |
313 | 313 | $callbacks = []; |
314 | 314 | } |
@@ -108,18 +108,22 @@ discard block |
||
108 | 108 | ): static { |
109 | 109 | $exceptionHandler ??= ExceptionHandler::class; |
110 | 110 | |
111 | - if (\is_string($exceptionHandler)) { |
|
111 | + if (\is_string($exceptionHandler)) |
|
112 | + { |
|
112 | 113 | $exceptionHandler = $container->make($exceptionHandler); |
113 | 114 | } |
114 | 115 | |
115 | - if ($handleErrors) { |
|
116 | + if ($handleErrors) |
|
117 | + { |
|
116 | 118 | $exceptionHandler->register(); |
117 | 119 | } |
118 | 120 | |
119 | - if (!$container->has(InitializerInterface::class)) { |
|
121 | + if (!$container->has(InitializerInterface::class)) |
|
122 | + { |
|
120 | 123 | $container->bind(InitializerInterface::class, Initializer::class); |
121 | 124 | } |
122 | - if (!$container->has(InvokerStrategyInterface::class)) { |
|
125 | + if (!$container->has(InvokerStrategyInterface::class)) |
|
126 | + { |
|
123 | 127 | $container->bind(InvokerStrategyInterface::class, DefaultStrategy::class); |
124 | 128 | } |
125 | 129 | |
@@ -154,7 +158,8 @@ discard block |
||
154 | 158 | |
155 | 159 | $this->fireCallbacks($this->runningCallbacks); |
156 | 160 | |
157 | - try { |
|
161 | + try |
|
162 | + { |
|
158 | 163 | // will protect any against env overwrite action |
159 | 164 | $this->container->runScope( |
160 | 165 | [EnvironmentInterface::class => $environment], |
@@ -165,7 +170,9 @@ discard block |
||
165 | 170 | $this->fireCallbacks($this->bootstrappedCallbacks); |
166 | 171 | } |
167 | 172 | ); |
168 | - } catch (\Throwable $e) { |
|
173 | + } |
|
174 | + catch (\Throwable $e) |
|
175 | + { |
|
169 | 176 | $this->exceptionHandler->handleGlobalException($e); |
170 | 177 | |
171 | 178 | return null; |
@@ -186,7 +193,8 @@ discard block |
||
186 | 193 | */ |
187 | 194 | public function running(Closure ...$callbacks): void |
188 | 195 | { |
189 | - foreach ($callbacks as $callback) { |
|
196 | + foreach ($callbacks as $callback) |
|
197 | + { |
|
190 | 198 | $this->runningCallbacks[] = $callback; |
191 | 199 | } |
192 | 200 | } |
@@ -201,7 +209,8 @@ discard block |
||
201 | 209 | */ |
202 | 210 | public function booting(Closure ...$callbacks): void |
203 | 211 | { |
204 | - foreach ($callbacks as $callback) { |
|
212 | + foreach ($callbacks as $callback) |
|
213 | + { |
|
205 | 214 | $this->bootingCallbacks[] = $callback; |
206 | 215 | } |
207 | 216 | } |
@@ -216,7 +225,8 @@ discard block |
||
216 | 225 | */ |
217 | 226 | public function booted(Closure ...$callbacks): void |
218 | 227 | { |
219 | - foreach ($callbacks as $callback) { |
|
228 | + foreach ($callbacks as $callback) |
|
229 | + { |
|
220 | 230 | $this->bootedCallbacks[] = $callback; |
221 | 231 | } |
222 | 232 | } |
@@ -232,7 +242,8 @@ discard block |
||
232 | 242 | */ |
233 | 243 | public function bootstrapped(Closure ...$callbacks): void |
234 | 244 | { |
235 | - foreach ($callbacks as $callback) { |
|
245 | + foreach ($callbacks as $callback) |
|
246 | + { |
|
236 | 247 | $this->bootstrappedCallbacks[] = $callback; |
237 | 248 | } |
238 | 249 | } |
@@ -260,8 +271,10 @@ discard block |
||
260 | 271 | $eventDispatcher = $this->getEventDispatcher(); |
261 | 272 | $eventDispatcher?->dispatch(new Serving()); |
262 | 273 | |
263 | - foreach ($this->dispatchers as $dispatcher) { |
|
264 | - if ($dispatcher->canServe()) { |
|
274 | + foreach ($this->dispatchers as $dispatcher) |
|
275 | + { |
|
276 | + if ($dispatcher->canServe()) |
|
277 | + { |
|
265 | 278 | return $this->container->runScope( |
266 | 279 | [DispatcherInterface::class => $dispatcher], |
267 | 280 | static function () use ($dispatcher, $eventDispatcher): mixed { |
@@ -302,11 +315,13 @@ discard block |
||
302 | 315 | */ |
303 | 316 | protected function fireCallbacks(array &$callbacks): void |
304 | 317 | { |
305 | - if ($callbacks === []) { |
|
318 | + if ($callbacks === []) |
|
319 | + { |
|
306 | 320 | return; |
307 | 321 | } |
308 | 322 | |
309 | - do { |
|
323 | + do |
|
324 | + { |
|
310 | 325 | $this->container->invoke(\current($callbacks)); |
311 | 326 | } while (\next($callbacks)); |
312 | 327 |