@@ -22,8 +22,10 @@ |
||
| 22 | 22 | public function setTags(array $tags): void |
| 23 | 23 | { |
| 24 | 24 | $setTags = []; |
| 25 | - foreach ($tags as $key => $value) { |
|
| 26 | - if (!\is_string($value)) { |
|
| 25 | + foreach ($tags as $key => $value) |
|
| 26 | + { |
|
| 27 | + if (!\is_string($value)) |
|
| 28 | + { |
|
| 27 | 29 | throw new StateException(\sprintf( |
| 28 | 30 | 'Invalid tag value, string expected got %s', |
| 29 | 31 | \get_debug_type($value) |
@@ -14,7 +14,8 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | public function addListener(callable $listener): self |
| 16 | 16 | { |
| 17 | - if (!\in_array($listener, $this->listeners, true)) { |
|
| 17 | + if (!\in_array($listener, $this->listeners, true)) |
|
| 18 | + { |
|
| 18 | 19 | $this->listeners[] = $listener; |
| 19 | 20 | } |
| 20 | 21 | |
@@ -24,7 +25,8 @@ discard block |
||
| 24 | 25 | public function removeListener(callable $listener): void |
| 25 | 26 | { |
| 26 | 27 | $key = \array_search($listener, $this->listeners, true); |
| 27 | - if ($key !== false) { |
|
| 28 | + if ($key !== false) |
|
| 29 | + { |
|
| 28 | 30 | unset($this->listeners[$key]); |
| 29 | 31 | } |
| 30 | 32 | } |
@@ -86,13 +86,15 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | protected function coreHandler(ContainerInterface $container): CoreHandler |
| 88 | 88 | { |
| 89 | - if ($this->handler !== null) { |
|
| 89 | + if ($this->handler !== null) |
|
| 90 | + { |
|
| 90 | 91 | return $this->handler; |
| 91 | 92 | } |
| 92 | 93 | |
| 93 | 94 | $scope = Proxy::create(new \ReflectionClass(ScopeInterface::class), null, new \Spiral\Core\Attribute\Proxy()); |
| 94 | 95 | |
| 95 | - try { |
|
| 96 | + try |
|
| 97 | + { |
|
| 96 | 98 | // construct on demand |
| 97 | 99 | $this->handler = new CoreHandler( |
| 98 | 100 | match (false) { |
@@ -106,7 +108,9 @@ discard block |
||
| 106 | 108 | ); |
| 107 | 109 | |
| 108 | 110 | return $this->handler; |
| 109 | - } catch (ContainerExceptionInterface $e) { |
|
| 111 | + } |
|
| 112 | + catch (ContainerExceptionInterface $e) |
|
| 113 | + { |
|
| 110 | 114 | throw new TargetException($e->getMessage(), $e->getCode(), $e); |
| 111 | 115 | } |
| 112 | 116 | } |
@@ -16,7 +16,8 @@ |
||
| 16 | 16 | { |
| 17 | 17 | public function __construct( |
| 18 | 18 | #[Proxy] private ScopeInterface $scope, |
| 19 | - ) {} |
|
| 19 | + ) { |
|
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | public function process( |
| 22 | 23 | ServerRequestInterface $request, |
@@ -6,7 +6,8 @@ |
||
| 6 | 6 | |
| 7 | 7 | require_once __DIR__ . '/../vendor/autoload.php'; |
| 8 | 8 | |
| 9 | -if (!\enum_exists(Spiral::class)) { |
|
| 9 | +if (!\enum_exists(Spiral::class)) |
|
| 10 | +{ |
|
| 10 | 11 | enum Spiral: string { |
| 11 | 12 | case HttpRequest = 'http-request'; |
| 12 | 13 | } |
@@ -75,12 +75,15 @@ discard block |
||
| 75 | 75 | ): StateInterface { |
| 76 | 76 | $state = new State(); |
| 77 | 77 | |
| 78 | - foreach ($config->getTags() as $key => $value) { |
|
| 79 | - if ($value instanceof \Closure) { |
|
| 78 | + foreach ($config->getTags() as $key => $value) |
|
| 79 | + { |
|
| 80 | + if ($value instanceof \Closure) |
|
| 81 | + { |
|
| 80 | 82 | $value = $this->invoker->invoke($value); |
| 81 | 83 | } |
| 82 | 84 | |
| 83 | - if (!\is_string($value) && !$value instanceof \Stringable) { |
|
| 85 | + if (!\is_string($value) && !$value instanceof \Stringable) |
|
| 86 | + { |
|
| 84 | 87 | throw new StateException( |
| 85 | 88 | \sprintf( |
| 86 | 89 | 'Invalid tag value, `string` expected got `%s`', |
@@ -94,21 +97,26 @@ discard block |
||
| 94 | 97 | |
| 95 | 98 | $errors = []; |
| 96 | 99 | |
| 97 | - foreach ($config->getCollectors() as $collector) { |
|
| 98 | - try { |
|
| 100 | + foreach ($config->getCollectors() as $collector) |
|
| 101 | + { |
|
| 102 | + try |
|
| 103 | + { |
|
| 99 | 104 | $collector = match (true) { |
| 100 | 105 | \is_string($collector) => $factory->make($collector), |
| 101 | 106 | $collector instanceof Autowire => $collector->resolve($factory), |
| 102 | 107 | default => $collector, |
| 103 | 108 | }; |
| 104 | - } catch (\Throwable) { |
|
| 109 | + } |
|
| 110 | + catch (\Throwable) |
|
| 111 | + { |
|
| 105 | 112 | $errors[] = \is_string($collector) || $collector instanceof \Stringable |
| 106 | 113 | ? (string) $collector |
| 107 | 114 | : \get_debug_type($collector); |
| 108 | 115 | continue; |
| 109 | 116 | } |
| 110 | 117 | |
| 111 | - if (!$collector instanceof StateCollectorInterface) { |
|
| 118 | + if (!$collector instanceof StateCollectorInterface) |
|
| 119 | + { |
|
| 112 | 120 | throw new StateException( |
| 113 | 121 | \sprintf( |
| 114 | 122 | 'Unable to populate state, invalid state collector %s', |