@@ -36,7 +36,8 @@ discard block |
||
36 | 36 | public function withInterceptors(InterceptorInterface ...$interceptors): self |
37 | 37 | { |
38 | 38 | $clone = clone $this; |
39 | - foreach ($interceptors as $interceptor) { |
|
39 | + foreach ($interceptors as $interceptor) |
|
40 | + { |
|
40 | 41 | $clone->interceptors[] = $interceptor; |
41 | 42 | } |
42 | 43 | |
@@ -55,11 +56,13 @@ discard block |
||
55 | 56 | */ |
56 | 57 | public function handle(CallContext $context): mixed |
57 | 58 | { |
58 | - if ($this->handler === null) { |
|
59 | + if ($this->handler === null) |
|
60 | + { |
|
59 | 61 | throw new InterceptorException('Unable to invoke pipeline without last handler.'); |
60 | 62 | } |
61 | 63 | |
62 | - if (isset($this->interceptors[$this->position])) { |
|
64 | + if (isset($this->interceptors[$this->position])) |
|
65 | + { |
|
63 | 66 | $interceptor = $this->interceptors[$this->position]; |
64 | 67 | |
65 | 68 | $this->dispatcher?->dispatch(new InterceptorCalling(context: $context, interceptor: $interceptor)); |
@@ -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(CallContext $context): mixed |
44 | 46 | { |
45 | 47 | return null; |
@@ -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 |
@@ -36,7 +36,8 @@ |
||
36 | 36 | $pipelineBuilder ??= new CompatiblePipelineBuilder($eventDispatcher); |
37 | 37 | |
38 | 38 | $resolved = []; |
39 | - foreach ($interceptors as $interceptor) { |
|
39 | + foreach ($interceptors as $interceptor) |
|
40 | + { |
|
40 | 41 | $resolved[] = $this->container->get($interceptor); |
41 | 42 | } |
42 | 43 |
@@ -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`', |
@@ -73,11 +73,13 @@ discard block |
||
73 | 73 | $registry = $container->get(QueueRegistry::class); |
74 | 74 | $config = $container->get(QueueConfig::class); |
75 | 75 | |
76 | - foreach ($config->getRegistryHandlers() as $jobType => $handler) { |
|
76 | + foreach ($config->getRegistryHandlers() as $jobType => $handler) |
|
77 | + { |
|
77 | 78 | $registry->setHandler($jobType, $handler); |
78 | 79 | } |
79 | 80 | |
80 | - foreach ($config->getRegistrySerializers() as $jobType => $serializer) { |
|
81 | + foreach ($config->getRegistrySerializers() as $jobType => $serializer) |
|
82 | + { |
|
81 | 83 | $registry->setSerializer($jobType, $serializer); |
82 | 84 | } |
83 | 85 | }); |
@@ -147,10 +149,14 @@ discard block |
||
147 | 149 | $builder ??= new CompatiblePipelineBuilder($dispatcher); |
148 | 150 | |
149 | 151 | $list = []; |
150 | - foreach ($config->getConsumeInterceptors() as $interceptor) { |
|
151 | - if (\is_string($interceptor)) { |
|
152 | + foreach ($config->getConsumeInterceptors() as $interceptor) |
|
153 | + { |
|
154 | + if (\is_string($interceptor)) |
|
155 | + { |
|
152 | 156 | $list[] = $container->get($interceptor); |
153 | - } elseif ($interceptor instanceof Autowire) { |
|
157 | + } |
|
158 | + elseif ($interceptor instanceof Autowire) |
|
159 | + { |
|
154 | 160 | $list[] = $interceptor->resolve($factory); |
155 | 161 | } |
156 | 162 | } |
@@ -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); |
@@ -116,7 +116,8 @@ |
||
116 | 116 | $builder ??= new CompatiblePipelineBuilder($dispatcher); |
117 | 117 | |
118 | 118 | $list = []; |
119 | - foreach ($config->getInterceptors() as $interceptor) { |
|
119 | + foreach ($config->getInterceptors() as $interceptor) |
|
120 | + { |
|
120 | 121 | $list[] = $container->get($interceptor); |
121 | 122 | } |
122 | 123 |
@@ -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 |