@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | protected readonly ExceptionHandlerInterface $exceptionHandler, |
73 | 73 | protected readonly BootloadManagerInterface $bootloader, |
74 | 74 | array $directories |
75 | - ) { |
|
75 | + ){ |
|
76 | 76 | $container->bindSingleton(ExceptionHandlerInterface::class, $exceptionHandler); |
77 | 77 | $container->bindSingleton(ExceptionRendererInterface::class, $exceptionHandler); |
78 | 78 | $container->bindSingleton(ExceptionReporterInterface::class, $exceptionHandler); |
@@ -109,35 +109,35 @@ discard block |
||
109 | 109 | final public static function create( |
110 | 110 | array $directories, |
111 | 111 | bool $handleErrors = true, |
112 | - ExceptionHandlerInterface|string|null $exceptionHandler = null, |
|
112 | + ExceptionHandlerInterface | string | null $exceptionHandler = null, |
|
113 | 113 | Container $container = new Container(), |
114 | - BootloadManagerInterface|Autowire|null $bootloadManager = null |
|
114 | + BootloadManagerInterface | Autowire | null $bootloadManager = null |
|
115 | 115 | ): static { |
116 | 116 | $exceptionHandler ??= ExceptionHandler::class; |
117 | 117 | |
118 | - if (\is_string($exceptionHandler)) { |
|
118 | + if (\is_string($exceptionHandler)){ |
|
119 | 119 | $exceptionHandler = $container->make($exceptionHandler); |
120 | 120 | } |
121 | 121 | |
122 | - if ($handleErrors) { |
|
122 | + if ($handleErrors){ |
|
123 | 123 | $exceptionHandler->register(); |
124 | 124 | } |
125 | 125 | |
126 | - if (!$container->has(InitializerInterface::class)) { |
|
126 | + if (!$container->has(InitializerInterface::class)){ |
|
127 | 127 | $container->bind(InitializerInterface::class, Initializer::class); |
128 | 128 | } |
129 | - if (!$container->has(InvokerStrategyInterface::class)) { |
|
129 | + if (!$container->has(InvokerStrategyInterface::class)){ |
|
130 | 130 | $container->bind(InvokerStrategyInterface::class, DefaultInvokerStrategy::class); |
131 | 131 | } |
132 | 132 | |
133 | - if ($bootloadManager instanceof Autowire) { |
|
133 | + if ($bootloadManager instanceof Autowire){ |
|
134 | 134 | $bootloadManager = $bootloadManager->resolve($container); |
135 | 135 | } |
136 | 136 | $bootloadManager ??= $container->make(StrategyBasedBootloadManager::class); |
137 | 137 | \assert($bootloadManager instanceof BootloadManagerInterface); |
138 | 138 | $container->bind(BootloadManagerInterface::class, $bootloadManager); |
139 | 139 | |
140 | - if (!$container->has(BootloaderRegistryInterface::class)) { |
|
140 | + if (!$container->has(BootloaderRegistryInterface::class)){ |
|
141 | 141 | $container->bindSingleton(BootloaderRegistryInterface::class, [self::class, 'initBootloaderRegistry']); |
142 | 142 | } |
143 | 143 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $environment ??= new Environment(); |
167 | 167 | $this->container->bindSingleton(EnvironmentInterface::class, $environment); |
168 | 168 | |
169 | - try { |
|
169 | + try{ |
|
170 | 170 | // will protect any against env overwrite action |
171 | 171 | $this->container->runScope( |
172 | 172 | [EnvironmentInterface::class => $environment], |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $this->fireCallbacks($this->bootstrappedCallbacks); |
183 | 183 | } |
184 | 184 | ); |
185 | - } catch (\Throwable $e) { |
|
185 | + }catch (\Throwable $e){ |
|
186 | 186 | $this->exceptionHandler->handleGlobalException($e); |
187 | 187 | |
188 | 188 | return null; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function running(Closure ...$callbacks): void |
205 | 205 | { |
206 | - foreach ($callbacks as $callback) { |
|
206 | + foreach ($callbacks as $callback){ |
|
207 | 207 | $this->runningCallbacks[] = $callback; |
208 | 208 | } |
209 | 209 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | */ |
219 | 219 | public function booting(Closure ...$callbacks): void |
220 | 220 | { |
221 | - foreach ($callbacks as $callback) { |
|
221 | + foreach ($callbacks as $callback){ |
|
222 | 222 | $this->bootingCallbacks[] = $callback; |
223 | 223 | } |
224 | 224 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function booted(Closure ...$callbacks): void |
235 | 235 | { |
236 | - foreach ($callbacks as $callback) { |
|
236 | + foreach ($callbacks as $callback){ |
|
237 | 237 | $this->bootedCallbacks[] = $callback; |
238 | 238 | } |
239 | 239 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | public function bootstrapped(Closure ...$callbacks): void |
251 | 251 | { |
252 | - foreach ($callbacks as $callback) { |
|
252 | + foreach ($callbacks as $callback){ |
|
253 | 253 | $this->bootstrappedCallbacks[] = $callback; |
254 | 254 | } |
255 | 255 | } |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | $eventDispatcher = $this->getEventDispatcher(); |
278 | 278 | $eventDispatcher?->dispatch(new Serving()); |
279 | 279 | |
280 | - foreach ($this->dispatchers as $dispatcher) { |
|
281 | - if ($dispatcher->canServe()) { |
|
280 | + foreach ($this->dispatchers as $dispatcher){ |
|
281 | + if ($dispatcher->canServe()){ |
|
282 | 282 | return $this->container->runScope( |
283 | 283 | [DispatcherInterface::class => $dispatcher], |
284 | 284 | static function () use ($dispatcher, $eventDispatcher): mixed { |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | */ |
330 | 330 | protected function fireCallbacks(array &$callbacks): void |
331 | 331 | { |
332 | - if ($callbacks === []) { |
|
332 | + if ($callbacks === []){ |
|
333 | 333 | return; |
334 | 334 | } |
335 | 335 | |
336 | - do { |
|
336 | + do{ |
|
337 | 337 | $this->container->invoke(\current($callbacks)); |
338 | - } while (\next($callbacks)); |
|
338 | + }while (\next($callbacks)); |
|
339 | 339 | |
340 | 340 | $callbacks = []; |
341 | 341 | } |
@@ -115,29 +115,35 @@ discard block |
||
115 | 115 | ): static { |
116 | 116 | $exceptionHandler ??= ExceptionHandler::class; |
117 | 117 | |
118 | - if (\is_string($exceptionHandler)) { |
|
118 | + if (\is_string($exceptionHandler)) |
|
119 | + { |
|
119 | 120 | $exceptionHandler = $container->make($exceptionHandler); |
120 | 121 | } |
121 | 122 | |
122 | - if ($handleErrors) { |
|
123 | + if ($handleErrors) |
|
124 | + { |
|
123 | 125 | $exceptionHandler->register(); |
124 | 126 | } |
125 | 127 | |
126 | - if (!$container->has(InitializerInterface::class)) { |
|
128 | + if (!$container->has(InitializerInterface::class)) |
|
129 | + { |
|
127 | 130 | $container->bind(InitializerInterface::class, Initializer::class); |
128 | 131 | } |
129 | - if (!$container->has(InvokerStrategyInterface::class)) { |
|
132 | + if (!$container->has(InvokerStrategyInterface::class)) |
|
133 | + { |
|
130 | 134 | $container->bind(InvokerStrategyInterface::class, DefaultInvokerStrategy::class); |
131 | 135 | } |
132 | 136 | |
133 | - if ($bootloadManager instanceof Autowire) { |
|
137 | + if ($bootloadManager instanceof Autowire) |
|
138 | + { |
|
134 | 139 | $bootloadManager = $bootloadManager->resolve($container); |
135 | 140 | } |
136 | 141 | $bootloadManager ??= $container->make(StrategyBasedBootloadManager::class); |
137 | 142 | \assert($bootloadManager instanceof BootloadManagerInterface); |
138 | 143 | $container->bind(BootloadManagerInterface::class, $bootloadManager); |
139 | 144 | |
140 | - if (!$container->has(BootloaderRegistryInterface::class)) { |
|
145 | + if (!$container->has(BootloaderRegistryInterface::class)) |
|
146 | + { |
|
141 | 147 | $container->bindSingleton(BootloaderRegistryInterface::class, [self::class, 'initBootloaderRegistry']); |
142 | 148 | } |
143 | 149 | |
@@ -166,7 +172,8 @@ discard block |
||
166 | 172 | $environment ??= new Environment(); |
167 | 173 | $this->container->bindSingleton(EnvironmentInterface::class, $environment); |
168 | 174 | |
169 | - try { |
|
175 | + try |
|
176 | + { |
|
170 | 177 | // will protect any against env overwrite action |
171 | 178 | $this->container->runScope( |
172 | 179 | [EnvironmentInterface::class => $environment], |
@@ -182,7 +189,9 @@ discard block |
||
182 | 189 | $this->fireCallbacks($this->bootstrappedCallbacks); |
183 | 190 | } |
184 | 191 | ); |
185 | - } catch (\Throwable $e) { |
|
192 | + } |
|
193 | + catch (\Throwable $e) |
|
194 | + { |
|
186 | 195 | $this->exceptionHandler->handleGlobalException($e); |
187 | 196 | |
188 | 197 | return null; |
@@ -203,7 +212,8 @@ discard block |
||
203 | 212 | */ |
204 | 213 | public function running(Closure ...$callbacks): void |
205 | 214 | { |
206 | - foreach ($callbacks as $callback) { |
|
215 | + foreach ($callbacks as $callback) |
|
216 | + { |
|
207 | 217 | $this->runningCallbacks[] = $callback; |
208 | 218 | } |
209 | 219 | } |
@@ -218,7 +228,8 @@ discard block |
||
218 | 228 | */ |
219 | 229 | public function booting(Closure ...$callbacks): void |
220 | 230 | { |
221 | - foreach ($callbacks as $callback) { |
|
231 | + foreach ($callbacks as $callback) |
|
232 | + { |
|
222 | 233 | $this->bootingCallbacks[] = $callback; |
223 | 234 | } |
224 | 235 | } |
@@ -233,7 +244,8 @@ discard block |
||
233 | 244 | */ |
234 | 245 | public function booted(Closure ...$callbacks): void |
235 | 246 | { |
236 | - foreach ($callbacks as $callback) { |
|
247 | + foreach ($callbacks as $callback) |
|
248 | + { |
|
237 | 249 | $this->bootedCallbacks[] = $callback; |
238 | 250 | } |
239 | 251 | } |
@@ -249,7 +261,8 @@ discard block |
||
249 | 261 | */ |
250 | 262 | public function bootstrapped(Closure ...$callbacks): void |
251 | 263 | { |
252 | - foreach ($callbacks as $callback) { |
|
264 | + foreach ($callbacks as $callback) |
|
265 | + { |
|
253 | 266 | $this->bootstrappedCallbacks[] = $callback; |
254 | 267 | } |
255 | 268 | } |
@@ -277,8 +290,10 @@ discard block |
||
277 | 290 | $eventDispatcher = $this->getEventDispatcher(); |
278 | 291 | $eventDispatcher?->dispatch(new Serving()); |
279 | 292 | |
280 | - foreach ($this->dispatchers as $dispatcher) { |
|
281 | - if ($dispatcher->canServe()) { |
|
293 | + foreach ($this->dispatchers as $dispatcher) |
|
294 | + { |
|
295 | + if ($dispatcher->canServe()) |
|
296 | + { |
|
282 | 297 | return $this->container->runScope( |
283 | 298 | [DispatcherInterface::class => $dispatcher], |
284 | 299 | static function () use ($dispatcher, $eventDispatcher): mixed { |
@@ -329,11 +344,13 @@ discard block |
||
329 | 344 | */ |
330 | 345 | protected function fireCallbacks(array &$callbacks): void |
331 | 346 | { |
332 | - if ($callbacks === []) { |
|
347 | + if ($callbacks === []) |
|
348 | + { |
|
333 | 349 | return; |
334 | 350 | } |
335 | 351 | |
336 | - do { |
|
352 | + do |
|
353 | + { |
|
337 | 354 | $this->container->invoke(\current($callbacks)); |
338 | 355 | } while (\next($callbacks)); |
339 | 356 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * 1. SimpleBootloader::class, |
17 | 17 | * 2. [SimpleBootloader::class => ['option' => 'value']] |
18 | 18 | */ |
19 | - public function registerSystem(string|array $bootloader): void; |
|
19 | + public function registerSystem(string | array $bootloader): void; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @param TClass|array<TClass, array<string, mixed>> $bootloader |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * 1. SimpleBootloader::class, |
26 | 26 | * 2. [SimpleBootloader::class => ['option' => 'value']] |
27 | 27 | */ |
28 | - public function register(string|array $bootloader): void; |
|
28 | + public function register(string | array $bootloader): void; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @return array<TClass>|array<TClass, array<string, mixed>> |
@@ -16,15 +16,15 @@ discard block |
||
16 | 16 | public function __construct( |
17 | 17 | private array $systemBootloaders = [], |
18 | 18 | private array $bootloaders = [], |
19 | - ) { |
|
19 | + ){ |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
23 | 23 | * @param TClass|array<TClass, array<string, mixed>> $bootloader |
24 | 24 | */ |
25 | - public function registerSystem(string|array $bootloader): void |
|
25 | + public function registerSystem(string | array $bootloader): void |
|
26 | 26 | { |
27 | - if ($this->hasBootloader($bootloader)) { |
|
27 | + if ($this->hasBootloader($bootloader)){ |
|
28 | 28 | return; |
29 | 29 | } |
30 | 30 | |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @param TClass|array<TClass, array<string, mixed>> $bootloader |
39 | 39 | */ |
40 | - public function register(string|array $bootloader): void |
|
40 | + public function register(string | array $bootloader): void |
|
41 | 41 | { |
42 | - if ($this->hasBootloader($bootloader)) { |
|
42 | + if ($this->hasBootloader($bootloader)){ |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * @param TClass|array<TClass, array<string, mixed>> $bootloader |
70 | 70 | */ |
71 | - private function hasBootloader(string|array $bootloader): bool |
|
71 | + private function hasBootloader(string | array $bootloader): bool |
|
72 | 72 | { |
73 | - if (\is_array($bootloader)) { |
|
73 | + if (\is_array($bootloader)){ |
|
74 | 74 | return false; |
75 | 75 | } |
76 | 76 |
@@ -24,7 +24,8 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function registerSystem(string|array $bootloader): void |
26 | 26 | { |
27 | - if ($this->hasBootloader($bootloader)) { |
|
27 | + if ($this->hasBootloader($bootloader)) |
|
28 | + { |
|
28 | 29 | return; |
29 | 30 | } |
30 | 31 | |
@@ -39,7 +40,8 @@ discard block |
||
39 | 40 | */ |
40 | 41 | public function register(string|array $bootloader): void |
41 | 42 | { |
42 | - if ($this->hasBootloader($bootloader)) { |
|
43 | + if ($this->hasBootloader($bootloader)) |
|
44 | + { |
|
43 | 45 | return; |
44 | 46 | } |
45 | 47 | |
@@ -70,7 +72,8 @@ discard block |
||
70 | 72 | */ |
71 | 73 | private function hasBootloader(string|array $bootloader): bool |
72 | 74 | { |
73 | - if (\is_array($bootloader)) { |
|
75 | + if (\is_array($bootloader)) |
|
76 | + { |
|
74 | 77 | return false; |
75 | 78 | } |
76 | 79 |