@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | private readonly FactoryInterface $factory, |
| 27 | 27 | ?EventDispatcherInterface $dispatcher = null, |
| 28 | 28 | ?PipelineBuilderInterface $builder = null, |
| 29 | - ) { |
|
| 29 | + ){ |
|
| 30 | 30 | $this->builder = $builder ?? new CompatiblePipelineBuilder($dispatcher); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | // Replaces alias with real pipeline name |
| 37 | 37 | $name = $this->config->getAliases()[$name] ?? $name; |
| 38 | 38 | |
| 39 | - if (!isset($this->pipelines[$name])) { |
|
| 39 | + if (!isset($this->pipelines[$name])){ |
|
| 40 | 40 | $this->pipelines[$name] = $this->resolveConnection($name); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -51,18 +51,18 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | $config = $this->config->getConnection($name); |
| 53 | 53 | |
| 54 | - try { |
|
| 54 | + try{ |
|
| 55 | 55 | $driver = $this->factory->make($config['driver'], $config); |
| 56 | 56 | |
| 57 | 57 | $list = []; |
| 58 | - foreach ($this->config->getPushInterceptors() as $interceptor) { |
|
| 58 | + foreach ($this->config->getPushInterceptors() as $interceptor){ |
|
| 59 | 59 | $list[] = \is_string($interceptor) || $interceptor instanceof Autowire |
| 60 | 60 | ? $this->container->get($interceptor) |
| 61 | 61 | : $interceptor; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | return new Queue($this->builder->withInterceptors(...$list)->build(new PushCore($driver))); |
| 65 | - } catch (ContainerException $e) { |
|
| 65 | + }catch (ContainerException $e){ |
|
| 66 | 66 | throw new Exception\NotSupportedDriverException( |
| 67 | 67 | \sprintf( |
| 68 | 68 | 'Driver `%s` is not supported. Connection `%s` cannot be created. Reason: `%s`', |
@@ -36,7 +36,8 @@ discard block |
||
| 36 | 36 | // Replaces alias with real pipeline name |
| 37 | 37 | $name = $this->config->getAliases()[$name] ?? $name; |
| 38 | 38 | |
| 39 | - if (!isset($this->pipelines[$name])) { |
|
| 39 | + if (!isset($this->pipelines[$name])) |
|
| 40 | + { |
|
| 40 | 41 | $this->pipelines[$name] = $this->resolveConnection($name); |
| 41 | 42 | } |
| 42 | 43 | |
@@ -51,18 +52,22 @@ discard block |
||
| 51 | 52 | { |
| 52 | 53 | $config = $this->config->getConnection($name); |
| 53 | 54 | |
| 54 | - try { |
|
| 55 | + try |
|
| 56 | + { |
|
| 55 | 57 | $driver = $this->factory->make($config['driver'], $config); |
| 56 | 58 | |
| 57 | 59 | $list = []; |
| 58 | - foreach ($this->config->getPushInterceptors() as $interceptor) { |
|
| 60 | + foreach ($this->config->getPushInterceptors() as $interceptor) |
|
| 61 | + { |
|
| 59 | 62 | $list[] = \is_string($interceptor) || $interceptor instanceof Autowire |
| 60 | 63 | ? $this->container->get($interceptor) |
| 61 | 64 | : $interceptor; |
| 62 | 65 | } |
| 63 | 66 | |
| 64 | 67 | return new Queue($this->builder->withInterceptors(...$list)->build(new PushCore($driver))); |
| 65 | - } catch (ContainerException $e) { |
|
| 68 | + } |
|
| 69 | + catch (ContainerException $e) |
|
| 70 | + { |
|
| 66 | 71 | throw new Exception\NotSupportedDriverException( |
| 67 | 72 | \sprintf( |
| 68 | 73 | 'Driver `%s` is not supported. Connection `%s` cannot be created. Reason: `%s`', |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | $builder = new CompatiblePipelineBuilder($dispatcher); |
| 33 | 33 | |
| 34 | 34 | $list = []; |
| 35 | - foreach (static::defineInterceptors() as $interceptor) { |
|
| 35 | + foreach (static::defineInterceptors() as $interceptor){ |
|
| 36 | 36 | $list[] = $interceptor instanceof CoreInterceptorInterface || $interceptor instanceof InterceptorInterface |
| 37 | 37 | ? $interceptor |
| 38 | 38 | : $container->get($interceptor); |
@@ -32,7 +32,8 @@ |
||
| 32 | 32 | $builder = new CompatiblePipelineBuilder($dispatcher); |
| 33 | 33 | |
| 34 | 34 | $list = []; |
| 35 | - foreach (static::defineInterceptors() as $interceptor) { |
|
| 35 | + foreach (static::defineInterceptors() as $interceptor) |
|
| 36 | + { |
|
| 36 | 37 | $list[] = $interceptor instanceof CoreInterceptorInterface || $interceptor instanceof InterceptorInterface |
| 37 | 38 | ? $interceptor |
| 38 | 39 | : $container->get($interceptor); |
@@ -13,13 +13,13 @@ |
||
| 13 | 13 | /** |
| 14 | 14 | * @throws ClassNotFoundException |
| 15 | 15 | */ |
| 16 | - public function canInitialize(BootloaderInterface|string $bootloader, ?BootloadConfig $config = null): bool |
|
| 16 | + public function canInitialize(BootloaderInterface | string $bootloader, ?BootloadConfig $config = null): bool |
|
| 17 | 17 | { |
| 18 | - if (!\is_string($bootloader)) { |
|
| 18 | + if (!\is_string($bootloader)){ |
|
| 19 | 19 | return true; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - if (!\class_exists($bootloader)) { |
|
| 22 | + if (!\class_exists($bootloader)){ |
|
| 23 | 23 | throw new ClassNotFoundException(\sprintf('Bootloader class `%s` does not exist.', $bootloader)); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -15,11 +15,13 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function canInitialize(BootloaderInterface|string $bootloader, ?BootloadConfig $config = null): bool |
| 17 | 17 | { |
| 18 | - if (!\is_string($bootloader)) { |
|
| 18 | + if (!\is_string($bootloader)) |
|
| 19 | + { |
|
| 19 | 20 | return true; |
| 20 | 21 | } |
| 21 | 22 | |
| 22 | - if (!\class_exists($bootloader)) { |
|
| 23 | + if (!\class_exists($bootloader)) |
|
| 24 | + { |
|
| 23 | 25 | throw new ClassNotFoundException(\sprintf('Bootloader class `%s` does not exist.', $bootloader)); |
| 24 | 26 | } |
| 25 | 27 | |
@@ -124,7 +124,8 @@ |
||
| 124 | 124 | $reflection = $target->getReflection(); |
| 125 | 125 | self::assertSame($hasReflection, $reflection !== null); |
| 126 | 126 | self::assertNull($target->getObject()); |
| 127 | - if ($hasReflection) { |
|
| 127 | + if ($hasReflection) |
|
| 128 | + { |
|
| 128 | 129 | self::assertInstanceOf(\ReflectionMethod::class, $reflection); |
| 129 | 130 | self::assertSame($action, $reflection->getName()); |
| 130 | 131 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $target = Target::fromReflectionFunction($reflection, ['print_r-path']); |
| 37 | 37 | |
| 38 | 38 | self::assertSame($reflection, $target->getReflection()); |
| 39 | - self::assertSame('print_r-path', (string) $target); |
|
| 39 | + self::assertSame('print_r-path', (string)$target); |
|
| 40 | 40 | self::assertNull($target->getObject()); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $target = Target::fromClosure(\print_r(...), ['print_r-path']); |
| 46 | 46 | |
| 47 | 47 | self::assertNotNull($target->getReflection()); |
| 48 | - self::assertSame('print_r-path', (string) $target); |
|
| 48 | + self::assertSame('print_r-path', (string)$target); |
|
| 49 | 49 | self::assertNull($target->getObject()); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $target = Target::fromClosure($this->{__FUNCTION__}(...), ['print_r-path']); |
| 55 | 55 | |
| 56 | 56 | self::assertNotNull($target->getReflection()); |
| 57 | - self::assertSame('print_r-path', (string) $target); |
|
| 57 | + self::assertSame('print_r-path', (string)$target); |
|
| 58 | 58 | self::assertNull($target->getObject()); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $target = Target::fromReflectionMethod($reflection, self::class); |
| 66 | 66 | |
| 67 | 67 | self::assertSame($reflection, $target->getReflection()); |
| 68 | - self::assertSame(self::class . '->' . __FUNCTION__, (string) $target); |
|
| 68 | + self::assertSame(self::class.'->'.__FUNCTION__, (string)$target); |
|
| 69 | 69 | self::assertNull($target->getObject()); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $target = Target::fromReflectionMethod($reflection, $this); |
| 77 | 77 | |
| 78 | 78 | self::assertSame($reflection, $target->getReflection()); |
| 79 | - self::assertSame(self::class . '->' . __FUNCTION__, (string) $target); |
|
| 79 | + self::assertSame(self::class.'->'.__FUNCTION__, (string)$target); |
|
| 80 | 80 | self::assertNotNull($target->getObject()); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | // Immutability |
| 90 | 90 | self::assertNotSame($target, $target2); |
| 91 | 91 | self::assertSame(['bar', 'baz'], $target2->getPath()); |
| 92 | - self::assertSame('bar.baz', (string) $target2); |
|
| 92 | + self::assertSame('bar.baz', (string)$target2); |
|
| 93 | 93 | // First target is not changed |
| 94 | 94 | self::assertSame(['foo', 'bar', 'baz'], $target->getPath()); |
| 95 | - self::assertSame($str, (string) $target); |
|
| 95 | + self::assertSame($str, (string)$target); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | #[DataProvider('providePathChunks')] |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $target = Target::fromPathString($str, $separator); |
| 103 | 103 | |
| 104 | 104 | self::assertSame($chunks, $target->getPath()); |
| 105 | - self::assertSame($str, (string) $target); |
|
| 105 | + self::assertSame($str, (string)$target); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | #[DataProvider('providePathChunks')] |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $target = Target::fromPathArray($chunks, $separator); |
| 113 | 113 | |
| 114 | 114 | self::assertSame($chunks, $target->getPath()); |
| 115 | - self::assertSame($str, (string) $target); |
|
| 115 | + self::assertSame($str, (string)$target); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | #[DataProvider('providePairs')] |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $reflection = $target->getReflection(); |
| 125 | 125 | self::assertSame($hasReflection, $reflection !== null); |
| 126 | 126 | self::assertNull($target->getObject()); |
| 127 | - if ($hasReflection) { |
|
| 127 | + if ($hasReflection){ |
|
| 128 | 128 | self::assertInstanceOf(\ReflectionMethod::class, $reflection); |
| 129 | 129 | self::assertSame($action, $reflection->getName()); |
| 130 | 130 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $target = Target::fromPathString($str); |
| 149 | 149 | |
| 150 | 150 | self::assertSame(['foo', 'bar', 'baz'], $target->getPath()); |
| 151 | - self::assertSame($str, (string) $target); |
|
| 151 | + self::assertSame($str, (string)$target); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | public function testPrivateConstructor(): void |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | public function testInterceptorCallingEventShouldBeDispatched(): void |
| 21 | 21 | { |
| 22 | 22 | $context = $this->createPathContext(['test', 'test2']); |
| 23 | - $interceptor = new class implements InterceptorInterface { |
|
| 23 | + $interceptor = new class implements InterceptorInterface{ |
|
| 24 | 24 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
| 25 | 25 | { |
| 26 | 26 | return null; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $pipeline = $this->createPipeline(interceptors: [$interceptor], dispatcher: $dispatcher); |
| 40 | 40 | |
| 41 | 41 | $pipeline->withHandler( |
| 42 | - new class implements HandlerInterface { |
|
| 42 | + new class implements HandlerInterface{ |
|
| 43 | 43 | public function handle(CallContextInterface $context): mixed |
| 44 | 44 | { |
| 45 | 45 | return null; |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | private function createPipeline( |
| 127 | 127 | array $interceptors = [], |
| 128 | - HandlerInterface|null $lastHandler = null, |
|
| 129 | - EventDispatcherInterface|null $dispatcher = null, |
|
| 128 | + HandlerInterface | null $lastHandler = null, |
|
| 129 | + EventDispatcherInterface | null $dispatcher = null, |
|
| 130 | 130 | ): InterceptorPipeline { |
| 131 | 131 | $pipeline = new InterceptorPipeline($dispatcher); |
| 132 | 132 | |
@@ -20,7 +20,8 @@ discard block |
||
| 20 | 20 | public function testInterceptorCallingEventShouldBeDispatched(): void |
| 21 | 21 | { |
| 22 | 22 | $context = $this->createPathContext(['test', 'test2']); |
| 23 | - $interceptor = new class implements InterceptorInterface { |
|
| 23 | + $interceptor = new class implements InterceptorInterface |
|
| 24 | + { |
|
| 24 | 25 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
| 25 | 26 | { |
| 26 | 27 | return null; |
@@ -39,7 +40,8 @@ discard block |
||
| 39 | 40 | $pipeline = $this->createPipeline(interceptors: [$interceptor], dispatcher: $dispatcher); |
| 40 | 41 | |
| 41 | 42 | $pipeline->withHandler( |
| 42 | - new class implements HandlerInterface { |
|
| 43 | + new class implements HandlerInterface |
|
| 44 | + { |
|
| 43 | 45 | public function handle(CallContextInterface $context): mixed |
| 44 | 46 | { |
| 45 | 47 | return null; |
@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | public static function pathToReflection(string $controller, string $action): \ReflectionMethod |
| 21 | 21 | { |
| 22 | - try { |
|
| 22 | + try{ |
|
| 23 | 23 | /** @psalm-suppress ArgumentTypeCoercion */ |
| 24 | 24 | $method = new \ReflectionMethod($controller, $action); |
| 25 | - } catch (\ReflectionException $e) { |
|
| 25 | + }catch (\ReflectionException $e){ |
|
| 26 | 26 | throw new TargetCallException( |
| 27 | 27 | \sprintf('Invalid action `%s`->`%s`', $controller, $action), |
| 28 | 28 | TargetCallException::BAD_ACTION, |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public static function validateControllerMethod(\ReflectionMethod $method, mixed $controller = null): void |
| 41 | 41 | { |
| 42 | - if ($method->isStatic() || !$method->isPublic()) { |
|
| 42 | + if ($method->isStatic() || !$method->isPublic()){ |
|
| 43 | 43 | throw new TargetCallException( |
| 44 | 44 | \sprintf( |
| 45 | 45 | 'Invalid action `%s`->`%s`', |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | ); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if ($controller === null) { |
|
| 53 | + if ($controller === null){ |
|
| 54 | 54 | return; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)) { |
|
| 57 | + if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)){ |
|
| 58 | 58 | throw new TargetCallException( |
| 59 | 59 | \sprintf( |
| 60 | 60 | 'Invalid controller. Expected instance of `%s`, got `%s`.', |
@@ -19,10 +19,13 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | public static function pathToReflection(string $controller, string $action): \ReflectionMethod |
| 21 | 21 | { |
| 22 | - try { |
|
| 22 | + try |
|
| 23 | + { |
|
| 23 | 24 | /** @psalm-suppress ArgumentTypeCoercion */ |
| 24 | 25 | $method = new \ReflectionMethod($controller, $action); |
| 25 | - } catch (\ReflectionException $e) { |
|
| 26 | + } |
|
| 27 | + catch (\ReflectionException $e) |
|
| 28 | + { |
|
| 26 | 29 | throw new TargetCallException( |
| 27 | 30 | \sprintf('Invalid action `%s`->`%s`', $controller, $action), |
| 28 | 31 | TargetCallException::BAD_ACTION, |
@@ -39,7 +42,8 @@ discard block |
||
| 39 | 42 | */ |
| 40 | 43 | public static function validateControllerMethod(\ReflectionMethod $method, mixed $controller = null): void |
| 41 | 44 | { |
| 42 | - if ($method->isStatic() || !$method->isPublic()) { |
|
| 45 | + if ($method->isStatic() || !$method->isPublic()) |
|
| 46 | + { |
|
| 43 | 47 | throw new TargetCallException( |
| 44 | 48 | \sprintf( |
| 45 | 49 | 'Invalid action `%s`->`%s`', |
@@ -50,11 +54,13 @@ discard block |
||
| 50 | 54 | ); |
| 51 | 55 | } |
| 52 | 56 | |
| 53 | - if ($controller === null) { |
|
| 57 | + if ($controller === null) |
|
| 58 | + { |
|
| 54 | 59 | return; |
| 55 | 60 | } |
| 56 | 61 | |
| 57 | - if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)) { |
|
| 62 | + if (!\is_object($controller) || !$method->getDeclaringClass()->isInstance($controller)) |
|
| 63 | + { |
|
| 58 | 64 | throw new TargetCallException( |
| 59 | 65 | \sprintf( |
| 60 | 66 | 'Invalid controller. Expected instance of `%s`, got `%s`.', |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | private TargetInterface $target, |
| 16 | 16 | private array $arguments = [], |
| 17 | 17 | array $attributes = [], |
| 18 | - ) { |
|
| 18 | + ){ |
|
| 19 | 19 | $this->attributes = $attributes; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -58,5 +58,5 @@ |
||
| 58 | 58 | * |
| 59 | 59 | * @return callable|array{class-string, non-empty-string}|null |
| 60 | 60 | */ |
| 61 | - public function getCallable(): callable|array|null; |
|
| 61 | + public function getCallable(): callable | array | null; |
|
| 62 | 62 | } |
@@ -31,7 +31,8 @@ |
||
| 31 | 31 | public function withInterceptors(CoreInterceptorInterface|InterceptorInterface ...$interceptors): static |
| 32 | 32 | { |
| 33 | 33 | $clone = clone $this; |
| 34 | - foreach ($interceptors as $interceptor) { |
|
| 34 | + foreach ($interceptors as $interceptor) |
|
| 35 | + { |
|
| 35 | 36 | $clone->pipeline->addInterceptor($interceptor); |
| 36 | 37 | } |
| 37 | 38 | |
@@ -23,17 +23,17 @@ |
||
| 23 | 23 | $this->pipeline = new InterceptorPipeline($dispatcher); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function withInterceptors(CoreInterceptorInterface|InterceptorInterface ...$interceptors): static |
|
| 26 | + public function withInterceptors(CoreInterceptorInterface | InterceptorInterface ...$interceptors): static |
|
| 27 | 27 | { |
| 28 | 28 | $clone = clone $this; |
| 29 | - foreach ($interceptors as $interceptor) { |
|
| 29 | + foreach ($interceptors as $interceptor){ |
|
| 30 | 30 | $clone->pipeline->addInterceptor($interceptor); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | return $clone; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function build(HandlerInterface|CoreInterface $handler): InterceptorPipeline |
|
| 36 | + public function build(HandlerInterface | CoreInterface $handler): InterceptorPipeline |
|
| 37 | 37 | { |
| 38 | 38 | /** @psalm-suppress InvalidArgument */ |
| 39 | 39 | return $handler instanceof HandlerInterface |