@@ -9,9 +9,9 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | final class AutowireListenerFactory implements ListenerFactoryInterface |
| 11 | 11 | { |
| 12 | - public function create(string|object $listener, string $method): \Closure |
|
| 12 | + public function create(string | object $listener, string $method): \Closure |
|
| 13 | 13 | { |
| 14 | - if ($this->listenerShouldBeAutowired($listener, $method)) { |
|
| 14 | + if ($this->listenerShouldBeAutowired($listener, $method)){ |
|
| 15 | 15 | return static function (object $event) use ($listener, $method): void { |
| 16 | 16 | ContainerScope::getContainer() |
| 17 | 17 | ->get(InvokerInterface::class) |
@@ -30,26 +30,26 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return TClass |
| 32 | 32 | */ |
| 33 | - private static function getListener(string|object $listener): object |
|
| 33 | + private static function getListener(string | object $listener): object |
|
| 34 | 34 | { |
| 35 | - if (\is_object($listener)) { |
|
| 35 | + if (\is_object($listener)){ |
|
| 36 | 36 | return $listener; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | return ContainerScope::getContainer()->get($listener); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - private function listenerShouldBeAutowired(object|string $listener, string $method): bool |
|
| 42 | + private function listenerShouldBeAutowired(object | string $listener, string $method): bool |
|
| 43 | 43 | { |
| 44 | - if (!\is_object($listener) && !\class_exists($listener) && !\interface_exists($listener)) { |
|
| 44 | + if (!\is_object($listener) && !\class_exists($listener) && !\interface_exists($listener)){ |
|
| 45 | 45 | return true; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - try { |
|
| 48 | + try{ |
|
| 49 | 49 | $refMethod = new \ReflectionMethod($listener, $method); |
| 50 | 50 | |
| 51 | 51 | return $refMethod->getNumberOfParameters() > 1; |
| 52 | - } catch (\ReflectionException $e) { |
|
| 52 | + }catch (\ReflectionException $e){ |
|
| 53 | 53 | $listener = \is_object($listener) ? $listener::class : $listener; |
| 54 | 54 | |
| 55 | 55 | throw match (true) { |
@@ -11,7 +11,8 @@ discard block |
||
| 11 | 11 | { |
| 12 | 12 | public function create(string|object $listener, string $method): \Closure |
| 13 | 13 | { |
| 14 | - if ($this->listenerShouldBeAutowired($listener, $method)) { |
|
| 14 | + if ($this->listenerShouldBeAutowired($listener, $method)) |
|
| 15 | + { |
|
| 15 | 16 | return static function (object $event) use ($listener, $method): void { |
| 16 | 17 | ContainerScope::getContainer() |
| 17 | 18 | ->get(InvokerInterface::class) |
@@ -32,7 +33,8 @@ discard block |
||
| 32 | 33 | */ |
| 33 | 34 | private static function getListener(string|object $listener): object |
| 34 | 35 | { |
| 35 | - if (\is_object($listener)) { |
|
| 36 | + if (\is_object($listener)) |
|
| 37 | + { |
|
| 36 | 38 | return $listener; |
| 37 | 39 | } |
| 38 | 40 | |
@@ -41,15 +43,19 @@ discard block |
||
| 41 | 43 | |
| 42 | 44 | private function listenerShouldBeAutowired(object|string $listener, string $method): bool |
| 43 | 45 | { |
| 44 | - if (!\is_object($listener) && !\class_exists($listener) && !\interface_exists($listener)) { |
|
| 46 | + if (!\is_object($listener) && !\class_exists($listener) && !\interface_exists($listener)) |
|
| 47 | + { |
|
| 45 | 48 | return true; |
| 46 | 49 | } |
| 47 | 50 | |
| 48 | - try { |
|
| 51 | + try |
|
| 52 | + { |
|
| 49 | 53 | $refMethod = new \ReflectionMethod($listener, $method); |
| 50 | 54 | |
| 51 | 55 | return $refMethod->getNumberOfParameters() > 1; |
| 52 | - } catch (\ReflectionException $e) { |
|
| 56 | + } |
|
| 57 | + catch (\ReflectionException $e) |
|
| 58 | + { |
|
| 53 | 59 | $listener = \is_object($listener) ? $listener::class : $listener; |
| 54 | 60 | |
| 55 | 61 | throw match (true) { |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | public function testIterate(): void |
| 26 | 26 | { |
| 27 | 27 | $out = ''; |
| 28 | - foreach ($this->buffer('abc') as $n) { |
|
| 28 | + foreach ($this->buffer('abc') as $n){ |
|
| 29 | 29 | $out .= $n->char; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | private function generate(StreamInterface $src) |
| 151 | 151 | { |
| 152 | - while (!$src->isEOI()) { |
|
| 152 | + while (!$src->isEOI()){ |
|
| 153 | 153 | yield new Byte($src->getOffset(), $src->peak()); |
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | private function generateToken(StreamInterface $src): \Generator |
| 158 | 158 | { |
| 159 | - while (!$src->isEOI()) { |
|
| 159 | + while (!$src->isEOI()){ |
|
| 160 | 160 | yield new Token(0, null, $src->peak()); |
| 161 | 161 | } |
| 162 | 162 | } |
@@ -25,7 +25,8 @@ discard block |
||
| 25 | 25 | public function testIterate(): void |
| 26 | 26 | { |
| 27 | 27 | $out = ''; |
| 28 | - foreach ($this->buffer('abc') as $n) { |
|
| 28 | + foreach ($this->buffer('abc') as $n) |
|
| 29 | + { |
|
| 29 | 30 | $out .= $n->char; |
| 30 | 31 | } |
| 31 | 32 | |
@@ -149,14 +150,16 @@ discard block |
||
| 149 | 150 | |
| 150 | 151 | private function generate(StreamInterface $src) |
| 151 | 152 | { |
| 152 | - while (!$src->isEOI()) { |
|
| 153 | + while (!$src->isEOI()) |
|
| 154 | + { |
|
| 153 | 155 | yield new Byte($src->getOffset(), $src->peak()); |
| 154 | 156 | } |
| 155 | 157 | } |
| 156 | 158 | |
| 157 | 159 | private function generateToken(StreamInterface $src): \Generator |
| 158 | 160 | { |
| 159 | - while (!$src->isEOI()) { |
|
| 161 | + while (!$src->isEOI()) |
|
| 162 | + { |
|
| 160 | 163 | yield new Token(0, null, $src->peak()); |
| 161 | 164 | } |
| 162 | 165 | } |
@@ -33,9 +33,12 @@ |
||
| 33 | 33 | |
| 34 | 34 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
| 35 | 35 | { |
| 36 | - try { |
|
| 36 | + try |
|
| 37 | + { |
|
| 37 | 38 | return $handler->handle($request); |
| 38 | - } catch (ValidationException $e) { |
|
| 39 | + } |
|
| 40 | + catch (ValidationException $e) |
|
| 41 | + { |
|
| 39 | 42 | return $this->renderErrors->render($e->errors, $e->context); |
| 40 | 43 | } |
| 41 | 44 | } |
@@ -27,15 +27,15 @@ |
||
| 27 | 27 | public function __construct( |
| 28 | 28 | ContainerInterface $container, |
| 29 | 29 | ?ErrorsRendererInterface $renderErrors = null, |
| 30 | - ) { |
|
| 30 | + ){ |
|
| 31 | 31 | $this->renderErrors = $renderErrors ?? $container->get(JsonErrorsRenderer::class); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
| 35 | 35 | { |
| 36 | - try { |
|
| 36 | + try{ |
|
| 37 | 37 | return $handler->handle($request); |
| 38 | - } catch (ValidationException $e) { |
|
| 38 | + }catch (ValidationException $e){ |
|
| 39 | 39 | return $this->renderErrors->render($e->errors, $e->context); |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | * @param non-empty-string $name |
| 108 | 108 | * @param non-empty-string|array<non-empty-string> $value |
| 109 | 109 | */ |
| 110 | - public function withHeader(string $name, string|array $value): self |
|
| 110 | + public function withHeader(string $name, string | array $value): self |
|
| 111 | 111 | { |
| 112 | 112 | $value = \is_iterable($value) ? $value : [$value]; |
| 113 | 113 | |
| 114 | 114 | $self = clone $this; |
| 115 | 115 | $self->headers[$name] = []; |
| 116 | 116 | |
| 117 | - foreach ($value as $item) { |
|
| 117 | + foreach ($value as $item){ |
|
| 118 | 118 | $self->headers[$name][] = $item; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * @param non-empty-string $name |
| 126 | 126 | * @param non-empty-string|array<non-empty-string> $value |
| 127 | 127 | */ |
| 128 | - public function withAddedHeader(string $name, string|array $value): self |
|
| 128 | + public function withAddedHeader(string $name, string | array $value): self |
|
| 129 | 129 | { |
| 130 | 130 | /** @var iterable<non-empty-string> $value */ |
| 131 | 131 | $value = \is_iterable($value) ? $value : [$value]; |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | /** @var array<non-empty-string> $headers */ |
| 134 | 134 | $headers = $this->headers[$name] ?? []; |
| 135 | 135 | |
| 136 | - foreach ($value as $item) { |
|
| 136 | + foreach ($value as $item){ |
|
| 137 | 137 | $headers[] = $item; |
| 138 | 138 | } |
| 139 | 139 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public function withoutHeader(string $name): self |
| 147 | 147 | { |
| 148 | - if (!isset($this->headers[$name])) { |
|
| 148 | + if (!isset($this->headers[$name])){ |
|
| 149 | 149 | return $this; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -114,7 +114,8 @@ discard block |
||
| 114 | 114 | $self = clone $this; |
| 115 | 115 | $self->headers[$name] = []; |
| 116 | 116 | |
| 117 | - foreach ($value as $item) { |
|
| 117 | + foreach ($value as $item) |
|
| 118 | + { |
|
| 118 | 119 | $self->headers[$name][] = $item; |
| 119 | 120 | } |
| 120 | 121 | |
@@ -133,7 +134,8 @@ discard block |
||
| 133 | 134 | /** @var array<non-empty-string> $headers */ |
| 134 | 135 | $headers = $this->headers[$name] ?? []; |
| 135 | 136 | |
| 136 | - foreach ($value as $item) { |
|
| 137 | + foreach ($value as $item) |
|
| 138 | + { |
|
| 137 | 139 | $headers[] = $item; |
| 138 | 140 | } |
| 139 | 141 | |
@@ -145,7 +147,8 @@ discard block |
||
| 145 | 147 | */ |
| 146 | 148 | public function withoutHeader(string $name): self |
| 147 | 149 | { |
| 148 | - if (!isset($this->headers[$name])) { |
|
| 150 | + if (!isset($this->headers[$name])) |
|
| 151 | + { |
|
| 149 | 152 | return $this; |
| 150 | 153 | } |
| 151 | 154 | |
@@ -32,13 +32,13 @@ |
||
| 32 | 32 | * @param non-empty-string $name |
| 33 | 33 | * @param non-empty-string|array<non-empty-string> $value |
| 34 | 34 | */ |
| 35 | - public function withHeader(string $name, string|array $value): self; |
|
| 35 | + public function withHeader(string $name, string | array $value): self; |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @param non-empty-string $name |
| 39 | 39 | * @param non-empty-string|array<non-empty-string> $value |
| 40 | 40 | */ |
| 41 | - public function withAddedHeader(string $name, string|array $value): self; |
|
| 41 | + public function withAddedHeader(string $name, string | array $value): self; |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * @param non-empty-string $name |
@@ -87,7 +87,7 @@ |
||
| 87 | 87 | $factory->shouldReceive('make')->andReturnUsing(function (string $name): QueueInterface { |
| 88 | 88 | $result = ['sync' => $this->defaultQueue, 'test' => $this->testQueue][$name] ?? null; |
| 89 | 89 | |
| 90 | - if ($result === null) { |
|
| 90 | + if ($result === null){ |
|
| 91 | 91 | throw new NotFoundException(); |
| 92 | 92 | } |
| 93 | 93 | return $result; |
@@ -87,7 +87,8 @@ |
||
| 87 | 87 | $factory->shouldReceive('make')->andReturnUsing(function (string $name): QueueInterface { |
| 88 | 88 | $result = ['sync' => $this->defaultQueue, 'test' => $this->testQueue][$name] ?? null; |
| 89 | 89 | |
| 90 | - if ($result === null) { |
|
| 90 | + if ($result === null) |
|
| 91 | + { |
|
| 91 | 92 | throw new NotFoundException(); |
| 92 | 93 | } |
| 93 | 94 | return $result; |
@@ -30,9 +30,9 @@ |
||
| 30 | 30 | \preg_replace_callback( |
| 31 | 31 | $this->pattern, |
| 32 | 32 | static function (array $matches) use ($context) { |
| 33 | - try { |
|
| 33 | + try{ |
|
| 34 | 34 | return $context->resolveValue($matches['name']) ?? $matches['default'] ?? null; |
| 35 | - } catch (ContextException $e) { |
|
| 35 | + }catch (ContextException $e){ |
|
| 36 | 36 | return $matches['default'] ?? throw $e; |
| 37 | 37 | } |
| 38 | 38 | }, |
@@ -29,10 +29,14 @@ |
||
| 29 | 29 | return $source->withCode( |
| 30 | 30 | \preg_replace_callback( |
| 31 | 31 | $this->pattern, |
| 32 | - static function (array $matches) use ($context) { |
|
| 33 | - try { |
|
| 32 | + static function (array $matches) use ($context) |
|
| 33 | + { |
|
| 34 | + try |
|
| 35 | + { |
|
| 34 | 36 | return $context->resolveValue($matches['name']) ?? $matches['default'] ?? null; |
| 35 | - } catch (ContextException $e) { |
|
| 37 | + } |
|
| 38 | + catch (ContextException $e) |
|
| 39 | + { |
|
| 36 | 40 | return $matches['default'] ?? throw $e; |
| 37 | 41 | } |
| 38 | 42 | }, |
@@ -69,8 +69,8 @@ |
||
| 69 | 69 | protected function getSource(string $path): ViewSource |
| 70 | 70 | { |
| 71 | 71 | $loader = new ViewLoader([ |
| 72 | - 'default' => __DIR__ . '/fixtures/default', |
|
| 73 | - 'other' => __DIR__ . '/fixtures/other', |
|
| 72 | + 'default' => __DIR__.'/fixtures/default', |
|
| 73 | + 'other' => __DIR__.'/fixtures/other', |
|
| 74 | 74 | ]); |
| 75 | 75 | |
| 76 | 76 | return $loader->withExtension('php')->load($path); |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | * @param non-empty-string $name |
| 9 | 9 | * @param non-empty-string|\Stringable $pattern |
| 10 | 10 | */ |
| 11 | - public function register(string $name, string|\Stringable $pattern): void; |
|
| 11 | + public function register(string $name, string | \Stringable $pattern): void; |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * @return array<non-empty-string, non-empty-string> |