@@ -63,7 +63,8 @@ |
||
63 | 63 | |
64 | 64 | public function addNamespace(string|PhpNamespace $namespace): PhpNamespace |
65 | 65 | { |
66 | - if ($namespace instanceof PhpNamespace) { |
|
66 | + if ($namespace instanceof PhpNamespace) |
|
67 | + { |
|
67 | 68 | $this->element->addNamespace($namespace->getElement()); |
68 | 69 | |
69 | 70 | return $namespace; |
@@ -53,9 +53,9 @@ |
||
53 | 53 | return self::fromElement((new Factory())->fromCode(\file_get_contents($reflection->getFileName()))); |
54 | 54 | } |
55 | 55 | |
56 | - public function addNamespace(string|PhpNamespace $namespace): PhpNamespace |
|
56 | + public function addNamespace(string | PhpNamespace $namespace): PhpNamespace |
|
57 | 57 | { |
58 | - if ($namespace instanceof PhpNamespace) { |
|
58 | + if ($namespace instanceof PhpNamespace){ |
|
59 | 59 | $this->element->addNamespace($namespace->getElement()); |
60 | 60 | |
61 | 61 | return $namespace; |
@@ -11,7 +11,7 @@ |
||
11 | 11 | |
12 | 12 | final class ValidationProviderTest extends TestCase |
13 | 13 | { |
14 | - private m\MockInterface|InvokerInterface $invoker; |
|
14 | + private m\MockInterface | InvokerInterface $invoker; |
|
15 | 15 | private ValidationProvider $provider; |
16 | 16 | |
17 | 17 | protected function setUp(): void |
@@ -14,7 +14,7 @@ |
||
14 | 14 | /** |
15 | 15 | * Create validator copy with new data set. |
16 | 16 | */ |
17 | - public function withData(array|object $data): ValidatorInterface; |
|
17 | + public function withData(array | object $data): ValidatorInterface; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Receive field from context data or return default value. |
@@ -17,5 +17,5 @@ |
||
17 | 17 | * @param mixed $context Validation context (available for checkers and validation |
18 | 18 | * methods but is not validated). |
19 | 19 | */ |
20 | - public function validate(array|object $data, array $rules, mixed $context = null): ValidatorInterface; |
|
20 | + public function validate(array | object $data, array $rules, mixed $context = null): ValidatorInterface; |
|
21 | 21 | } |
@@ -9,7 +9,7 @@ |
||
9 | 9 | public function __construct( |
10 | 10 | private readonly SessionScope $session, |
11 | 11 | private readonly string $name |
12 | - ) { |
|
12 | + ){ |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | private readonly CookiesConfig $cookiesConfig, |
32 | 32 | private readonly SessionFactoryInterface $factory, |
33 | 33 | private readonly ScopeInterface $scope |
34 | - ) { |
|
34 | + ){ |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | $this->fetchID($request) |
46 | 46 | ); |
47 | 47 | |
48 | - try { |
|
48 | + try{ |
|
49 | 49 | $response = $this->scope->runScope( |
50 | 50 | [SessionInterface::class => $session], |
51 | 51 | static fn () => $handler->handle($request->withAttribute(self::ATTRIBUTE, $session)) |
52 | 52 | ); |
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); |
@@ -45,12 +45,15 @@ discard block |
||
45 | 45 | $this->fetchID($request) |
46 | 46 | ); |
47 | 47 | |
48 | - try { |
|
48 | + try |
|
49 | + { |
|
49 | 50 | $response = $this->scope->runScope( |
50 | 51 | [SessionInterface::class => $session], |
51 | 52 | static fn () => $handler->handle($request->withAttribute(self::ATTRIBUTE, $session)) |
52 | 53 | ); |
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 |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | public function __construct( |
12 | 12 | private readonly string $id, |
13 | 13 | private readonly array $payload, |
14 | - private readonly ?\DateTimeInterface $expiresAt = null |
|
15 | - ) { |
|
14 | + private readonly ? \DateTimeInterface $expiresAt = null |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function getID(): string |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | public static function unpack(array $data): Token |
51 | 51 | { |
52 | 52 | $expiresAt = null; |
53 | - if ($data['expiresAt'] !== null) { |
|
53 | + if ($data['expiresAt'] !== null){ |
|
54 | 54 | $expiresAt = (new \DateTimeImmutable())->setTimestamp($data['expiresAt']); |
55 | 55 | } |
56 | 56 |
@@ -50,7 +50,8 @@ |
||
50 | 50 | public static function unpack(array $data): Token |
51 | 51 | { |
52 | 52 | $expiresAt = null; |
53 | - if ($data['expiresAt'] !== null) { |
|
53 | + if ($data['expiresAt'] !== null) |
|
54 | + { |
|
54 | 55 | $expiresAt = (new \DateTimeImmutable())->setTimestamp($data['expiresAt']); |
55 | 56 | } |
56 | 57 |
@@ -19,28 +19,28 @@ discard block |
||
19 | 19 | |
20 | 20 | public function __construct( |
21 | 21 | private readonly SessionScope $session |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function load(string $id): ?TokenInterface |
26 | 26 | { |
27 | - try { |
|
27 | + try{ |
|
28 | 28 | $tokenData = $this->session->getSection(self::SESSION_SECTION)->get('token'); |
29 | - if ($tokenData === null) { |
|
29 | + if ($tokenData === null){ |
|
30 | 30 | return null; |
31 | 31 | } |
32 | 32 | |
33 | 33 | $token = Token::unpack($tokenData); |
34 | - } catch (\Throwable $e) { |
|
35 | - throw new TokenStorageException('Unable to load session token', (int) $e->getCode(), $e); |
|
34 | + }catch (\Throwable $e){ |
|
35 | + throw new TokenStorageException('Unable to load session token', (int)$e->getCode(), $e); |
|
36 | 36 | } |
37 | 37 | |
38 | - if (!\hash_equals($token->getID(), $id)) { |
|
38 | + if (!\hash_equals($token->getID(), $id)){ |
|
39 | 39 | return null; |
40 | 40 | } |
41 | 41 | |
42 | 42 | $expiresAt = $token->getExpiresAt(); |
43 | - if ($expiresAt !== null && $expiresAt < new \DateTimeImmutable()) { |
|
43 | + if ($expiresAt !== null && $expiresAt < new \DateTimeImmutable()){ |
|
44 | 44 | $this->delete($token); |
45 | 45 | return null; |
46 | 46 | } |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | |
51 | 51 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface |
52 | 52 | { |
53 | - try { |
|
53 | + try{ |
|
54 | 54 | $token = new Token($this->randomHash(128), $payload, $expiresAt); |
55 | 55 | $this->session->getSection(self::SESSION_SECTION)->set('token', $token->pack()); |
56 | 56 | |
57 | 57 | return $token; |
58 | - } catch (\Throwable $e) { |
|
59 | - throw new TokenStorageException('Unable to create session token', (int) $e->getCode(), $e); |
|
58 | + }catch (\Throwable $e){ |
|
59 | + throw new TokenStorageException('Unable to create session token', (int)$e->getCode(), $e); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 |
@@ -24,23 +24,29 @@ discard block |
||
24 | 24 | |
25 | 25 | public function load(string $id): ?TokenInterface |
26 | 26 | { |
27 | - try { |
|
27 | + try |
|
28 | + { |
|
28 | 29 | $tokenData = $this->session->getSection(self::SESSION_SECTION)->get('token'); |
29 | - if ($tokenData === null) { |
|
30 | + if ($tokenData === null) |
|
31 | + { |
|
30 | 32 | return null; |
31 | 33 | } |
32 | 34 | |
33 | 35 | $token = Token::unpack($tokenData); |
34 | - } catch (\Throwable $e) { |
|
36 | + } |
|
37 | + catch (\Throwable $e) |
|
38 | + { |
|
35 | 39 | throw new TokenStorageException('Unable to load session token', (int) $e->getCode(), $e); |
36 | 40 | } |
37 | 41 | |
38 | - if (!\hash_equals($token->getID(), $id)) { |
|
42 | + if (!\hash_equals($token->getID(), $id)) |
|
43 | + { |
|
39 | 44 | return null; |
40 | 45 | } |
41 | 46 | |
42 | 47 | $expiresAt = $token->getExpiresAt(); |
43 | - if ($expiresAt !== null && $expiresAt < new \DateTimeImmutable()) { |
|
48 | + if ($expiresAt !== null && $expiresAt < new \DateTimeImmutable()) |
|
49 | + { |
|
44 | 50 | $this->delete($token); |
45 | 51 | return null; |
46 | 52 | } |
@@ -50,12 +56,15 @@ discard block |
||
50 | 56 | |
51 | 57 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface |
52 | 58 | { |
53 | - try { |
|
59 | + try |
|
60 | + { |
|
54 | 61 | $token = new Token($this->randomHash(128), $payload, $expiresAt); |
55 | 62 | $this->session->getSection(self::SESSION_SECTION)->set('token', $token->pack()); |
56 | 63 | |
57 | 64 | return $token; |
58 | - } catch (\Throwable $e) { |
|
65 | + } |
|
66 | + catch (\Throwable $e) |
|
67 | + { |
|
59 | 68 | throw new TokenStorageException('Unable to create session token', (int) $e->getCode(), $e); |
60 | 69 | } |
61 | 70 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | { |
16 | 16 | public function __construct( |
17 | 17 | private readonly ContainerInterface $container |
18 | - ) { |
|
18 | + ){ |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | |
69 | 69 | private function getAuthContext(): AuthContextInterface |
70 | 70 | { |
71 | - try { |
|
71 | + try{ |
|
72 | 72 | return $this->container->get(AuthContextInterface::class); |
73 | - } catch (NotFoundExceptionInterface $e) { |
|
73 | + }catch (NotFoundExceptionInterface $e){ |
|
74 | 74 | throw new ScopeException('Unable to resolve auth context, invalid scope', $e->getCode(), $e); |
75 | 75 | } |
76 | 76 | } |
@@ -68,9 +68,12 @@ |
||
68 | 68 | |
69 | 69 | private function getAuthContext(): AuthContextInterface |
70 | 70 | { |
71 | - try { |
|
71 | + try |
|
72 | + { |
|
72 | 73 | return $this->container->get(AuthContextInterface::class); |
73 | - } catch (NotFoundExceptionInterface $e) { |
|
74 | + } |
|
75 | + catch (NotFoundExceptionInterface $e) |
|
76 | + { |
|
74 | 77 | throw new ScopeException('Unable to resolve auth context, invalid scope', $e->getCode(), $e); |
75 | 78 | } |
76 | 79 | } |