@@ -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 | |
@@ -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 | |