@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | public function __construct( |
22 | 22 | private readonly QueueInterface $connection, |
23 | - ) { |
|
23 | + ){ |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -31,14 +31,14 @@ discard block |
||
31 | 31 | string $action, |
32 | 32 | array $parameters = ['options' => null, 'payload' => []], |
33 | 33 | ): string { |
34 | - if ($parameters['options'] === null) { |
|
34 | + if ($parameters['options'] === null){ |
|
35 | 35 | $parameters['options'] = new Options(); |
36 | 36 | } |
37 | 37 | |
38 | 38 | $tracer = $this->getTracer(); |
39 | 39 | |
40 | - if (\method_exists($parameters['options'], 'withHeader')) { |
|
41 | - foreach ($tracer->getContext() as $key => $data) { |
|
40 | + if (\method_exists($parameters['options'], 'withHeader')){ |
|
41 | + foreach ($tracer->getContext() as $key => $data){ |
|
42 | 42 | $parameters['options'] = $parameters['options']->withHeader($key, $data); |
43 | 43 | } |
44 | 44 | } |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | |
59 | 59 | private function getTracer(): TracerInterface |
60 | 60 | { |
61 | - try { |
|
61 | + try{ |
|
62 | 62 | return ContainerScope::getContainer()->get(TracerInterface::class); |
63 | - } catch (\Throwable $e) { |
|
63 | + }catch (\Throwable $e){ |
|
64 | 64 | return new NullTracer(); |
65 | 65 | } |
66 | 66 | } |
@@ -31,14 +31,17 @@ discard block |
||
31 | 31 | string $action, |
32 | 32 | array $parameters = ['options' => null, 'payload' => []], |
33 | 33 | ): string { |
34 | - if ($parameters['options'] === null) { |
|
34 | + if ($parameters['options'] === null) |
|
35 | + { |
|
35 | 36 | $parameters['options'] = new Options(); |
36 | 37 | } |
37 | 38 | |
38 | 39 | $tracer = $this->getTracer(); |
39 | 40 | |
40 | - if (\method_exists($parameters['options'], 'withHeader')) { |
|
41 | - foreach ($tracer->getContext() as $key => $data) { |
|
41 | + if (\method_exists($parameters['options'], 'withHeader')) |
|
42 | + { |
|
43 | + foreach ($tracer->getContext() as $key => $data) |
|
44 | + { |
|
42 | 45 | $parameters['options'] = $parameters['options']->withHeader($key, $data); |
43 | 46 | } |
44 | 47 | } |
@@ -58,9 +61,12 @@ discard block |
||
58 | 61 | |
59 | 62 | private function getTracer(): TracerInterface |
60 | 63 | { |
61 | - try { |
|
64 | + try |
|
65 | + { |
|
62 | 66 | return ContainerScope::getContainer()->get(TracerInterface::class); |
63 | - } catch (\Throwable $e) { |
|
67 | + } |
|
68 | + catch (\Throwable $e) |
|
69 | + { |
|
64 | 70 | return new NullTracer(); |
65 | 71 | } |
66 | 72 | } |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | public const DEFAULT_ROOT_SCOPE_NAME = 'root'; |
50 | 50 | |
51 | 51 | private Internal\State $state; |
52 | - private ResolverInterface|Internal\Resolver $resolver; |
|
53 | - private FactoryInterface|Internal\Factory $factory; |
|
54 | - private ContainerInterface|Internal\Container $container; |
|
55 | - private BinderInterface|Internal\Binder $binder; |
|
56 | - private InvokerInterface|Internal\Invoker $invoker; |
|
52 | + private ResolverInterface | Internal\Resolver $resolver; |
|
53 | + private FactoryInterface | Internal\Factory $factory; |
|
54 | + private ContainerInterface | Internal\Container $container; |
|
55 | + private BinderInterface | Internal\Binder $binder; |
|
56 | + private InvokerInterface | Internal\Invoker $invoker; |
|
57 | 57 | private Internal\Scope $scope; |
58 | 58 | |
59 | 59 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public function __construct( |
63 | 63 | private Config $config = new Config(), |
64 | 64 | ?string $scopeName = self::DEFAULT_ROOT_SCOPE_NAME, |
65 | - ) { |
|
65 | + ){ |
|
66 | 66 | $this->initServices($this, $scopeName); |
67 | 67 | |
68 | 68 | /** @psalm-suppress RedundantPropertyInitializationCheck */ |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @throws ContainerException |
139 | 139 | * @throws \Throwable |
140 | 140 | */ |
141 | - public function get(string|Autowire $id, string $context = null): mixed |
|
141 | + public function get(string | Autowire $id, string $context = null): mixed |
|
142 | 142 | { |
143 | 143 | /** @psalm-suppress TooManyArguments */ |
144 | 144 | return $this->container->get($id, $context); |
@@ -166,16 +166,16 @@ discard block |
||
166 | 166 | $binds = &$this->state->bindings; |
167 | 167 | $singletons = &$this->state->singletons; |
168 | 168 | $cleanup = $previous = $prevSin = []; |
169 | - foreach ($bindings as $alias => $resolver) { |
|
169 | + foreach ($bindings as $alias => $resolver){ |
|
170 | 170 | // Store previous bindings |
171 | - if (isset($binds[$alias])) { |
|
171 | + if (isset($binds[$alias])){ |
|
172 | 172 | $previous[$alias] = $binds[$alias]; |
173 | - } else { |
|
173 | + }else{ |
|
174 | 174 | // Store bindings to be removed |
175 | 175 | $cleanup[] = $alias; |
176 | 176 | } |
177 | 177 | // Store previous singletons |
178 | - if (isset($singletons[$alias])) { |
|
178 | + if (isset($singletons[$alias])){ |
|
179 | 179 | $prevSin[$alias] = $singletons[$alias]; |
180 | 180 | unset($singletons[$alias]); |
181 | 181 | } |
@@ -183,21 +183,21 @@ discard block |
||
183 | 183 | $this->binder->bind($alias, $resolver); |
184 | 184 | } |
185 | 185 | |
186 | - try { |
|
186 | + try{ |
|
187 | 187 | return ContainerScope::getContainer() !== $this |
188 | 188 | ? ContainerScope::runScope($this, $scope) |
189 | 189 | : $scope($this); |
190 | - } finally { |
|
190 | + }finally{ |
|
191 | 191 | // Remove new bindings |
192 | - foreach ($cleanup as $alias) { |
|
192 | + foreach ($cleanup as $alias){ |
|
193 | 193 | unset($binds[$alias], $singletons[$alias]); |
194 | 194 | } |
195 | 195 | // Restore previous bindings |
196 | - foreach ($previous as $alias => $resolver) { |
|
196 | + foreach ($previous as $alias => $resolver){ |
|
197 | 197 | $binds[$alias] = $resolver; |
198 | 198 | } |
199 | 199 | // Restore singletons |
200 | - foreach ($prevSin as $alias => $instance) { |
|
200 | + foreach ($prevSin as $alias => $instance){ |
|
201 | 201 | $singletons[$alias] = $instance; |
202 | 202 | } |
203 | 203 | } |
@@ -211,32 +211,32 @@ discard block |
||
211 | 211 | // Open scope |
212 | 212 | $container = new self($this->config, $name); |
213 | 213 | |
214 | - try { |
|
214 | + try{ |
|
215 | 215 | // Configure scope |
216 | 216 | $container->scope->setParent($this, $this->scope); |
217 | 217 | |
218 | 218 | // Add specific bindings |
219 | - foreach ($bindings as $alias => $resolver) { |
|
219 | + foreach ($bindings as $alias => $resolver){ |
|
220 | 220 | $container->binder->bind($alias, $resolver); |
221 | 221 | } |
222 | 222 | |
223 | 223 | return ContainerScope::runScope( |
224 | 224 | $container, |
225 | 225 | static function (self $container) use ($autowire, $closure): mixed { |
226 | - try { |
|
226 | + try{ |
|
227 | 227 | return $autowire |
228 | 228 | ? $container->invoke($closure) |
229 | 229 | : $closure($container); |
230 | - } finally { |
|
230 | + }finally{ |
|
231 | 231 | $container->closeScope(); |
232 | 232 | } |
233 | 233 | } |
234 | 234 | ); |
235 | - } finally { |
|
235 | + }finally{ |
|
236 | 236 | // Check the container has not been leaked |
237 | 237 | $link = \WeakReference::create($container); |
238 | 238 | unset($container); |
239 | - if ($link->get() !== null) { |
|
239 | + if ($link->get() !== null){ |
|
240 | 240 | throw new ScopeContainerLeakedException($name, $this->scope->getParentScopeNames()); |
241 | 241 | } |
242 | 242 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @psalm-param TResolver $resolver |
270 | 270 | */ |
271 | - public function bindSingleton(string $alias, string|array|callable|object $resolver): void |
|
271 | + public function bindSingleton(string $alias, string | array | callable | object $resolver): void |
|
272 | 272 | { |
273 | 273 | $this->binder->bindSingleton($alias, $resolver); |
274 | 274 | } |
@@ -335,8 +335,8 @@ discard block |
||
335 | 335 | ]); |
336 | 336 | |
337 | 337 | // Create container services |
338 | - foreach ($container->config as $property => $class) { |
|
339 | - if (\property_exists($container, $property)) { |
|
338 | + foreach ($container->config as $property => $class){ |
|
339 | + if (\property_exists($container, $property)){ |
|
340 | 340 | $container->$property = $constructor->get($property, $class); |
341 | 341 | } |
342 | 342 | } |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | private function closeScope(): void |
351 | 351 | { |
352 | 352 | /** @psalm-suppress RedundantPropertyInitializationCheck */ |
353 | - if (!isset($this->scope)) { |
|
353 | + if (!isset($this->scope)){ |
|
354 | 354 | $this->destruct(); |
355 | 355 | return; |
356 | 356 | } |
@@ -359,10 +359,10 @@ discard block |
||
359 | 359 | |
360 | 360 | // Run finalizers |
361 | 361 | $errors = []; |
362 | - foreach ($this->state->finalizers as $finalizer) { |
|
363 | - try { |
|
362 | + foreach ($this->state->finalizers as $finalizer){ |
|
363 | + try{ |
|
364 | 364 | $this->invoker->invoke($finalizer); |
365 | - } catch (\Throwable $e) { |
|
365 | + }catch (\Throwable $e){ |
|
366 | 366 | $errors[] = $e; |
367 | 367 | } |
368 | 368 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | $this->destruct(); |
372 | 372 | |
373 | 373 | // Throw collected errors |
374 | - if ($errors !== []) { |
|
374 | + if ($errors !== []){ |
|
375 | 375 | throw new FinalizersException($scopeName, $errors); |
376 | 376 | } |
377 | 377 | } |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | { |
14 | 14 | public const INJECTOR = EnumLocatorInjector::class; |
15 | 15 | |
16 | - public function getEnums(object|string|null $target = null): array |
|
16 | + public function getEnums(object | string | null $target = null): array |
|
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)){ |
|
19 | 19 | $target = new \ReflectionClass($target); |
20 | 20 | } |
21 | 21 | |
22 | 22 | $result = []; |
23 | - foreach ($this->availableEnums() as $enum) { |
|
24 | - try { |
|
23 | + foreach ($this->availableEnums() as $enum){ |
|
24 | + try{ |
|
25 | 25 | $reflection = $this->enumReflection($enum); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
26 | + }catch (LocatorException $e){ |
|
27 | + if ($this->debug){ |
|
28 | 28 | throw $e; |
29 | 29 | } |
30 | 30 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | continue; |
33 | 33 | } |
34 | 34 | |
35 | - if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) { |
|
35 | + if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()){ |
|
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $enums = []; |
53 | 53 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
54 | + foreach ($this->availableReflections() as $reflection){ |
|
55 | 55 | $enums = \array_merge($enums, $reflection->getEnums()); |
56 | 56 | } |
57 | 57 | |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | */ |
66 | 66 | protected function isTargeted(\ReflectionEnum $enum, \ReflectionClass $target = null): bool |
67 | 67 | { |
68 | - if ($target === null) { |
|
68 | + if ($target === null){ |
|
69 | 69 | return true; |
70 | 70 | } |
71 | 71 | |
72 | - if (!$target->isTrait()) { |
|
72 | + if (!$target->isTrait()){ |
|
73 | 73 | //Target is interface or class |
74 | 74 | /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */ |
75 | 75 | return $enum->isSubclassOf($target) || $enum->getName() === $target->getName(); |
@@ -15,16 +15,22 @@ discard block |
||
15 | 15 | |
16 | 16 | public function getEnums(object|string|null $target = null): array |
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)) |
|
19 | + { |
|
19 | 20 | $target = new \ReflectionClass($target); |
20 | 21 | } |
21 | 22 | |
22 | 23 | $result = []; |
23 | - foreach ($this->availableEnums() as $enum) { |
|
24 | - try { |
|
24 | + foreach ($this->availableEnums() as $enum) |
|
25 | + { |
|
26 | + try |
|
27 | + { |
|
25 | 28 | $reflection = $this->enumReflection($enum); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
29 | + } |
|
30 | + catch (LocatorException $e) |
|
31 | + { |
|
32 | + if ($this->debug) |
|
33 | + { |
|
28 | 34 | throw $e; |
29 | 35 | } |
30 | 36 | |
@@ -32,7 +38,8 @@ discard block |
||
32 | 38 | continue; |
33 | 39 | } |
34 | 40 | |
35 | - if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) { |
|
41 | + if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) |
|
42 | + { |
|
36 | 43 | continue; |
37 | 44 | } |
38 | 45 | |
@@ -51,7 +58,8 @@ discard block |
||
51 | 58 | { |
52 | 59 | $enums = []; |
53 | 60 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
61 | + foreach ($this->availableReflections() as $reflection) |
|
62 | + { |
|
55 | 63 | $enums = \array_merge($enums, $reflection->getEnums()); |
56 | 64 | } |
57 | 65 | |
@@ -65,11 +73,13 @@ discard block |
||
65 | 73 | */ |
66 | 74 | protected function isTargeted(\ReflectionEnum $enum, \ReflectionClass $target = null): bool |
67 | 75 | { |
68 | - if ($target === null) { |
|
76 | + if ($target === null) |
|
77 | + { |
|
69 | 78 | return true; |
70 | 79 | } |
71 | 80 | |
72 | - if (!$target->isTrait()) { |
|
81 | + if (!$target->isTrait()) |
|
82 | + { |
|
73 | 83 | //Target is interface or class |
74 | 84 | /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */ |
75 | 85 | return $enum->isSubclassOf($target) || $enum->getName() === $target->getName(); |