@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | private readonly bool $useAnnotations = false, |
| 30 | 30 | private readonly bool $namedArguments = true, |
| 31 | 31 | private readonly bool $scanParents = false, |
| 32 | - ) { |
|
| 32 | + ){ |
|
| 33 | 33 | parent::__construct($scope); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -45,25 +45,25 @@ discard block |
||
| 45 | 45 | ? (new Factory())->create() |
| 46 | 46 | : new AttributeReader($this->namedArguments ? new NamedArgumentsInstantiator() : null); |
| 47 | 47 | |
| 48 | - if ($attribute === null) { |
|
| 48 | + if ($attribute === null){ |
|
| 49 | 49 | return; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $attribute = $attribute->newInstance(); |
| 53 | 53 | |
| 54 | - foreach ($classes as $class) { |
|
| 54 | + foreach ($classes as $class){ |
|
| 55 | 55 | // If attribute is defined on class level and class has target attribute |
| 56 | 56 | // then we can add it to the list of classes |
| 57 | - if ($attribute->flags & \Attribute::TARGET_CLASS) { |
|
| 58 | - if ($reader->firstClassMetadata($class, $target->getName())) { |
|
| 57 | + if ($attribute->flags & \Attribute::TARGET_CLASS){ |
|
| 58 | + if ($reader->firstClassMetadata($class, $target->getName())){ |
|
| 59 | 59 | yield $class->getName(); |
| 60 | 60 | continue; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - if ($this->scanParents) { |
|
| 63 | + if ($this->scanParents){ |
|
| 64 | 64 | // Interfaces |
| 65 | - foreach ($class->getInterfaces() as $interface) { |
|
| 66 | - if ($reader->firstClassMetadata($interface, $target->getName())) { |
|
| 65 | + foreach ($class->getInterfaces() as $interface){ |
|
| 66 | + if ($reader->firstClassMetadata($interface, $target->getName())){ |
|
| 67 | 67 | yield $class->getName(); |
| 68 | 68 | continue 2; |
| 69 | 69 | } |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | // Parents |
| 73 | 73 | $parent = $class->getParentClass(); |
| 74 | - while ($parent !== false) { |
|
| 75 | - if ($reader->firstClassMetadata($parent, $target->getName())) { |
|
| 74 | + while ($parent !== false){ |
|
| 75 | + if ($reader->firstClassMetadata($parent, $target->getName())){ |
|
| 76 | 76 | yield $class->getName(); |
| 77 | 77 | continue 2; |
| 78 | 78 | } |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | // If attribute is defined on method level and class methods has target attribute |
| 85 | 85 | // then we can add it to the list of classes |
| 86 | - if ($attribute->flags & \Attribute::TARGET_METHOD) { |
|
| 87 | - foreach ($class->getMethods() as $method) { |
|
| 88 | - if ($reader->firstFunctionMetadata($method, $target->getName())) { |
|
| 86 | + if ($attribute->flags & \Attribute::TARGET_METHOD){ |
|
| 87 | + foreach ($class->getMethods() as $method){ |
|
| 88 | + if ($reader->firstFunctionMetadata($method, $target->getName())){ |
|
| 89 | 89 | yield $class->getName(); |
| 90 | 90 | continue 2; |
| 91 | 91 | } |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | // If attribute is defined on property level and class properties has target attribute |
| 96 | 96 | // then we can add it to the list of classes |
| 97 | - if ($attribute->flags & \Attribute::TARGET_PROPERTY) { |
|
| 98 | - foreach ($class->getProperties() as $property) { |
|
| 99 | - if ($reader->firstPropertyMetadata($property, $target->getName())) { |
|
| 97 | + if ($attribute->flags & \Attribute::TARGET_PROPERTY){ |
|
| 98 | + foreach ($class->getProperties() as $property){ |
|
| 99 | + if ($reader->firstPropertyMetadata($property, $target->getName())){ |
|
| 100 | 100 | yield $class->getName(); |
| 101 | 101 | continue 2; |
| 102 | 102 | } |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | // If attribute is defined on constant level and class constants has target attribute |
| 108 | 108 | // then we can add it to the list of classes |
| 109 | - if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT) { |
|
| 110 | - foreach ($class->getReflectionConstants() as $constant) { |
|
| 111 | - if ($reader->firstConstantMetadata($constant, $target->getName())) { |
|
| 109 | + if ($attribute->flags & \Attribute::TARGET_CLASS_CONSTANT){ |
|
| 110 | + foreach ($class->getReflectionConstants() as $constant){ |
|
| 111 | + if ($reader->firstConstantMetadata($constant, $target->getName())){ |
|
| 112 | 112 | yield $class->getName(); |
| 113 | 113 | continue 2; |
| 114 | 114 | } |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | // If attribute is defined on method parameters level and class method parameter has target attribute |
| 120 | 120 | // then we can add it to the list of classes |
| 121 | - if ($attribute->flags & \Attribute::TARGET_PARAMETER) { |
|
| 122 | - foreach ($class->getMethods() as $method) { |
|
| 123 | - foreach ($method->getParameters() as $parameter) { |
|
| 124 | - if ($reader->firstParameterMetadata($parameter, $target->getName())) { |
|
| 121 | + if ($attribute->flags & \Attribute::TARGET_PARAMETER){ |
|
| 122 | + foreach ($class->getMethods() as $method){ |
|
| 123 | + foreach ($method->getParameters() as $parameter){ |
|
| 124 | + if ($reader->firstParameterMetadata($parameter, $target->getName())){ |
|
| 125 | 125 | yield $class->getName(); |
| 126 | 126 | continue 3; |
| 127 | 127 | } |
@@ -20,10 +20,10 @@ |
||
| 20 | 20 | public function testToString(): void |
| 21 | 21 | { |
| 22 | 22 | $attribute = new TargetAttribute('foo'); |
| 23 | - $this->assertSame('3dc18b19eed74479a03c069dec2e8724', (string) $attribute); |
|
| 23 | + $this->assertSame('3dc18b19eed74479a03c069dec2e8724', (string)$attribute); |
|
| 24 | 24 | |
| 25 | 25 | $attribute = new TargetAttribute('foo', 'bar'); |
| 26 | - $this->assertSame('52ec767c53f3898bf6de6f6e88125dc8', (string) $attribute); |
|
| 26 | + $this->assertSame('52ec767c53f3898bf6de6f6e88125dc8', (string)$attribute); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function testFilterAttrWithArgs(): void |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | protected readonly ExceptionHandlerInterface $exceptionHandler, |
| 78 | 78 | protected readonly BootloadManagerInterface $bootloader, |
| 79 | 79 | array $directories |
| 80 | - ) { |
|
| 80 | + ){ |
|
| 81 | 81 | $container->bindSingleton(ExceptionHandlerInterface::class, $exceptionHandler); |
| 82 | 82 | $container->bindSingleton(ExceptionRendererInterface::class, $exceptionHandler); |
| 83 | 83 | $container->bindSingleton(ExceptionReporterInterface::class, $exceptionHandler); |
@@ -114,35 +114,35 @@ discard block |
||
| 114 | 114 | final public static function create( |
| 115 | 115 | array $directories, |
| 116 | 116 | bool $handleErrors = true, |
| 117 | - ExceptionHandlerInterface|string|null $exceptionHandler = null, |
|
| 117 | + ExceptionHandlerInterface | string | null $exceptionHandler = null, |
|
| 118 | 118 | Container $container = new Container(), |
| 119 | - BootloadManagerInterface|Autowire|null $bootloadManager = null |
|
| 119 | + BootloadManagerInterface | Autowire | null $bootloadManager = null |
|
| 120 | 120 | ): static { |
| 121 | 121 | $exceptionHandler ??= ExceptionHandler::class; |
| 122 | 122 | |
| 123 | - if (\is_string($exceptionHandler)) { |
|
| 123 | + if (\is_string($exceptionHandler)){ |
|
| 124 | 124 | $exceptionHandler = $container->make($exceptionHandler); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if ($handleErrors) { |
|
| 127 | + if ($handleErrors){ |
|
| 128 | 128 | $exceptionHandler->register(); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if (!$container->has(InitializerInterface::class)) { |
|
| 131 | + if (!$container->has(InitializerInterface::class)){ |
|
| 132 | 132 | $container->bind(InitializerInterface::class, Initializer::class); |
| 133 | 133 | } |
| 134 | - if (!$container->has(InvokerStrategyInterface::class)) { |
|
| 134 | + if (!$container->has(InvokerStrategyInterface::class)){ |
|
| 135 | 135 | $container->bind(InvokerStrategyInterface::class, DefaultInvokerStrategy::class); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - if ($bootloadManager instanceof Autowire) { |
|
| 138 | + if ($bootloadManager instanceof Autowire){ |
|
| 139 | 139 | $bootloadManager = $bootloadManager->resolve($container); |
| 140 | 140 | } |
| 141 | 141 | $bootloadManager ??= $container->make(StrategyBasedBootloadManager::class); |
| 142 | 142 | \assert($bootloadManager instanceof BootloadManagerInterface); |
| 143 | 143 | $container->bind(BootloadManagerInterface::class, $bootloadManager); |
| 144 | 144 | |
| 145 | - if (!$container->has(BootloaderRegistryInterface::class)) { |
|
| 145 | + if (!$container->has(BootloaderRegistryInterface::class)){ |
|
| 146 | 146 | /** @psalm-suppress InvalidArgument */ |
| 147 | 147 | $container->bindSingleton(BootloaderRegistryInterface::class, [self::class, 'initBootloaderRegistry']); |
| 148 | 148 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $environment ??= new Environment(); |
| 173 | 173 | $this->container->bindSingleton(EnvironmentInterface::class, $environment); |
| 174 | 174 | |
| 175 | - try { |
|
| 175 | + try{ |
|
| 176 | 176 | // will protect any against env overwrite action |
| 177 | 177 | $this->container->runScope( |
| 178 | 178 | [EnvironmentInterface::class => $environment], |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | $this->fireCallbacks($this->bootstrappedCallbacks); |
| 190 | 190 | } |
| 191 | 191 | ); |
| 192 | - } catch (\Throwable $e) { |
|
| 192 | + }catch (\Throwable $e){ |
|
| 193 | 193 | $this->exceptionHandler->handleGlobalException($e); |
| 194 | 194 | |
| 195 | 195 | return null; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | public function running(Closure ...$callbacks): void |
| 212 | 212 | { |
| 213 | - foreach ($callbacks as $callback) { |
|
| 213 | + foreach ($callbacks as $callback){ |
|
| 214 | 214 | $this->runningCallbacks[] = $callback; |
| 215 | 215 | } |
| 216 | 216 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | public function booting(Closure ...$callbacks): void |
| 227 | 227 | { |
| 228 | - foreach ($callbacks as $callback) { |
|
| 228 | + foreach ($callbacks as $callback){ |
|
| 229 | 229 | $this->bootingCallbacks[] = $callback; |
| 230 | 230 | } |
| 231 | 231 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | public function booted(Closure ...$callbacks): void |
| 242 | 242 | { |
| 243 | - foreach ($callbacks as $callback) { |
|
| 243 | + foreach ($callbacks as $callback){ |
|
| 244 | 244 | $this->bootedCallbacks[] = $callback; |
| 245 | 245 | } |
| 246 | 246 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | public function bootstrapped(Closure ...$callbacks): void |
| 258 | 258 | { |
| 259 | - foreach ($callbacks as $callback) { |
|
| 259 | + foreach ($callbacks as $callback){ |
|
| 260 | 260 | $this->bootstrappedCallbacks[] = $callback; |
| 261 | 261 | } |
| 262 | 262 | } |
@@ -268,9 +268,9 @@ discard block |
||
| 268 | 268 | * @param class-string<DispatcherInterface>|DispatcherInterface $dispatcher The class name or instance |
| 269 | 269 | * of the dispatcher. Since v4.0, it will only accept the class name. |
| 270 | 270 | */ |
| 271 | - public function addDispatcher(string|DispatcherInterface $dispatcher): self |
|
| 271 | + public function addDispatcher(string | DispatcherInterface $dispatcher): self |
|
| 272 | 272 | { |
| 273 | - if (\is_object($dispatcher)) { |
|
| 273 | + if (\is_object($dispatcher)){ |
|
| 274 | 274 | $dispatcher = $dispatcher::class; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -292,19 +292,19 @@ discard block |
||
| 292 | 292 | $eventDispatcher?->dispatch(new Serving()); |
| 293 | 293 | |
| 294 | 294 | $serving = $servingScope = null; |
| 295 | - foreach ($this->dispatchers as $dispatcher) { |
|
| 295 | + foreach ($this->dispatchers as $dispatcher){ |
|
| 296 | 296 | $reflection = new \ReflectionClass($dispatcher); |
| 297 | 297 | |
| 298 | 298 | $scope = ($reflection->getAttributes(DispatcherScope::class)[0] ?? null)?->newInstance()->scope; |
| 299 | 299 | $this->container->getBinder($scope)->bind($dispatcher, $dispatcher); |
| 300 | 300 | |
| 301 | - if ($serving === null && $this->canServe($reflection)) { |
|
| 301 | + if ($serving === null && $this->canServe($reflection)){ |
|
| 302 | 302 | $serving = $dispatcher; |
| 303 | 303 | $servingScope = $scope; |
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - if ($serving === null) { |
|
| 307 | + if ($serving === null){ |
|
| 308 | 308 | $eventDispatcher?->dispatch(new DispatcherNotFound()); |
| 309 | 309 | throw new BootException('Unable to locate active dispatcher.'); |
| 310 | 310 | } |
@@ -353,13 +353,13 @@ discard block |
||
| 353 | 353 | */ |
| 354 | 354 | protected function fireCallbacks(array &$callbacks): void |
| 355 | 355 | { |
| 356 | - if ($callbacks === []) { |
|
| 356 | + if ($callbacks === []){ |
|
| 357 | 357 | return; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - do { |
|
| 360 | + do{ |
|
| 361 | 361 | $this->container->invoke(\current($callbacks)); |
| 362 | - } while (\next($callbacks)); |
|
| 362 | + }while (\next($callbacks)); |
|
| 363 | 363 | |
| 364 | 364 | $callbacks = []; |
| 365 | 365 | } |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | */ |
| 400 | 400 | private function canServe(\ReflectionClass $reflection): bool |
| 401 | 401 | { |
| 402 | - if (!$reflection->hasMethod('canServe')) { |
|
| 402 | + if (!$reflection->hasMethod('canServe')){ |
|
| 403 | 403 | throw new BootException('Dispatcher must implement static `canServe` method.'); |
| 404 | 404 | } |
| 405 | 405 | |