@@ -113,22 +113,27 @@ discard block |
||
| 113 | 113 | ): static { |
| 114 | 114 | $exceptionHandler ??= ExceptionHandler::class; |
| 115 | 115 | |
| 116 | - if (\is_string($exceptionHandler)) { |
|
| 116 | + if (\is_string($exceptionHandler)) |
|
| 117 | + { |
|
| 117 | 118 | $exceptionHandler = $container->make($exceptionHandler); |
| 118 | 119 | } |
| 119 | 120 | |
| 120 | - if ($handleErrors) { |
|
| 121 | + if ($handleErrors) |
|
| 122 | + { |
|
| 121 | 123 | $exceptionHandler->register(); |
| 122 | 124 | } |
| 123 | 125 | |
| 124 | - if (!$container->has(InitializerInterface::class)) { |
|
| 126 | + if (!$container->has(InitializerInterface::class)) |
|
| 127 | + { |
|
| 125 | 128 | $container->bind(InitializerInterface::class, Initializer::class); |
| 126 | 129 | } |
| 127 | - if (!$container->has(InvokerStrategyInterface::class)) { |
|
| 130 | + if (!$container->has(InvokerStrategyInterface::class)) |
|
| 131 | + { |
|
| 128 | 132 | $container->bind(InvokerStrategyInterface::class, DefaultInvokerStrategy::class); |
| 129 | 133 | } |
| 130 | 134 | |
| 131 | - if ($bootloadManager instanceof Autowire) { |
|
| 135 | + if ($bootloadManager instanceof Autowire) |
|
| 136 | + { |
|
| 132 | 137 | $bootloadManager = $bootloadManager->resolve($container); |
| 133 | 138 | } |
| 134 | 139 | $bootloadManager ??= $container->make(StrategyBasedBootloadManager::class); |
@@ -160,7 +165,8 @@ discard block |
||
| 160 | 165 | $environment ??= new Environment(); |
| 161 | 166 | $this->container->bindSingleton(EnvironmentInterface::class, $environment); |
| 162 | 167 | |
| 163 | - try { |
|
| 168 | + try |
|
| 169 | + { |
|
| 164 | 170 | // will protect any against env overwrite action |
| 165 | 171 | $this->container->runScope( |
| 166 | 172 | [EnvironmentInterface::class => $environment], |
@@ -174,7 +180,9 @@ discard block |
||
| 174 | 180 | $this->fireCallbacks($this->bootstrappedCallbacks); |
| 175 | 181 | } |
| 176 | 182 | ); |
| 177 | - } catch (\Throwable $e) { |
|
| 183 | + } |
|
| 184 | + catch (\Throwable $e) |
|
| 185 | + { |
|
| 178 | 186 | $this->exceptionHandler->handleGlobalException($e); |
| 179 | 187 | |
| 180 | 188 | return null; |
@@ -195,7 +203,8 @@ discard block |
||
| 195 | 203 | */ |
| 196 | 204 | public function running(Closure ...$callbacks): void |
| 197 | 205 | { |
| 198 | - foreach ($callbacks as $callback) { |
|
| 206 | + foreach ($callbacks as $callback) |
|
| 207 | + { |
|
| 199 | 208 | $this->runningCallbacks[] = $callback; |
| 200 | 209 | } |
| 201 | 210 | } |
@@ -210,7 +219,8 @@ discard block |
||
| 210 | 219 | */ |
| 211 | 220 | public function booting(Closure ...$callbacks): void |
| 212 | 221 | { |
| 213 | - foreach ($callbacks as $callback) { |
|
| 222 | + foreach ($callbacks as $callback) |
|
| 223 | + { |
|
| 214 | 224 | $this->bootingCallbacks[] = $callback; |
| 215 | 225 | } |
| 216 | 226 | } |
@@ -225,7 +235,8 @@ discard block |
||
| 225 | 235 | */ |
| 226 | 236 | public function booted(Closure ...$callbacks): void |
| 227 | 237 | { |
| 228 | - foreach ($callbacks as $callback) { |
|
| 238 | + foreach ($callbacks as $callback) |
|
| 239 | + { |
|
| 229 | 240 | $this->bootedCallbacks[] = $callback; |
| 230 | 241 | } |
| 231 | 242 | } |
@@ -241,7 +252,8 @@ discard block |
||
| 241 | 252 | */ |
| 242 | 253 | public function bootstrapped(Closure ...$callbacks): void |
| 243 | 254 | { |
| 244 | - foreach ($callbacks as $callback) { |
|
| 255 | + foreach ($callbacks as $callback) |
|
| 256 | + { |
|
| 245 | 257 | $this->bootstrappedCallbacks[] = $callback; |
| 246 | 258 | } |
| 247 | 259 | } |
@@ -269,8 +281,10 @@ discard block |
||
| 269 | 281 | $eventDispatcher = $this->getEventDispatcher(); |
| 270 | 282 | $eventDispatcher?->dispatch(new Serving()); |
| 271 | 283 | |
| 272 | - foreach ($this->dispatchers as $dispatcher) { |
|
| 273 | - if ($dispatcher->canServe()) { |
|
| 284 | + foreach ($this->dispatchers as $dispatcher) |
|
| 285 | + { |
|
| 286 | + if ($dispatcher->canServe()) |
|
| 287 | + { |
|
| 274 | 288 | return $this->container->runScope( |
| 275 | 289 | [DispatcherInterface::class => $dispatcher], |
| 276 | 290 | static function () use ($dispatcher, $eventDispatcher): mixed { |
@@ -321,11 +335,13 @@ discard block |
||
| 321 | 335 | */ |
| 322 | 336 | protected function fireCallbacks(array &$callbacks): void |
| 323 | 337 | { |
| 324 | - if ($callbacks === []) { |
|
| 338 | + if ($callbacks === []) |
|
| 339 | + { |
|
| 325 | 340 | return; |
| 326 | 341 | } |
| 327 | 342 | |
| 328 | - do { |
|
| 343 | + do |
|
| 344 | + { |
|
| 329 | 345 | $this->container->invoke(\current($callbacks)); |
| 330 | 346 | } while (\next($callbacks)); |
| 331 | 347 | |
@@ -47,7 +47,8 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | private function initInstantiator(AttributesConfig $config): InstantiatorInterface |
| 49 | 49 | { |
| 50 | - if ($config->isAnnotationsReaderEnabled()) { |
|
| 50 | + if ($config->isAnnotationsReaderEnabled()) |
|
| 51 | + { |
|
| 51 | 52 | return new Facade(); |
| 52 | 53 | } |
| 53 | 54 | |
@@ -62,7 +63,8 @@ discard block |
||
| 62 | 63 | ): ReaderInterface { |
| 63 | 64 | $reader = new AttributeReader($instantiator); |
| 64 | 65 | |
| 65 | - if ($container->has(CacheInterface::class)) { |
|
| 66 | + if ($container->has(CacheInterface::class)) |
|
| 67 | + { |
|
| 66 | 68 | $cache = $container->get(CacheInterface::class); |
| 67 | 69 | \assert($cache instanceof CacheInterface); |
| 68 | 70 | |
@@ -71,8 +73,10 @@ discard block |
||
| 71 | 73 | |
| 72 | 74 | $supportAnnotations = $config->isAnnotationsReaderEnabled(); |
| 73 | 75 | |
| 74 | - if ($supportAnnotations) { |
|
| 75 | - if (!\interface_exists(DoctrineReaderInterface::class)) { |
|
| 76 | + if ($supportAnnotations) |
|
| 77 | + { |
|
| 78 | + if (!\interface_exists(DoctrineReaderInterface::class)) |
|
| 79 | + { |
|
| 76 | 80 | throw new InitializationException( |
| 77 | 81 | 'Doctrine annotations reader is not available, please install "doctrine/annotations" package', |
| 78 | 82 | ); |
@@ -90,7 +90,8 @@ |
||
| 90 | 90 | */ |
| 91 | 91 | public function addScopedDirectory(string $scope, string $directory): void |
| 92 | 92 | { |
| 93 | - if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])) { |
|
| 93 | + if (!isset($this->config->getConfig(TokenizerConfig::CONFIG)['scopes'][$scope])) |
|
| 94 | + { |
|
| 94 | 95 | $this->config->modify( |
| 95 | 96 | TokenizerConfig::CONFIG, |
| 96 | 97 | new Append('scopes', $scope, []), |