| @@ -61,7 +61,7 @@ discard block | ||
| 61 | 61 | protected readonly ExceptionHandlerInterface $exceptionHandler, | 
| 62 | 62 | protected readonly BootloadManagerInterface $bootloader, | 
| 63 | 63 | array $directories | 
| 64 | -    ) { | |
| 64 | +    ){ | |
| 65 | 65 | $container->bindSingleton(ExceptionHandlerInterface::class, $exceptionHandler); | 
| 66 | 66 | $container->bindSingleton(ExceptionRendererInterface::class, $exceptionHandler); | 
| 67 | 67 | $container->bindSingleton(ExceptionReporterInterface::class, $exceptionHandler); | 
| @@ -100,21 +100,21 @@ discard block | ||
| 100 | 100 | final public static function create( | 
| 101 | 101 | array $directories, | 
| 102 | 102 | bool $handleErrors = true, | 
| 103 | - ExceptionHandlerInterface|string|null $exceptionHandler = null, | |
| 103 | + ExceptionHandlerInterface | string | null $exceptionHandler = null, | |
| 104 | 104 | Container $container = new Container(), | 
| 105 | 105 | ?BootloadManagerInterface $bootloadManager = null | 
| 106 | 106 |      ): static { | 
| 107 | 107 | $exceptionHandler ??= ExceptionHandler::class; | 
| 108 | 108 | |
| 109 | -        if (\is_string($exceptionHandler)) { | |
| 109 | +        if (\is_string($exceptionHandler)){ | |
| 110 | 110 | $exceptionHandler = $container->make($exceptionHandler); | 
| 111 | 111 | } | 
| 112 | 112 | |
| 113 | -        if ($handleErrors) { | |
| 113 | +        if ($handleErrors){ | |
| 114 | 114 | $exceptionHandler->register(); | 
| 115 | 115 | } | 
| 116 | 116 | |
| 117 | -        if (!$container->has(InitializerInterface::class)) { | |
| 117 | +        if (!$container->has(InitializerInterface::class)){ | |
| 118 | 118 | $container->bind(InitializerInterface::class, Initializer::class); | 
| 119 | 119 | } | 
| 120 | 120 | |
| @@ -149,7 +149,7 @@ discard block | ||
| 149 | 149 | |
| 150 | 150 | $this->fireCallbacks($this->runningCallbacks); | 
| 151 | 151 | |
| 152 | -        try { | |
| 152 | +        try{ | |
| 153 | 153 | // will protect any against env overwrite action | 
| 154 | 154 | $this->container->runScope( | 
| 155 | 155 | [EnvironmentInterface::class => $environment], | 
| @@ -160,7 +160,7 @@ discard block | ||
| 160 | 160 | $this->fireCallbacks($this->bootstrappedCallbacks); | 
| 161 | 161 | } | 
| 162 | 162 | ); | 
| 163 | -        } catch (\Throwable $e) { | |
| 163 | +        }catch (\Throwable $e){ | |
| 164 | 164 | $this->exceptionHandler->handleGlobalException($e); | 
| 165 | 165 | |
| 166 | 166 | return null; | 
| @@ -181,7 +181,7 @@ discard block | ||
| 181 | 181 | */ | 
| 182 | 182 | public function running(Closure ...$callbacks): void | 
| 183 | 183 |      { | 
| 184 | -        foreach ($callbacks as $callback) { | |
| 184 | +        foreach ($callbacks as $callback){ | |
| 185 | 185 | $this->runningCallbacks[] = $callback; | 
| 186 | 186 | } | 
| 187 | 187 | } | 
| @@ -196,7 +196,7 @@ discard block | ||
| 196 | 196 | */ | 
| 197 | 197 | public function booting(Closure ...$callbacks): void | 
| 198 | 198 |      { | 
| 199 | -        foreach ($callbacks as $callback) { | |
| 199 | +        foreach ($callbacks as $callback){ | |
| 200 | 200 | $this->bootingCallbacks[] = $callback; | 
| 201 | 201 | } | 
| 202 | 202 | } | 
| @@ -211,7 +211,7 @@ discard block | ||
| 211 | 211 | */ | 
| 212 | 212 | public function booted(Closure ...$callbacks): void | 
| 213 | 213 |      { | 
| 214 | -        foreach ($callbacks as $callback) { | |
| 214 | +        foreach ($callbacks as $callback){ | |
| 215 | 215 | $this->bootedCallbacks[] = $callback; | 
| 216 | 216 | } | 
| 217 | 217 | } | 
| @@ -227,7 +227,7 @@ discard block | ||
| 227 | 227 | */ | 
| 228 | 228 | public function bootstrapped(Closure ...$callbacks): void | 
| 229 | 229 |      { | 
| 230 | -        foreach ($callbacks as $callback) { | |
| 230 | +        foreach ($callbacks as $callback){ | |
| 231 | 231 | $this->bootstrappedCallbacks[] = $callback; | 
| 232 | 232 | } | 
| 233 | 233 | } | 
| @@ -255,8 +255,8 @@ discard block | ||
| 255 | 255 | $eventDispatcher = $this->getEventDispatcher(); | 
| 256 | 256 | $eventDispatcher?->dispatch(new Serving()); | 
| 257 | 257 | |
| 258 | -        foreach ($this->dispatchers as $dispatcher) { | |
| 259 | -            if ($dispatcher->canServe()) { | |
| 258 | +        foreach ($this->dispatchers as $dispatcher){ | |
| 259 | +            if ($dispatcher->canServe()){ | |
| 260 | 260 | return $this->container->runScope( | 
| 261 | 261 | [DispatcherInterface::class => $dispatcher], | 
| 262 | 262 |                      static function () use ($dispatcher, $eventDispatcher): mixed { | 
| @@ -297,13 +297,13 @@ discard block | ||
| 297 | 297 | */ | 
| 298 | 298 | protected function fireCallbacks(array &$callbacks): void | 
| 299 | 299 |      { | 
| 300 | -        if ($callbacks === []) { | |
| 300 | +        if ($callbacks === []){ | |
| 301 | 301 | return; | 
| 302 | 302 | } | 
| 303 | 303 | |
| 304 | -        do { | |
| 304 | +        do{ | |
| 305 | 305 | $this->container->invoke(\current($callbacks)); | 
| 306 | - } while (\next($callbacks)); | |
| 306 | + }while (\next($callbacks)); | |
| 307 | 307 | |
| 308 | 308 | $callbacks = []; | 
| 309 | 309 | } | 
| @@ -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 | } | 
| @@ -23,7 +23,7 @@ discard block | ||
| 23 | 23 | private readonly InvokerInterface $invoker, | 
| 24 | 24 | private readonly ResolverInterface $resolver, | 
| 25 | 25 | private readonly InitializerInterface $initializer | 
| 26 | -    ) { | |
| 26 | +    ){ | |
| 27 | 27 | } | 
| 28 | 28 | |
| 29 | 29 | public function getClasses(): array | 
| @@ -52,13 +52,13 @@ discard block | ||
| 52 | 52 |      { | 
| 53 | 53 | $bootloaders = \iterator_to_array($this->initializer->init($classes)); | 
| 54 | 54 | |
| 55 | -        foreach ($bootloaders as $data) { | |
| 55 | +        foreach ($bootloaders as $data){ | |
| 56 | 56 | $this->invokeBootloader($data['bootloader'], Methods::INIT, $data['options']); | 
| 57 | 57 | } | 
| 58 | 58 | |
| 59 | 59 | $this->fireCallbacks($bootingCallbacks); | 
| 60 | 60 | |
| 61 | -        foreach ($bootloaders as $data) { | |
| 61 | +        foreach ($bootloaders as $data){ | |
| 62 | 62 | $this->invokeBootloader($data['bootloader'], Methods::BOOT, $data['options']); | 
| 63 | 63 | } | 
| 64 | 64 | |
| @@ -68,14 +68,14 @@ discard block | ||
| 68 | 68 | private function invokeBootloader(BootloaderInterface $bootloader, Methods $method, array $options): void | 
| 69 | 69 |      { | 
| 70 | 70 | $refl = new \ReflectionClass($bootloader); | 
| 71 | -        if (!$refl->hasMethod($method->value)) { | |
| 71 | +        if (!$refl->hasMethod($method->value)){ | |
| 72 | 72 | return; | 
| 73 | 73 | } | 
| 74 | 74 | |
| 75 | 75 | $method = $refl->getMethod($method->value); | 
| 76 | 76 | |
| 77 | 77 | $args = $this->resolver->resolveArguments($method); | 
| 78 | -        if (!isset($args['boot'])) { | |
| 78 | +        if (!isset($args['boot'])){ | |
| 79 | 79 | $args['boot'] = $options; | 
| 80 | 80 | } | 
| 81 | 81 | |
| @@ -87,7 +87,7 @@ discard block | ||
| 87 | 87 | */ | 
| 88 | 88 | private function fireCallbacks(array $callbacks): void | 
| 89 | 89 |      { | 
| 90 | -        foreach ($callbacks as $callback) { | |
| 90 | +        foreach ($callbacks as $callback){ | |
| 91 | 91 | $this->invoker->invoke($callback); | 
| 92 | 92 | } | 
| 93 | 93 | } |