@@ -22,8 +22,8 @@ |
||
| 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 | + if (!\is_string($value)){ |
|
| 27 | 27 | throw new StateException(\sprintf( |
| 28 | 28 | 'Invalid tag value, string expected got %s', |
| 29 | 29 | \get_debug_type($value) |
@@ -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,7 @@ 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 | $this->listeners[] = $listener; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | public function removeListener(callable $listener): void |
| 25 | 25 | { |
| 26 | 26 | $key = \array_search($listener, $this->listeners, true); |
| 27 | - if ($key !== false) { |
|
| 27 | + if ($key !== false){ |
|
| 28 | 28 | unset($this->listeners[$key]); |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -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 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | // Automatically prepend HTTP verb to all action names. |
| 28 | 28 | public const RESTFUL = 1; |
| 29 | 29 | |
| 30 | - private HandlerInterface|CoreInterface|null $pipeline = null; |
|
| 30 | + private HandlerInterface | CoreInterface | null $pipeline = null; |
|
| 31 | 31 | private ?CoreHandler $handler = null; |
| 32 | 32 | private bool $verbActions; |
| 33 | 33 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | private array $constrains, |
| 37 | 37 | int $options = 0, |
| 38 | 38 | private string $defaultAction = 'index' |
| 39 | - ) { |
|
| 39 | + ){ |
|
| 40 | 40 | $this->verbActions = ($options & self::RESTFUL) === self::RESTFUL; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @mutation-free |
| 55 | 55 | * @deprecated Use {@see withHandler()} instead. |
| 56 | 56 | */ |
| 57 | - public function withCore(HandlerInterface|CoreInterface $core): TargetInterface |
|
| 57 | + public function withCore(HandlerInterface | CoreInterface $core): TargetInterface |
|
| 58 | 58 | { |
| 59 | 59 | $target = clone $this; |
| 60 | 60 | $target->pipeline = $core; |
@@ -86,13 +86,13 @@ 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 | return $this->handler; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $scope = Proxy::create(new \ReflectionClass(ScopeInterface::class), null, new \Spiral\Core\Attribute\Proxy()); |
| 94 | 94 | |
| 95 | - try { |
|
| 95 | + try{ |
|
| 96 | 96 | // construct on demand |
| 97 | 97 | $this->handler = new CoreHandler( |
| 98 | 98 | match (false) { |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | 108 | return $this->handler; |
| 109 | - } catch (ContainerExceptionInterface $e) { |
|
| 109 | + }catch (ContainerExceptionInterface $e){ |
|
| 110 | 110 | throw new TargetException($e->getMessage(), $e->getCode(), $e); |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -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,7 @@ |
||
| 16 | 16 | { |
| 17 | 17 | public function __construct( |
| 18 | 18 | #[Proxy] private ScopeInterface $scope, |
| 19 | - ) {} |
|
| 19 | + ){} |
|
| 20 | 20 | |
| 21 | 21 | public function process( |
| 22 | 22 | ServerRequestInterface $request, |
@@ -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, |
@@ -4,9 +4,9 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace Spiral\Framework; |
| 6 | 6 | |
| 7 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 7 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 8 | 8 | |
| 9 | -if (!\enum_exists(Spiral::class)) { |
|
| 9 | +if (!\enum_exists(Spiral::class)){ |
|
| 10 | 10 | enum Spiral: string { |
| 11 | 11 | case HttpRequest = 'http-request'; |
| 12 | 12 | } |
@@ -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 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | public function __construct( |
| 38 | 38 | private readonly InvokerInterface $invoker, |
| 39 | 39 | private readonly ConfiguratorInterface $config, |
| 40 | - ) { |
|
| 40 | + ){ |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @param non-empty-string $key |
| 54 | 54 | * @param TTag $value |
| 55 | 55 | */ |
| 56 | - public function addTag(string $key, string|\Stringable|\Closure $value): void |
|
| 56 | + public function addTag(string $key, string | \Stringable | \Closure $value): void |
|
| 57 | 57 | { |
| 58 | 58 | $this->config->modify(DebugConfig::CONFIG, new Append('tags', $key, $value)); |
| 59 | 59 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * @psalm-param TCollector $collector |
| 63 | 63 | */ |
| 64 | - public function addStateCollector(string|StateCollectorInterface|Autowire $collector): void |
|
| 64 | + public function addStateCollector(string | StateCollectorInterface | Autowire $collector): void |
|
| 65 | 65 | { |
| 66 | 66 | $this->config->modify(DebugConfig::CONFIG, new Append('collectors', null, $collector)); |
| 67 | 67 | } |
@@ -75,12 +75,12 @@ 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 | + if ($value instanceof \Closure){ |
|
| 80 | 80 | $value = $this->invoker->invoke($value); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if (!\is_string($value) && !$value instanceof \Stringable) { |
|
| 83 | + if (!\is_string($value) && !$value instanceof \Stringable){ |
|
| 84 | 84 | throw new StateException( |
| 85 | 85 | \sprintf( |
| 86 | 86 | 'Invalid tag value, `string` expected got `%s`', |
@@ -94,21 +94,21 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | $errors = []; |
| 96 | 96 | |
| 97 | - foreach ($config->getCollectors() as $collector) { |
|
| 98 | - try { |
|
| 97 | + foreach ($config->getCollectors() as $collector){ |
|
| 98 | + try{ |
|
| 99 | 99 | $collector = match (true) { |
| 100 | 100 | \is_string($collector) => $factory->make($collector), |
| 101 | 101 | $collector instanceof Autowire => $collector->resolve($factory), |
| 102 | 102 | default => $collector, |
| 103 | 103 | }; |
| 104 | - } catch (\Throwable) { |
|
| 104 | + }catch (\Throwable){ |
|
| 105 | 105 | $errors[] = \is_string($collector) || $collector instanceof \Stringable |
| 106 | - ? (string) $collector |
|
| 106 | + ? (string)$collector |
|
| 107 | 107 | : \get_debug_type($collector); |
| 108 | 108 | continue; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if (!$collector instanceof StateCollectorInterface) { |
|
| 111 | + if (!$collector instanceof StateCollectorInterface){ |
|
| 112 | 112 | throw new StateException( |
| 113 | 113 | \sprintf( |
| 114 | 114 | 'Unable to populate state, invalid state collector %s', |
@@ -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', |