@@ -34,17 +34,17 @@ discard block |
||
34 | 34 | public function __construct( |
35 | 35 | private readonly ResponseFactoryInterface $responseFactory, |
36 | 36 | private readonly array $allowMethods = self::ALLOW_METHODS, |
37 | - ) {} |
|
37 | + ){} |
|
38 | 38 | |
39 | 39 | public function process(Request $request, RequestHandlerInterface $handler): Response |
40 | 40 | { |
41 | 41 | $token = $request->getAttribute(CsrfMiddleware::ATTRIBUTE); |
42 | 42 | |
43 | - if (empty($token)) { |
|
43 | + if (empty($token)){ |
|
44 | 44 | throw new \LogicException('Unable to apply CSRF firewall, attribute is missing'); |
45 | 45 | } |
46 | 46 | |
47 | - if ($this->isRequired($request) && !\hash_equals($token, $this->fetchToken($request))) { |
|
47 | + if ($this->isRequired($request) && !\hash_equals($token, $this->fetchToken($request))){ |
|
48 | 48 | return $this->responseFactory->createResponse(412, 'Bad CSRF Token'); |
49 | 49 | } |
50 | 50 | |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | */ |
65 | 65 | protected function fetchToken(Request $request): string |
66 | 66 | { |
67 | - if ($request->hasHeader(self::HEADER)) { |
|
67 | + if ($request->hasHeader(self::HEADER)){ |
|
68 | 68 | return $request->getHeaderLine(self::HEADER); |
69 | 69 | } |
70 | 70 | |
71 | 71 | $data = $request->getParsedBody(); |
72 | - if (\is_array($data) && isset($data[self::PARAMETER]) && \is_string($data[self::PARAMETER])) { |
|
72 | + if (\is_array($data) && isset($data[self::PARAMETER]) && \is_string($data[self::PARAMETER])){ |
|
73 | 73 | return $data[self::PARAMETER]; |
74 | 74 | } |
75 | 75 |
@@ -34,17 +34,20 @@ discard block |
||
34 | 34 | public function __construct( |
35 | 35 | private readonly ResponseFactoryInterface $responseFactory, |
36 | 36 | private readonly array $allowMethods = self::ALLOW_METHODS, |
37 | - ) {} |
|
37 | + ) { |
|
38 | +} |
|
38 | 39 | |
39 | 40 | public function process(Request $request, RequestHandlerInterface $handler): Response |
40 | 41 | { |
41 | 42 | $token = $request->getAttribute(CsrfMiddleware::ATTRIBUTE); |
42 | 43 | |
43 | - if (empty($token)) { |
|
44 | + if (empty($token)) |
|
45 | + { |
|
44 | 46 | throw new \LogicException('Unable to apply CSRF firewall, attribute is missing'); |
45 | 47 | } |
46 | 48 | |
47 | - if ($this->isRequired($request) && !\hash_equals($token, $this->fetchToken($request))) { |
|
49 | + if ($this->isRequired($request) && !\hash_equals($token, $this->fetchToken($request))) |
|
50 | + { |
|
48 | 51 | return $this->responseFactory->createResponse(412, 'Bad CSRF Token'); |
49 | 52 | } |
50 | 53 | |
@@ -64,12 +67,14 @@ discard block |
||
64 | 67 | */ |
65 | 68 | protected function fetchToken(Request $request): string |
66 | 69 | { |
67 | - if ($request->hasHeader(self::HEADER)) { |
|
70 | + if ($request->hasHeader(self::HEADER)) |
|
71 | + { |
|
68 | 72 | return $request->getHeaderLine(self::HEADER); |
69 | 73 | } |
70 | 74 | |
71 | 75 | $data = $request->getParsedBody(); |
72 | - if (\is_array($data) && isset($data[self::PARAMETER]) && \is_string($data[self::PARAMETER])) { |
|
76 | + if (\is_array($data) && isset($data[self::PARAMETER]) && \is_string($data[self::PARAMETER])) |
|
77 | + { |
|
73 | 78 | return $data[self::PARAMETER]; |
74 | 79 | } |
75 | 80 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | public function testInjection(): void |
42 | 42 | { |
43 | - $factory = new class implements LogsInterface { |
|
43 | + $factory = new class implements LogsInterface{ |
|
44 | 44 | public function getLogger(string $channel): LoggerInterface |
45 | 45 | { |
46 | 46 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | public function testInjectionNullableChannel(): void |
59 | 59 | { |
60 | - $factory = new class implements LogsInterface { |
|
60 | + $factory = new class implements LogsInterface{ |
|
61 | 61 | public function getLogger(?string $channel): LoggerInterface |
62 | 62 | { |
63 | 63 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | public function testInjectionWithAttribute(): void |
76 | 76 | { |
77 | - $factory = new class implements LogsInterface { |
|
77 | + $factory = new class implements LogsInterface{ |
|
78 | 78 | public function getLogger(?string $channel): LoggerInterface |
79 | 79 | { |
80 | 80 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -40,7 +40,8 @@ discard block |
||
40 | 40 | |
41 | 41 | public function testInjection(): void |
42 | 42 | { |
43 | - $factory = new class implements LogsInterface { |
|
43 | + $factory = new class implements LogsInterface |
|
44 | + { |
|
44 | 45 | public function getLogger(string $channel): LoggerInterface |
45 | 46 | { |
46 | 47 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -57,7 +58,8 @@ discard block |
||
57 | 58 | |
58 | 59 | public function testInjectionNullableChannel(): void |
59 | 60 | { |
60 | - $factory = new class implements LogsInterface { |
|
61 | + $factory = new class implements LogsInterface |
|
62 | + { |
|
61 | 63 | public function getLogger(?string $channel): LoggerInterface |
62 | 64 | { |
63 | 65 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -74,7 +76,8 @@ discard block |
||
74 | 76 | |
75 | 77 | public function testInjectionWithAttribute(): void |
76 | 78 | { |
77 | - $factory = new class implements LogsInterface { |
|
79 | + $factory = new class implements LogsInterface |
|
80 | + { |
|
78 | 81 | public function getLogger(?string $channel): LoggerInterface |
79 | 82 | { |
80 | 83 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -19,7 +19,7 @@ |
||
19 | 19 | public function __construct( |
20 | 20 | callable $receptor, |
21 | 21 | private readonly string $channel, |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | $this->receptor = $receptor(...); |
24 | 24 | } |
25 | 25 |
@@ -20,18 +20,18 @@ |
||
20 | 20 | |
21 | 21 | public function __construct( |
22 | 22 | private readonly LogsInterface $factory, |
23 | - ) {} |
|
23 | + ){} |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @param \ReflectionParameter|string|null $context may use extended context if possible. |
27 | 27 | */ |
28 | 28 | public function createInjection( |
29 | 29 | \ReflectionClass $class, |
30 | - \ReflectionParameter|null|string $context = null, |
|
30 | + \ReflectionParameter | null | string $context = null, |
|
31 | 31 | ): LoggerInterface { |
32 | 32 | $channel = \is_object($context) ? $this->extractChannelAttribute($context) : null; |
33 | 33 | |
34 | - if ($channel === null) { |
|
34 | + if ($channel === null){ |
|
35 | 35 | /** |
36 | 36 | * Array of flags to check if the logger allows null argument |
37 | 37 | * |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | |
21 | 21 | public function __construct( |
22 | 22 | private readonly LogsInterface $factory, |
23 | - ) {} |
|
23 | + ) { |
|
24 | +} |
|
24 | 25 | |
25 | 26 | /** |
26 | 27 | * @param \ReflectionParameter|string|null $context may use extended context if possible. |
@@ -31,7 +32,8 @@ discard block |
||
31 | 32 | ): LoggerInterface { |
32 | 33 | $channel = \is_object($context) ? $this->extractChannelAttribute($context) : null; |
33 | 34 | |
34 | - if ($channel === null) { |
|
35 | + if ($channel === null) |
|
36 | + { |
|
35 | 37 | /** |
36 | 38 | * Array of flags to check if the logger allows null argument |
37 | 39 | * |
@@ -12,7 +12,7 @@ |
||
12 | 12 | private readonly string $level, |
13 | 13 | private readonly string $message, |
14 | 14 | private readonly array $context = [], |
15 | - ) {} |
|
15 | + ){} |
|
16 | 16 | |
17 | 17 | public function getTime(): \DateTimeInterface |
18 | 18 | { |
@@ -12,7 +12,8 @@ |
||
12 | 12 | private readonly string $level, |
13 | 13 | private readonly string $message, |
14 | 14 | private readonly array $context = [], |
15 | - ) {} |
|
15 | + ) { |
|
16 | +} |
|
16 | 17 | |
17 | 18 | public function getTime(): \DateTimeInterface |
18 | 19 | { |
@@ -17,5 +17,5 @@ |
||
17 | 17 | /** |
18 | 18 | * @param non-empty-string $name |
19 | 19 | */ |
20 | - public function __construct(public readonly string $name) {} |
|
20 | + public function __construct(public readonly string $name){} |
|
21 | 21 | } |
@@ -17,5 +17,7 @@ |
||
17 | 17 | /** |
18 | 18 | * @param non-empty-string $name |
19 | 19 | */ |
20 | - public function __construct(public readonly string $name) {} |
|
20 | + public function __construct(public readonly string $name) |
|
21 | + { |
|
22 | +} |
|
21 | 23 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function __construct( |
16 | 16 | private readonly ListenerRegistryInterface $listenedRegistry, |
17 | - ) {} |
|
17 | + ){} |
|
18 | 18 | |
19 | 19 | public function getLogger(string $channel): LoggerInterface |
20 | 20 | { |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | $e = new LogEvent( |
27 | 27 | new \DateTime(), |
28 | 28 | $channel, |
29 | - (string) $level, |
|
29 | + (string)$level, |
|
30 | 30 | $message, |
31 | 31 | $context, |
32 | 32 | ); |
33 | 33 | |
34 | - foreach ($this->listenedRegistry->getListeners() as $listener) { |
|
34 | + foreach ($this->listenedRegistry->getListeners() as $listener){ |
|
35 | 35 | \call_user_func($listener, $e); |
36 | 36 | } |
37 | 37 | } |
@@ -14,7 +14,8 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function __construct( |
16 | 16 | private readonly ListenerRegistryInterface $listenedRegistry, |
17 | - ) {} |
|
17 | + ) { |
|
18 | +} |
|
18 | 19 | |
19 | 20 | public function getLogger(string $channel): LoggerInterface |
20 | 21 | { |
@@ -31,7 +32,8 @@ discard block |
||
31 | 32 | $context, |
32 | 33 | ); |
33 | 34 | |
34 | - foreach ($this->listenedRegistry->getListeners() as $listener) { |
|
35 | + foreach ($this->listenedRegistry->getListeners() as $listener) |
|
36 | + { |
|
35 | 37 | \call_user_func($listener, $e); |
36 | 38 | } |
37 | 39 | } |
@@ -324,14 +324,19 @@ discard block |
||
324 | 324 | ?string $invalidParameter = null, |
325 | 325 | string $exceptionClass = InvalidArgumentException::class, |
326 | 326 | ): void { |
327 | - try { |
|
327 | + try |
|
328 | + { |
|
328 | 329 | $this->createResolver()->validateArguments(new \ReflectionFunction($closure), $arguments); |
329 | - } catch (ValidationException $e) { |
|
330 | + } |
|
331 | + catch (ValidationException $e) |
|
332 | + { |
|
330 | 333 | $this->assertInstanceOf($exceptionClass, $e, 'Expected other exception.'); |
331 | - if ($invalidParameter === null) { |
|
334 | + if ($invalidParameter === null) |
|
335 | + { |
|
332 | 336 | throw $e; |
333 | 337 | } |
334 | - if ($e->getParameter() !== $invalidParameter) { |
|
338 | + if ($e->getParameter() !== $invalidParameter) |
|
339 | + { |
|
335 | 340 | $this->fail( |
336 | 341 | \sprintf( |
337 | 342 | 'The other argument has been failed: `%s` instead of `%s`.', |
@@ -343,7 +348,8 @@ discard block |
||
343 | 348 | $this->assertTrue(true, 'Invalid value has been failed.'); |
344 | 349 | return; |
345 | 350 | } |
346 | - if ($invalidParameter === null) { |
|
351 | + if ($invalidParameter === null) |
|
352 | + { |
|
347 | 353 | $this->assertTrue(true, 'Valid argument value has been failed.'); |
348 | 354 | return; |
349 | 355 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public function testUnionType(): void |
120 | 120 | { |
121 | 121 | $this->validateClosureArguments( |
122 | - static fn(array|\Traversable $a, array|\Traversable $b) => null, |
|
122 | + static fn(array | \Traversable $a, array | \Traversable $b) => null, |
|
123 | 123 | [[1, 2, NAN], new \EmptyIterator()], |
124 | 124 | ); |
125 | 125 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | public function testNullableUnionType(): void |
128 | 128 | { |
129 | 129 | $this->validateClosureArguments( |
130 | - static fn(null|array|\Traversable $a, null|array|\Traversable $b) => null, |
|
130 | + static fn(null | array | \Traversable $a, null | array | \Traversable $b) => null, |
|
131 | 131 | [null, new \EmptyIterator()], |
132 | 132 | ); |
133 | 133 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | public function testWrongUnionType(): void |
191 | 191 | { |
192 | 192 | $this->validateClosureArguments( |
193 | - static fn(array|\Traversable $a) => null, |
|
193 | + static fn(array | \Traversable $a) => null, |
|
194 | 194 | ['foo'], |
195 | 195 | 'a', |
196 | 196 | ); |
@@ -324,14 +324,14 @@ discard block |
||
324 | 324 | ?string $invalidParameter = null, |
325 | 325 | string $exceptionClass = InvalidArgumentException::class, |
326 | 326 | ): void { |
327 | - try { |
|
327 | + try{ |
|
328 | 328 | $this->createResolver()->validateArguments(new \ReflectionFunction($closure), $arguments); |
329 | - } catch (ValidationException $e) { |
|
329 | + }catch (ValidationException $e){ |
|
330 | 330 | $this->assertInstanceOf($exceptionClass, $e, 'Expected other exception.'); |
331 | - if ($invalidParameter === null) { |
|
331 | + if ($invalidParameter === null){ |
|
332 | 332 | throw $e; |
333 | 333 | } |
334 | - if ($e->getParameter() !== $invalidParameter) { |
|
334 | + if ($e->getParameter() !== $invalidParameter){ |
|
335 | 335 | $this->fail( |
336 | 336 | \sprintf( |
337 | 337 | 'The other argument has been failed: `%s` instead of `%s`.', |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $this->assertTrue(true, 'Invalid value has been failed.'); |
344 | 344 | return; |
345 | 345 | } |
346 | - if ($invalidParameter === null) { |
|
346 | + if ($invalidParameter === null){ |
|
347 | 347 | $this->assertTrue(true, 'Valid argument value has been failed.'); |
348 | 348 | return; |
349 | 349 | } |
@@ -105,7 +105,7 @@ |
||
105 | 105 | new \DateTimeImmutable(), |
106 | 106 | new EngineVAZ2101(), |
107 | 107 | ], |
108 | - validate: false, |
|
108 | + validate : false, |
|
109 | 109 | ); |
110 | 110 | |
111 | 111 | $this->assertCount(2, $result); |