@@ -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 | ), |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | public function __construct( |
43 | 43 | private readonly ConfiguratorInterface $config, |
44 | 44 | private readonly BinderInterface $binder, |
45 | - ) { |
|
45 | + ){ |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function defineDependencies(): array |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ->getBinder(Spiral::Http) |
60 | 60 | ->bind( |
61 | 61 | AuthContextInterface::class, |
62 | - static fn (?ServerRequestInterface $request): AuthContextInterface => |
|
62 | + static fn (?ServerRequestInterface $request) : AuthContextInterface => |
|
63 | 63 | ($request ?? throw new InvalidRequestScopeException(AuthContextInterface::class)) |
64 | 64 | ->getAttribute(AuthMiddleware::ATTRIBUTE) ?? throw new ContextualObjectNotFoundException( |
65 | 65 | AuthContextInterface::class, |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | ] |
103 | 103 | ); |
104 | 104 | |
105 | - $kernel->booting(function () { |
|
105 | + $kernel->booting(function (){ |
|
106 | 106 | $this->addTransport('cookie', $this->createDefaultCookieTransport()); |
107 | 107 | $this->addTransport('header', new HeaderTransport('X-Auth-Token')); |
108 | 108 | $this->addTokenStorage('session', SessionTokenStorage::class); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param non-empty-string $name |
116 | 116 | * @param Autowire|HttpTransportInterface|class-string<HttpTransportInterface> $transport |
117 | 117 | */ |
118 | - public function addTransport(string $name, Autowire|HttpTransportInterface|string $transport): void |
|
118 | + public function addTransport(string $name, Autowire | HttpTransportInterface | string $transport): void |
|
119 | 119 | { |
120 | 120 | $this->config->modify(AuthConfig::CONFIG, new Append('transports', $name, $transport)); |
121 | 121 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param non-empty-string $name |
127 | 127 | * @param Autowire|TokenStorageInterface|class-string<TokenStorageInterface> $storage |
128 | 128 | */ |
129 | - public function addTokenStorage(string $name, Autowire|TokenStorageInterface|string $storage): void |
|
129 | + public function addTokenStorage(string $name, Autowire | TokenStorageInterface | string $storage): void |
|
130 | 130 | { |
131 | 131 | $this->config->modify(AuthConfig::CONFIG, new Append('storages', $name, $storage)); |
132 | 132 | } |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | $registry = new TransportRegistry(); |
150 | 150 | $registry->setDefaultTransport($config->getDefaultTransport()); |
151 | 151 | |
152 | - foreach ($config->getTransports() as $name => $transport) { |
|
153 | - if ($transport instanceof Autowire) { |
|
152 | + foreach ($config->getTransports() as $name => $transport){ |
|
153 | + if ($transport instanceof Autowire){ |
|
154 | 154 | $transport = $transport->resolve($factory); |
155 | 155 | } |
156 | 156 |