@@ -64,7 +64,7 @@ |
||
| 64 | 64 | $config = new EventsConfig([ |
| 65 | 65 | 'interceptors' => [ |
| 66 | 66 | 'bar', |
| 67 | - new class implements CoreInterceptorInterface { |
|
| 67 | + new class implements CoreInterceptorInterface{ |
|
| 68 | 68 | public function process(string $controller, string $action, array $parameters, CoreInterface $core): mixed |
| 69 | 69 | { |
| 70 | 70 | } |
@@ -64,7 +64,8 @@ |
||
| 64 | 64 | $config = new EventsConfig([ |
| 65 | 65 | 'interceptors' => [ |
| 66 | 66 | 'bar', |
| 67 | - new class implements CoreInterceptorInterface { |
|
| 67 | + new class implements CoreInterceptorInterface |
|
| 68 | + { |
|
| 68 | 69 | public function process(string $controller, string $action, array $parameters, CoreInterface $core): mixed |
| 69 | 70 | { |
| 70 | 71 | } |
@@ -13,7 +13,9 @@ |
||
| 13 | 13 | { |
| 14 | 14 | public function testDispatch(): void |
| 15 | 15 | { |
| 16 | - $event = new class() {}; |
|
| 16 | + $event = new class() |
|
| 17 | + { |
|
| 18 | +}; |
|
| 17 | 19 | |
| 18 | 20 | $core = m::mock(CoreInterface::class); |
| 19 | 21 | $core |
@@ -13,7 +13,9 @@ |
||
| 13 | 13 | { |
| 14 | 14 | public function testCallAction(): void |
| 15 | 15 | { |
| 16 | - $event = new class() {}; |
|
| 16 | + $event = new class() |
|
| 17 | + { |
|
| 18 | +}; |
|
| 17 | 19 | |
| 18 | 20 | $dispatcher = m::mock(EventDispatcherInterface::class); |
| 19 | 21 | $dispatcher |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | { |
| 12 | 12 | public function __construct( |
| 13 | 13 | private readonly CoreInterface $core |
| 14 | - ) { |
|
| 14 | + ){ |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public function dispatch(object $event): object |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | { |
| 15 | 15 | public function __construct( |
| 16 | 16 | private readonly EventDispatcherInterface $dispatcher |
| 17 | - ) { |
|
| 17 | + ){ |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | public function __construct( |
| 48 | 48 | private readonly ConfiguratorInterface $configs |
| 49 | - ) { |
|
| 49 | + ){ |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function init(): void |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | FinalizerInterface $finalizer, |
| 71 | 71 | ?EventDispatcherInterface $eventDispatcher = null |
| 72 | 72 | ): void { |
| 73 | - if ($eventDispatcher !== null) { |
|
| 73 | + if ($eventDispatcher !== null){ |
|
| 74 | 74 | $this->initEventDispatcher(new Core($eventDispatcher), $config, $container, $factory); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - foreach ($config->getProcessors() as $processor) { |
|
| 77 | + foreach ($config->getProcessors() as $processor){ |
|
| 78 | 78 | $processor = $this->autowire($processor, $container, $factory); |
| 79 | 79 | |
| 80 | 80 | \assert($processor instanceof ProcessorInterface); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $registry->process(); |
| 86 | 86 | }); |
| 87 | 87 | |
| 88 | - if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null) { |
|
| 88 | + if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null){ |
|
| 89 | 89 | $finalizer->setEventDispatcher($eventDispatcher); |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | /** |
| 94 | 94 | * @param TInterceptor $interceptor |
| 95 | 95 | */ |
| 96 | - public function addInterceptor(string|CoreInterceptorInterface|Container\Autowire $interceptor): void |
|
| 96 | + public function addInterceptor(string | CoreInterceptorInterface | Container\Autowire $interceptor): void |
|
| 97 | 97 | { |
| 98 | 98 | $this->configs->modify(EventsConfig::CONFIG, new Append('interceptors', null, $interceptor)); |
| 99 | 99 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | ): void { |
| 107 | 107 | $core = new InterceptableCore($core); |
| 108 | 108 | |
| 109 | - foreach ($config->getInterceptors() as $interceptor) { |
|
| 109 | + foreach ($config->getInterceptors() as $interceptor){ |
|
| 110 | 110 | $interceptor = $this->autowire($interceptor, $container, $factory); |
| 111 | 111 | |
| 112 | 112 | \assert($interceptor instanceof CoreInterceptorInterface); |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | $container->bindSingleton(EventDispatcherInterface::class, new EventDispatcher($core)); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - private function autowire(string|object $id, ContainerInterface $container, FactoryInterface $factory): object |
|
| 119 | + private function autowire(string | object $id, ContainerInterface $container, FactoryInterface $factory): object |
|
| 120 | 120 | { |
| 121 | - if (\is_string($id)) { |
|
| 121 | + if (\is_string($id)){ |
|
| 122 | 122 | $id = $container->get($id); |
| 123 | - } elseif ($id instanceof Autowire) { |
|
| 123 | + } elseif ($id instanceof Autowire){ |
|
| 124 | 124 | $id = $id->resolve($factory); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -70,11 +70,13 @@ discard block |
||
| 70 | 70 | FinalizerInterface $finalizer, |
| 71 | 71 | ?EventDispatcherInterface $eventDispatcher = null |
| 72 | 72 | ): void { |
| 73 | - if ($eventDispatcher !== null) { |
|
| 73 | + if ($eventDispatcher !== null) |
|
| 74 | + { |
|
| 74 | 75 | $this->initEventDispatcher(new Core($eventDispatcher), $config, $container, $factory); |
| 75 | 76 | } |
| 76 | 77 | |
| 77 | - foreach ($config->getProcessors() as $processor) { |
|
| 78 | + foreach ($config->getProcessors() as $processor) |
|
| 79 | + { |
|
| 78 | 80 | $processor = $this->autowire($processor, $container, $factory); |
| 79 | 81 | |
| 80 | 82 | \assert($processor instanceof ProcessorInterface); |
@@ -85,7 +87,8 @@ discard block |
||
| 85 | 87 | $registry->process(); |
| 86 | 88 | }); |
| 87 | 89 | |
| 88 | - if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null) { |
|
| 90 | + if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null) |
|
| 91 | + { |
|
| 89 | 92 | $finalizer->setEventDispatcher($eventDispatcher); |
| 90 | 93 | } |
| 91 | 94 | } |
@@ -106,7 +109,8 @@ discard block |
||
| 106 | 109 | ): void { |
| 107 | 110 | $core = new InterceptableCore($core); |
| 108 | 111 | |
| 109 | - foreach ($config->getInterceptors() as $interceptor) { |
|
| 112 | + foreach ($config->getInterceptors() as $interceptor) |
|
| 113 | + { |
|
| 110 | 114 | $interceptor = $this->autowire($interceptor, $container, $factory); |
| 111 | 115 | |
| 112 | 116 | \assert($interceptor instanceof CoreInterceptorInterface); |
@@ -118,9 +122,12 @@ discard block |
||
| 118 | 122 | |
| 119 | 123 | private function autowire(string|object $id, ContainerInterface $container, FactoryInterface $factory): object |
| 120 | 124 | { |
| 121 | - if (\is_string($id)) { |
|
| 125 | + if (\is_string($id)) |
|
| 126 | + { |
|
| 122 | 127 | $id = $container->get($id); |
| 123 | - } elseif ($id instanceof Autowire) { |
|
| 128 | + } |
|
| 129 | + elseif ($id instanceof Autowire) |
|
| 130 | + { |
|
| 124 | 131 | $id = $id->resolve($factory); |
| 125 | 132 | } |
| 126 | 133 | |