@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | public function __construct( |
50 | 50 | private readonly ConfiguratorInterface $configs |
51 | - ) { |
|
51 | + ){ |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function init(): void |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | FinalizerInterface $finalizer, |
73 | 73 | ?EventDispatcherInterface $eventDispatcher = null |
74 | 74 | ): void { |
75 | - if ($eventDispatcher !== null) { |
|
75 | + if ($eventDispatcher !== null){ |
|
76 | 76 | $this->initEventDispatcher(new Core($eventDispatcher), $config, $container, $factory); |
77 | 77 | } |
78 | 78 | |
79 | - foreach ($config->getProcessors() as $processor) { |
|
79 | + foreach ($config->getProcessors() as $processor){ |
|
80 | 80 | $processor = $this->autowire($processor, $container, $factory); |
81 | 81 | |
82 | 82 | \assert($processor instanceof ProcessorInterface); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $registry->process(); |
88 | 88 | }); |
89 | 89 | |
90 | - if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null) { |
|
90 | + if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null){ |
|
91 | 91 | $finalizer->setEventDispatcher($eventDispatcher); |
92 | 92 | } |
93 | 93 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param TInterceptor $interceptor |
97 | 97 | */ |
98 | 98 | public function addInterceptor( |
99 | - string|InterceptorInterface|CoreInterceptorInterface|Container\Autowire $interceptor, |
|
99 | + string | InterceptorInterface | CoreInterceptorInterface | Container\Autowire $interceptor, |
|
100 | 100 | ): void { |
101 | 101 | $this->configs->modify(EventsConfig::CONFIG, new Append('interceptors', null, $interceptor)); |
102 | 102 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | ): void { |
110 | 110 | $builder = new CompatiblePipelineBuilder(); |
111 | 111 | $list = []; |
112 | - foreach ($config->getInterceptors() as $interceptor) { |
|
112 | + foreach ($config->getInterceptors() as $interceptor){ |
|
113 | 113 | $list[] = $this->autowire($interceptor, $container, $factory); |
114 | 114 | } |
115 | 115 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @throws ContainerExceptionInterface |
129 | 129 | */ |
130 | - private function autowire(string|object $id, ContainerInterface $container, FactoryInterface $factory): object |
|
130 | + private function autowire(string | object $id, ContainerInterface $container, FactoryInterface $factory): object |
|
131 | 131 | { |
132 | 132 | return match (true) { |
133 | 133 | \is_string($id) => $container->get($id), |
@@ -72,11 +72,13 @@ discard block |
||
72 | 72 | FinalizerInterface $finalizer, |
73 | 73 | ?EventDispatcherInterface $eventDispatcher = null |
74 | 74 | ): void { |
75 | - if ($eventDispatcher !== null) { |
|
75 | + if ($eventDispatcher !== null) |
|
76 | + { |
|
76 | 77 | $this->initEventDispatcher(new Core($eventDispatcher), $config, $container, $factory); |
77 | 78 | } |
78 | 79 | |
79 | - foreach ($config->getProcessors() as $processor) { |
|
80 | + foreach ($config->getProcessors() as $processor) |
|
81 | + { |
|
80 | 82 | $processor = $this->autowire($processor, $container, $factory); |
81 | 83 | |
82 | 84 | \assert($processor instanceof ProcessorInterface); |
@@ -87,7 +89,8 @@ discard block |
||
87 | 89 | $registry->process(); |
88 | 90 | }); |
89 | 91 | |
90 | - if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null) { |
|
92 | + if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null) |
|
93 | + { |
|
91 | 94 | $finalizer->setEventDispatcher($eventDispatcher); |
92 | 95 | } |
93 | 96 | } |
@@ -109,7 +112,8 @@ discard block |
||
109 | 112 | ): void { |
110 | 113 | $builder = new CompatiblePipelineBuilder(); |
111 | 114 | $list = []; |
112 | - foreach ($config->getInterceptors() as $interceptor) { |
|
115 | + foreach ($config->getInterceptors() as $interceptor) |
|
116 | + { |
|
113 | 117 | $list[] = $this->autowire($interceptor, $container, $factory); |
114 | 118 | } |
115 | 119 |
@@ -14,8 +14,8 @@ |
||
14 | 14 | { |
15 | 15 | private readonly bool $isLegacy; |
16 | 16 | public function __construct( |
17 | - private readonly HandlerInterface|CoreInterface $core, |
|
18 | - ) { |
|
17 | + private readonly HandlerInterface | CoreInterface $core, |
|
18 | + ){ |
|
19 | 19 | $this->isLegacy = !$core instanceof HandlerInterface; |
20 | 20 | } |
21 | 21 |
@@ -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 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $target = Target::fromReflectionMethod($reflection, self::class); |
48 | 48 | |
49 | 49 | self::assertSame($reflection, $target->getReflection()); |
50 | - self::assertSame(self::class . '->' . __FUNCTION__, (string)$target); |
|
50 | + self::assertSame(self::class.'->'.__FUNCTION__, (string)$target); |
|
51 | 51 | self::assertNull($target->getObject()); |
52 | 52 | } |
53 | 53 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $target = Target::fromReflectionMethod($reflection, $this); |
59 | 59 | |
60 | 60 | self::assertSame($reflection, $target->getReflection()); |
61 | - self::assertSame(self::class . '->' . __FUNCTION__, (string)$target); |
|
61 | + self::assertSame(self::class.'->'.__FUNCTION__, (string)$target); |
|
62 | 62 | self::assertNotNull($target->getObject()); |
63 | 63 | } |
64 | 64 | |
@@ -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 | } |
@@ -14,13 +14,13 @@ |
||
14 | 14 | |
15 | 15 | public function __construct( |
16 | 16 | private readonly int $counter, |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
21 | 21 | { |
22 | 22 | $this->result = []; |
23 | - for ($i = 0; $i < $this->counter; ++$i) { |
|
23 | + for ($i = 0; $i < $this->counter; ++$i){ |
|
24 | 24 | $this->result[] = $handler->handle($context); |
25 | 25 | } |
26 | 26 |
@@ -20,7 +20,8 @@ |
||
20 | 20 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
21 | 21 | { |
22 | 22 | $this->result = []; |
23 | - for ($i = 0; $i < $this->counter; ++$i) { |
|
23 | + for ($i = 0; $i < $this->counter; ++$i) |
|
24 | + { |
|
24 | 25 | $this->result[] = $handler->handle($context); |
25 | 26 | } |
26 | 27 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | public function __construct( |
14 | 14 | private string $attribute, |
15 | 15 | private mixed $value, |
16 | - ) { |
|
16 | + ){ |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | public function intercept(CallContextInterface $context, HandlerInterface $handler): mixed |
@@ -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 |