@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function __construct( |
| 30 | 30 | /** @internal */ |
| 31 | 31 | #[Proxy] protected ContainerInterface $container |
| 32 | - ) { |
|
| 32 | + ){ |
|
| 33 | 33 | // TODO: can we simplify this? |
| 34 | 34 | // resolver is usually the container itself |
| 35 | 35 | /** @psalm-suppress MixedAssignment */ |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | protected function resolveArguments(\ReflectionMethod $method, array $parameters): array |
| 65 | 65 | { |
| 66 | - foreach ($method->getParameters() as $parameter) { |
|
| 66 | + foreach ($method->getParameters() as $parameter){ |
|
| 67 | 67 | $name = $parameter->getName(); |
| 68 | 68 | if ( |
| 69 | 69 | \array_key_exists($name, $parameters) && |
| 70 | 70 | $parameters[$name] === null && |
| 71 | 71 | $parameter->isDefaultValueAvailable() |
| 72 | - ) { |
|
| 72 | + ){ |
|
| 73 | 73 | /** @psalm-suppress MixedAssignment */ |
| 74 | 74 | $parameters[$name] = $parameter->getDefaultValue(); |
| 75 | 75 | } |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | private function invoke(string $class, \ReflectionMethod $method, array $arguments): mixed |
| 86 | 86 | { |
| 87 | - try { |
|
| 87 | + try{ |
|
| 88 | 88 | $args = $this->resolveArguments($method, $arguments); |
| 89 | - } catch (ArgumentResolvingException | InvalidArgumentException $e) { |
|
| 89 | + }catch (ArgumentResolvingException | InvalidArgumentException $e){ |
|
| 90 | 90 | throw new ControllerException( |
| 91 | 91 | \sprintf( |
| 92 | 92 | 'Missing/invalid parameter %s of `%s`->`%s`', |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | ControllerException::BAD_ARGUMENT, |
| 98 | 98 | $e, |
| 99 | 99 | ); |
| 100 | - } catch (ContainerExceptionInterface $e) { |
|
| 100 | + }catch (ContainerExceptionInterface $e){ |
|
| 101 | 101 | throw new ControllerException( |
| 102 | 102 | $e->getMessage(), |
| 103 | 103 | ControllerException::ERROR, |
@@ -63,7 +63,8 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | protected function resolveArguments(\ReflectionMethod $method, array $parameters): array |
| 65 | 65 | { |
| 66 | - foreach ($method->getParameters() as $parameter) { |
|
| 66 | + foreach ($method->getParameters() as $parameter) |
|
| 67 | + { |
|
| 67 | 68 | $name = $parameter->getName(); |
| 68 | 69 | if ( |
| 69 | 70 | \array_key_exists($name, $parameters) && |
@@ -84,9 +85,12 @@ discard block |
||
| 84 | 85 | */ |
| 85 | 86 | private function invoke(string $class, \ReflectionMethod $method, array $arguments): mixed |
| 86 | 87 | { |
| 87 | - try { |
|
| 88 | + try |
|
| 89 | + { |
|
| 88 | 90 | $args = $this->resolveArguments($method, $arguments); |
| 89 | - } catch (ArgumentResolvingException | InvalidArgumentException $e) { |
|
| 91 | + } |
|
| 92 | + catch (ArgumentResolvingException | InvalidArgumentException $e) |
|
| 93 | + { |
|
| 90 | 94 | throw new ControllerException( |
| 91 | 95 | \sprintf( |
| 92 | 96 | 'Missing/invalid parameter %s of `%s`->`%s`', |
@@ -97,7 +101,9 @@ discard block |
||
| 97 | 101 | ControllerException::BAD_ARGUMENT, |
| 98 | 102 | $e, |
| 99 | 103 | ); |
| 100 | - } catch (ContainerExceptionInterface $e) { |
|
| 104 | + } |
|
| 105 | + catch (ContainerExceptionInterface $e) |
|
| 106 | + { |
|
| 101 | 107 | throw new ControllerException( |
| 102 | 108 | $e->getMessage(), |
| 103 | 109 | ControllerException::ERROR, |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | public function __construct( |
| 24 | 24 | #[Proxy] private readonly ContainerInterface $container |
| 25 | - ) { |
|
| 25 | + ){ |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function getActiveSession(): SessionInterface |
| 98 | 98 | { |
| 99 | - try { |
|
| 99 | + try{ |
|
| 100 | 100 | return $this->container->get(SessionInterface::class); |
| 101 | - } catch (NotFoundExceptionInterface $e) { |
|
| 101 | + }catch (NotFoundExceptionInterface $e){ |
|
| 102 | 102 | throw new ScopeException( |
| 103 | 103 | 'Unable to receive active session, invalid request scope', |
| 104 | 104 | $e->getCode(), |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | private readonly CookiesConfig $cookiesConfig, |
| 35 | 35 | private readonly SessionFactoryInterface $factory, |
| 36 | 36 | private readonly ScopeInterface $scope |
| 37 | - ) { |
|
| 37 | + ){ |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | $this->fetchID($request) |
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | - try { |
|
| 51 | + try{ |
|
| 52 | 52 | $response = $handler->handle($request->withAttribute(self::ATTRIBUTE, $session)); |
| 53 | - } catch (\Throwable $e) { |
|
| 53 | + }catch (\Throwable $e){ |
|
| 54 | 54 | $session->abort(); |
| 55 | 55 | throw $e; |
| 56 | 56 | } |
@@ -63,14 +63,14 @@ discard block |
||
| 63 | 63 | Request $request, |
| 64 | 64 | Response $response |
| 65 | 65 | ): Response { |
| 66 | - if (!$session->isStarted()) { |
|
| 66 | + if (!$session->isStarted()){ |
|
| 67 | 67 | return $response; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $session->commit(); |
| 71 | 71 | |
| 72 | 72 | //SID changed |
| 73 | - if ($this->fetchID($request) !== $session->getID()) { |
|
| 73 | + if ($this->fetchID($request) !== $session->getID()){ |
|
| 74 | 74 | return $this->withCookie($request, $response, $session->getID()); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | protected function fetchID(Request $request): ?string |
| 85 | 85 | { |
| 86 | 86 | $cookies = $request->getCookieParams(); |
| 87 | - if (empty($cookies[$this->config->getCookie()])) { |
|
| 87 | + if (empty($cookies[$this->config->getCookie()])){ |
|
| 88 | 88 | return null; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | protected function clientSignature(Request $request): string |
| 107 | 107 | { |
| 108 | 108 | $signature = ''; |
| 109 | - foreach (self::SIGNATURE_HEADERS as $header) { |
|
| 110 | - $signature .= $request->getHeaderLine($header) . ';'; |
|
| 109 | + foreach (self::SIGNATURE_HEADERS as $header){ |
|
| 110 | + $signature .= $request->getHeaderLine($header).';'; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | return \hash('sha256', $signature); |
@@ -48,9 +48,12 @@ discard block |
||
| 48 | 48 | $this->fetchID($request) |
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | - try { |
|
| 51 | + try |
|
| 52 | + { |
|
| 52 | 53 | $response = $handler->handle($request->withAttribute(self::ATTRIBUTE, $session)); |
| 53 | - } catch (\Throwable $e) { |
|
| 54 | + } |
|
| 55 | + catch (\Throwable $e) |
|
| 56 | + { |
|
| 54 | 57 | $session->abort(); |
| 55 | 58 | throw $e; |
| 56 | 59 | } |
@@ -63,14 +66,16 @@ discard block |
||
| 63 | 66 | Request $request, |
| 64 | 67 | Response $response |
| 65 | 68 | ): Response { |
| 66 | - if (!$session->isStarted()) { |
|
| 69 | + if (!$session->isStarted()) |
|
| 70 | + { |
|
| 67 | 71 | return $response; |
| 68 | 72 | } |
| 69 | 73 | |
| 70 | 74 | $session->commit(); |
| 71 | 75 | |
| 72 | 76 | //SID changed |
| 73 | - if ($this->fetchID($request) !== $session->getID()) { |
|
| 77 | + if ($this->fetchID($request) !== $session->getID()) |
|
| 78 | + { |
|
| 74 | 79 | return $this->withCookie($request, $response, $session->getID()); |
| 75 | 80 | } |
| 76 | 81 | |
@@ -84,7 +89,8 @@ discard block |
||
| 84 | 89 | protected function fetchID(Request $request): ?string |
| 85 | 90 | { |
| 86 | 91 | $cookies = $request->getCookieParams(); |
| 87 | - if (empty($cookies[$this->config->getCookie()])) { |
|
| 92 | + if (empty($cookies[$this->config->getCookie()])) |
|
| 93 | + { |
|
| 88 | 94 | return null; |
| 89 | 95 | } |
| 90 | 96 | |
@@ -106,7 +112,8 @@ discard block |
||
| 106 | 112 | protected function clientSignature(Request $request): string |
| 107 | 113 | { |
| 108 | 114 | $signature = ''; |
| 109 | - foreach (self::SIGNATURE_HEADERS as $header) { |
|
| 115 | + foreach (self::SIGNATURE_HEADERS as $header) |
|
| 116 | + { |
|
| 110 | 117 | $signature .= $request->getHeaderLine($header) . ';'; |
| 111 | 118 | } |
| 112 | 119 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | public function __construct( |
| 36 | 36 | private readonly ConfiguratorInterface $config, |
| 37 | 37 | private readonly BinderInterface $binder, |
| 38 | - ) { |
|
| 38 | + ){ |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function defineDependencies(): array |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @psalm-param MiddlewareInterface|Autowire|class-string<MiddlewareInterface> Middleware definition |
| 100 | 100 | */ |
| 101 | - public function addMiddleware(string|Autowire|MiddlewareInterface $middleware): void |
|
| 101 | + public function addMiddleware(string | Autowire | MiddlewareInterface $middleware): void |
|
| 102 | 102 | { |
| 103 | 103 | $this->config->modify(HttpConfig::CONFIG, new Append('middleware', null, $middleware)); |
| 104 | 104 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function __construct( |
| 23 | 23 | private readonly ConfiguratorInterface $config, |
| 24 | 24 | private readonly BinderInterface $binder, |
| 25 | - ) { |
|
| 25 | + ){ |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public function defineBindings(): array |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | private function cookieQueue(?ServerRequestInterface $request): CookieQueue |
| 56 | 56 | { |
| 57 | - if ($request === null) { |
|
| 57 | + if ($request === null){ |
|
| 58 | 58 | throw new InvalidRequestScopeException(CookieQueue::class); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -54,7 +54,8 @@ |
||
| 54 | 54 | |
| 55 | 55 | private function cookieQueue(?ServerRequestInterface $request): CookieQueue |
| 56 | 56 | { |
| 57 | - if ($request === null) { |
|
| 57 | + if ($request === null) |
|
| 58 | + { |
|
| 58 | 59 | throw new InvalidRequestScopeException(CookieQueue::class); |
| 59 | 60 | } |
| 60 | 61 | |
@@ -19,8 +19,8 @@ |
||
| 19 | 19 | { |
| 20 | 20 | public function __construct( |
| 21 | 21 | string $id, |
| 22 | - string|Container|null $scopeOrContainer = null, |
|
| 23 | - ) { |
|
| 22 | + string | Container | null $scopeOrContainer = null, |
|
| 23 | + ){ |
|
| 24 | 24 | parent::__construct($id, $scopeOrContainer, Spiral::Http->value); |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | { |
| 16 | 16 | public function __construct( |
| 17 | 17 | private readonly BinderInterface $binder, |
| 18 | - ) { |
|
| 18 | + ){ |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function defineDependencies(): array |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | public function __construct( |
| 42 | 42 | private readonly ConfiguratorInterface $config, |
| 43 | 43 | private readonly BinderInterface $binder, |
| 44 | - ) { |
|
| 44 | + ){ |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public function defineDependencies(): array |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | $groups->registerRoutes($router); |
| 81 | 81 | }; |
| 82 | 82 | |
| 83 | - if ($kernel instanceof Kernel) { |
|
| 83 | + if ($kernel instanceof Kernel){ |
|
| 84 | 84 | $kernel->appBooted($configuratorCallback); |
| 85 | 85 | $kernel->appBooted($groupsCallback); |
| 86 | - } else { |
|
| 86 | + }else{ |
|
| 87 | 87 | $kernel->booted($configuratorCallback); |
| 88 | 88 | $kernel->booted($groupsCallback); |
| 89 | 89 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | private function route(ServerRequestInterface $request): RouteInterface |
| 114 | 114 | { |
| 115 | 115 | $route = $request->getAttribute(Router::ROUTE_ATTRIBUTE, null); |
| 116 | - if ($route === null) { |
|
| 116 | + if ($route === null){ |
|
| 117 | 117 | throw new ScopeException('Unable to resolve Route, invalid request scope'); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | public function __construct( |
| 27 | 27 | private readonly BinderInterface $binder, |
| 28 | - ) { |
|
| 28 | + ){ |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public function defineBindings(): array |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | ->getBinder(Spiral::Http) |
| 35 | 35 | ->bind( |
| 36 | 36 | SessionInterface::class, |
| 37 | - static fn (?ServerRequestInterface $request): SessionInterface => |
|
| 37 | + static fn (?ServerRequestInterface $request) : SessionInterface => |
|
| 38 | 38 | ($request ?? throw new InvalidRequestScopeException(SessionInterface::class)) |
| 39 | 39 | ->getAttribute(SessionMiddleware::ATTRIBUTE) ?? throw new ContextualObjectNotFoundException( |
| 40 | 40 | SessionInterface::class, |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | 'handler' => new Autowire( |
| 76 | 76 | FileHandler::class, |
| 77 | 77 | [ |
| 78 | - 'directory' => $directories->get('runtime') . 'session', |
|
| 78 | + 'directory' => $directories->get('runtime').'session', |
|
| 79 | 79 | 'lifetime' => 86400, |
| 80 | 80 | ] |
| 81 | 81 | ), |