@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $cookies = $this->fetchCookies($response); |
| 38 | 38 | |
| 39 | 39 | self::assertArrayHasKey('csrf-token', $cookies); |
| 40 | - self::assertSame($cookies['csrf-token'], (string) $response->getBody()); |
|
| 40 | + self::assertSame($cookies['csrf-token'], (string)$response->getBody()); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function testLengthException(): void |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $response = $this->get($core, '/'); |
| 95 | 95 | self::assertSame(200, $response->getStatusCode()); |
| 96 | - self::assertSame('all good', (string) $response->getBody()); |
|
| 96 | + self::assertSame('all good', (string)$response->getBody()); |
|
| 97 | 97 | |
| 98 | 98 | $cookies = $this->fetchCookies($response); |
| 99 | 99 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | 114 | self::assertSame(200, $response->getStatusCode()); |
| 115 | - self::assertSame('all good', (string) $response->getBody()); |
|
| 115 | + self::assertSame('all good', (string)$response->getBody()); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | public function testHeaderOK(): void |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $response = $this->get($core, '/'); |
| 126 | 126 | self::assertSame(200, $response->getStatusCode()); |
| 127 | - self::assertSame('all good', (string) $response->getBody()); |
|
| 127 | + self::assertSame('all good', (string)$response->getBody()); |
|
| 128 | 128 | |
| 129 | 129 | $cookies = $this->fetchCookies($response); |
| 130 | 130 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | 145 | self::assertSame(200, $response->getStatusCode()); |
| 146 | - self::assertSame('all good', (string) $response->getBody()); |
|
| 146 | + self::assertSame('all good', (string)$response->getBody()); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | public function testHeaderOKStrict(): void |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | ); |
| 174 | 174 | |
| 175 | 175 | self::assertSame(200, $response->getStatusCode()); |
| 176 | - self::assertSame('all good', (string) $response->getBody()); |
|
| 176 | + self::assertSame('all good', (string)$response->getBody()); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | protected function setUp(): void |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | { |
| 258 | 258 | $result = []; |
| 259 | 259 | |
| 260 | - foreach ($response->getHeaders() as $header) { |
|
| 261 | - foreach ($header as $headerLine) { |
|
| 260 | + foreach ($response->getHeaders() as $header){ |
|
| 261 | + foreach ($header as $headerLine){ |
|
| 262 | 262 | $chunk = \explode(';', $headerLine); |
| 263 | - if (\mb_strpos($chunk[0], '=') === false) { |
|
| 263 | + if (\mb_strpos($chunk[0], '=') === false){ |
|
| 264 | 264 | continue; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -257,10 +257,13 @@ |
||
| 257 | 257 | { |
| 258 | 258 | $result = []; |
| 259 | 259 | |
| 260 | - foreach ($response->getHeaders() as $header) { |
|
| 261 | - foreach ($header as $headerLine) { |
|
| 260 | + foreach ($response->getHeaders() as $header) |
|
| 261 | + { |
|
| 262 | + foreach ($header as $headerLine) |
|
| 263 | + { |
|
| 262 | 264 | $chunk = \explode(';', $headerLine); |
| 263 | - if (\mb_strpos($chunk[0], '=') === false) { |
|
| 265 | + if (\mb_strpos($chunk[0], '=') === false) |
|
| 266 | + { |
|
| 264 | 267 | continue; |
| 265 | 268 | } |
| 266 | 269 | |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | public function __construct( |
| 27 | 27 | private readonly CsrfConfig $config, |
| 28 | - ) {} |
|
| 28 | + ){} |
|
| 29 | 29 | |
| 30 | 30 | public function process(Request $request, RequestHandlerInterface $handler): Response |
| 31 | 31 | { |
| 32 | 32 | $cookie = null; |
| 33 | - if (isset($request->getCookieParams()[$this->config->getCookie()])) { |
|
| 33 | + if (isset($request->getCookieParams()[$this->config->getCookie()])){ |
|
| 34 | 34 | $token = $request->getCookieParams()[$this->config->getCookie()]; |
| 35 | - } else { |
|
| 35 | + }else{ |
|
| 36 | 36 | //Making new token |
| 37 | 37 | $token = $this->random($this->config->getTokenLength()); |
| 38 | 38 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | //CSRF issues must be handled by Firewall middleware |
| 44 | 44 | $response = $handler->handle($request->withAttribute(self::ATTRIBUTE, $token)); |
| 45 | 45 | |
| 46 | - if (!empty($cookie)) { |
|
| 46 | + if (!empty($cookie)){ |
|
| 47 | 47 | return $response->withAddedHeader('Set-Cookie', $cookie); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | private function random(int $length = 32): string |
| 76 | 76 | { |
| 77 | - try { |
|
| 78 | - if (empty($string = \random_bytes($length))) { |
|
| 77 | + try{ |
|
| 78 | + if (empty($string = \random_bytes($length))){ |
|
| 79 | 79 | throw new \RuntimeException('Unable to generate random string'); |
| 80 | 80 | } |
| 81 | - } catch (\Throwable $e) { |
|
| 82 | - throw new \RuntimeException('Unable to generate random string', (int) $e->getCode(), $e); |
|
| 81 | + }catch (\Throwable $e){ |
|
| 82 | + throw new \RuntimeException('Unable to generate random string', (int)$e->getCode(), $e); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | return \substr(\base64_encode($string), 0, $length); |
@@ -25,14 +25,18 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | public function __construct( |
| 27 | 27 | private readonly CsrfConfig $config, |
| 28 | - ) {} |
|
| 28 | + ) { |
|
| 29 | +} |
|
| 29 | 30 | |
| 30 | 31 | public function process(Request $request, RequestHandlerInterface $handler): Response |
| 31 | 32 | { |
| 32 | 33 | $cookie = null; |
| 33 | - if (isset($request->getCookieParams()[$this->config->getCookie()])) { |
|
| 34 | + if (isset($request->getCookieParams()[$this->config->getCookie()])) |
|
| 35 | + { |
|
| 34 | 36 | $token = $request->getCookieParams()[$this->config->getCookie()]; |
| 35 | - } else { |
|
| 37 | + } |
|
| 38 | + else |
|
| 39 | + { |
|
| 36 | 40 | //Making new token |
| 37 | 41 | $token = $this->random($this->config->getTokenLength()); |
| 38 | 42 | |
@@ -43,7 +47,8 @@ discard block |
||
| 43 | 47 | //CSRF issues must be handled by Firewall middleware |
| 44 | 48 | $response = $handler->handle($request->withAttribute(self::ATTRIBUTE, $token)); |
| 45 | 49 | |
| 46 | - if (!empty($cookie)) { |
|
| 50 | + if (!empty($cookie)) |
|
| 51 | + { |
|
| 47 | 52 | return $response->withAddedHeader('Set-Cookie', $cookie); |
| 48 | 53 | } |
| 49 | 54 | |
@@ -74,11 +79,15 @@ discard block |
||
| 74 | 79 | */ |
| 75 | 80 | private function random(int $length = 32): string |
| 76 | 81 | { |
| 77 | - try { |
|
| 78 | - if (empty($string = \random_bytes($length))) { |
|
| 82 | + try |
|
| 83 | + { |
|
| 84 | + if (empty($string = \random_bytes($length))) |
|
| 85 | + { |
|
| 79 | 86 | throw new \RuntimeException('Unable to generate random string'); |
| 80 | 87 | } |
| 81 | - } catch (\Throwable $e) { |
|
| 88 | + } |
|
| 89 | + catch (\Throwable $e) |
|
| 90 | + { |
|
| 82 | 91 | throw new \RuntimeException('Unable to generate random string', (int) $e->getCode(), $e); |
| 83 | 92 | } |
| 84 | 93 | |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | |
| 90 | 90 | public function testClosureFactory(): void |
| 91 | 91 | { |
| 92 | - $this->bind(Bucket::class, static function ($data) { |
|
| 92 | + $this->bind(Bucket::class, static function ($data){ |
|
| 93 | 93 | return new Bucket('via-closure', $data); |
| 94 | 94 | }); |
| 95 | 95 | |
@@ -89,7 +89,8 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | public function testClosureFactory(): void |
| 91 | 91 | { |
| 92 | - $this->bind(Bucket::class, static function ($data) { |
|
| 92 | + $this->bind(Bucket::class, static function ($data) |
|
| 93 | + { |
|
| 93 | 94 | return new Bucket('via-closure', $data); |
| 94 | 95 | }); |
| 95 | 96 | |
@@ -129,7 +130,8 @@ discard block |
||
| 129 | 130 | $sample = new SampleClass(); |
| 130 | 131 | |
| 131 | 132 | $this->bind(Bucket::class, [Factory::class, 'makeBucketWithSample']); |
| 132 | - $this->bind(SampleClass::class, static function () use ($sample) { |
|
| 133 | + $this->bind(SampleClass::class, static function () use ($sample) |
|
| 134 | + { |
|
| 133 | 135 | return $sample; |
| 134 | 136 | }); |
| 135 | 137 | |
@@ -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 | } |
@@ -34,24 +34,24 @@ discard block |
||
| 34 | 34 | yield [$from(static fn(string $string = self::STRING_CONST) => 0), 'mixed $string = self::STRING_CONST']; |
| 35 | 35 | yield [ |
| 36 | 36 | $from(static fn(string $string = ProxyClassRendererTest::STRING_CONST) => 0), |
| 37 | - 'mixed $string = \\' . self::class . '::STRING_CONST', |
|
| 37 | + 'mixed $string = \\'.self::class.'::STRING_CONST', |
|
| 38 | 38 | ]; |
| 39 | - yield [$from(static fn(string|int $string = self::INT_CONST) => 0), 'mixed $string = self::INT_CONST']; |
|
| 39 | + yield [$from(static fn(string | int $string = self::INT_CONST) => 0), 'mixed $string = self::INT_CONST']; |
|
| 40 | 40 | yield [$from(static fn(mixed $string = 42) => 0), 'mixed $string = 42']; |
| 41 | 41 | yield [$from(static fn(int $string = 42) => 0), 'mixed $string = 42']; |
| 42 | 42 | yield [$from(static fn(float $string = 42) => 0), 'mixed $string = 42.0']; |
| 43 | 43 | yield [$from(static fn(?bool $string = false) => 0), 'mixed $string = false']; |
| 44 | - yield [$from(static fn(bool|null $string = true) => 0), 'mixed $string = true']; |
|
| 44 | + yield [$from(static fn(bool | null $string = true) => 0), 'mixed $string = true']; |
|
| 45 | 45 | yield [$from(static fn(?object $string = null) => 0), 'mixed $string = NULL']; |
| 46 | 46 | yield [$from(static fn(?iterable $string = null) => 0), 'mixed $string = NULL']; |
| 47 | 47 | yield [$from(static fn(\Countable&\ArrayAccess $val) => 0), 'mixed $val']; |
| 48 | 48 | yield [$from(static fn(string ...$val) => 0), 'mixed ...$val']; |
| 49 | - yield [$from(static fn(string|int ...$val) => 0), 'mixed ...$val']; |
|
| 50 | - yield [$from(static fn(string|int &$link) => 0), 'mixed &$link']; |
|
| 49 | + yield [$from(static fn(string | int ...$val) => 0), 'mixed ...$val']; |
|
| 50 | + yield [$from(static fn(string | int &$link) => 0), 'mixed &$link']; |
|
| 51 | 51 | yield [$from(self::withSelf(...)), 'mixed $self = new self()']; |
| 52 | 52 | yield [$from(static fn(object $link = new \stdClass()) => 0), 'mixed $link = new \stdClass()']; |
| 53 | 53 | yield [ |
| 54 | - $from(static fn(#[Proxy] float|int|\stdClass|null $string = new \stdClass(1, 2, bar: "\n'zero")) => 0), |
|
| 54 | + $from(static fn(#[Proxy] float | int | \stdClass | null $string = new \stdClass(1, 2, bar: "\n'zero")) => 0), |
|
| 55 | 55 | "mixed \$string = new \stdClass(1, 2, bar: '\n\'zero')", |
| 56 | 56 | ]; |
| 57 | 57 | yield [ |
@@ -66,22 +66,22 @@ discard block |
||
| 66 | 66 | public const INT_CONST = 42; |
| 67 | 67 | |
| 68 | 68 | #[ExpectedAttribute('public function test1(...$variadic)')] |
| 69 | - public function test1(...$variadic) {} |
|
| 69 | + public function test1(...$variadic){} |
|
| 70 | 70 | |
| 71 | 71 | #[ExpectedAttribute('public function test2(mixed $string = self::INT_CONST): string|int')] |
| 72 | - public function test2(string|int $string = self::INT_CONST): string|int {} |
|
| 72 | + public function test2(string | int $string = self::INT_CONST): string | int {} |
|
| 73 | 73 | |
| 74 | 74 | #[ExpectedAttribute('public function test3(mixed $obj = new \stdClass(new \stdClass(), new \stdClass()))')] |
| 75 | - public function test3(object $obj = new \stdClass(new \stdClass(), new \stdClass())) {} |
|
| 75 | + public function test3(object $obj = new \stdClass(new \stdClass(), new \stdClass())){} |
|
| 76 | 76 | |
| 77 | - #[ExpectedAttribute('public function test4(): \\' . ProxyClassRendererTest::class)] |
|
| 77 | + #[ExpectedAttribute('public function test4(): \\'.ProxyClassRendererTest::class)] |
|
| 78 | 78 | public function test4(): ProxyClassRendererTest {} |
| 79 | 79 | |
| 80 | 80 | #[ExpectedAttribute('public function &test5(): string')] |
| 81 | 81 | public function &test5(): string {} |
| 82 | 82 | }; |
| 83 | 83 | |
| 84 | - foreach ((new \ReflectionClass($class))->getMethods() as $method) { |
|
| 84 | + foreach ((new \ReflectionClass($class))->getMethods() as $method){ |
|
| 85 | 85 | $expected = $method->getAttributes(ExpectedAttribute::class)[0]->newInstance(); |
| 86 | 86 | |
| 87 | 87 | yield [$method, $expected->value]; |
@@ -96,22 +96,22 @@ discard block |
||
| 96 | 96 | $from = static fn(\Closure $closure): \ReflectionParameter => new \ReflectionParameter($closure, 0); |
| 97 | 97 | |
| 98 | 98 | yield [$from(static fn(string $string) => 0), 'string']; |
| 99 | - yield [$from(static fn(string|int $string) => 0), 'string|int']; |
|
| 99 | + yield [$from(static fn(string | int $string) => 0), 'string|int']; |
|
| 100 | 100 | yield [$from(static fn(mixed $string) => 0), 'mixed']; |
| 101 | 101 | yield [$from(static fn(int $string) => 0), 'int']; |
| 102 | 102 | yield [$from(static fn(float $string) => 0), 'float']; |
| 103 | 103 | yield [$from(static fn(?bool $string) => 0), '?bool']; |
| 104 | - yield [$from(static fn(bool|null $string) => 0), '?bool']; |
|
| 104 | + yield [$from(static fn(bool | null $string) => 0), '?bool']; |
|
| 105 | 105 | yield [$from(static fn(object $string) => 0), 'object']; |
| 106 | 106 | yield [$from(static fn(iterable $string) => 0), 'iterable']; |
| 107 | 107 | yield [$from(static fn(\Countable&\ArrayAccess $val) => 0), '\Countable&\ArrayAccess']; |
| 108 | 108 | yield [$from(static fn(string ...$val) => 0), 'string']; |
| 109 | - yield [$from(static fn(string|int ...$val) => 0), 'string|int']; |
|
| 110 | - yield [$from(static fn(string|int &$link) => 0), 'string|int']; |
|
| 111 | - yield [$from(self::withSelf(...)), '\\' . self::class]; |
|
| 109 | + yield [$from(static fn(string | int ...$val) => 0), 'string|int']; |
|
| 110 | + yield [$from(static fn(string | int &$link) => 0), 'string|int']; |
|
| 111 | + yield [$from(self::withSelf(...)), '\\'.self::class]; |
|
| 112 | 112 | yield [$from(static fn(object $link) => 0), 'object']; |
| 113 | - yield [$from(static fn(#[Proxy] float|int|\stdClass|null $string) => 0), '\stdClass|int|float|null']; |
|
| 114 | - yield [$from(static fn(SimpleEnum $val) => 0), '\\' . SimpleEnum::class]; |
|
| 113 | + yield [$from(static fn(#[Proxy] float | int | \stdClass | null $string) => 0), '\stdClass|int|float|null']; |
|
| 114 | + yield [$from(static fn(SimpleEnum $val) => 0), '\\'.SimpleEnum::class]; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public function testInterfaceWithConstructor(): void |
@@ -174,5 +174,5 @@ discard block |
||
| 174 | 174 | { |
| 175 | 175 | public function __construct( |
| 176 | 176 | public readonly string $value, |
| 177 | - ) {} |
|
| 177 | + ){} |
|
| 178 | 178 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $proxy = $$var; |
| 101 | 101 | self::assertSame(['foo', 'bar', 'baz', 69], $proxy->extraVariadic('foo', 'bar', 'baz', 69)); |
| 102 | 102 | self::assertSame( |
| 103 | - ['foo' => 'foo','zap' => 'bar', 'gas' => 69], |
|
| 103 | + ['foo' => 'foo', 'zap' => 'bar', 'gas' => 69], |
|
| 104 | 104 | $proxy->extraVariadic(foo: 'foo', zap: 'bar', gas: 69), |
| 105 | 105 | ); |
| 106 | 106 | }); |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $root->bindSingleton(MockInterface::class, Stub\MockInterfaceImpl::class); |
| 186 | 186 | $root->bindSingleton(EmptyInterface::class, Stub\MockInterfaceImpl::class); |
| 187 | 187 | |
| 188 | - $mock = $root->invoke(static fn(#[Proxy] MockInterface|EmptyInterface $mock) => $mock); |
|
| 188 | + $mock = $root->invoke(static fn(#[Proxy] MockInterface | EmptyInterface $mock) => $mock); |
|
| 189 | 189 | |
| 190 | 190 | self::assertInstanceOf(MockInterfaceImpl::class, $mock); |
| 191 | 191 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | { |
| 239 | 239 | \set_error_handler(static function (int $errno, string $error) use ($interface): void { |
| 240 | 240 | self::assertSame( |
| 241 | - \sprintf('Using `%s` outside of the `foo` scope is deprecated and will be ' . |
|
| 241 | + \sprintf('Using `%s` outside of the `foo` scope is deprecated and will be '. |
|
| 242 | 242 | 'impossible in version 4.0.', $interface), |
| 243 | 243 | $error, |
| 244 | 244 | ); |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | { |
| 296 | 296 | \set_error_handler(static function (int $errno, string $error) use ($interface): void { |
| 297 | 297 | self::assertSame( |
| 298 | - \sprintf('Using `%s` outside of the `a` scope is deprecated and will be ' . |
|
| 298 | + \sprintf('Using `%s` outside of the `a` scope is deprecated and will be '. |
|
| 299 | 299 | 'impossible in version 4.0.', $interface), |
| 300 | 300 | $error, |
| 301 | 301 | ); |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | public function testDeprecationProxyConfigDontThrowIfNotConstructed(string $interface): void |
| 324 | 324 | { |
| 325 | 325 | \set_error_handler(static function (int $errno, string $error) use ($interface): void { |
| 326 | - self::fail('Unexpected error: ' . $error); |
|
| 326 | + self::fail('Unexpected error: '.$error); |
|
| 327 | 327 | }); |
| 328 | 328 | |
| 329 | 329 | $root = new Container(); |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | #[DataProvider('invalidDeprecationProxyArgsDataProvider')] |
| 346 | - public function testDeprecationProxyConfigArgsRequiredException(string|null $scope, string|null $version): void |
|
| 346 | + public function testDeprecationProxyConfigArgsRequiredException(string | null $scope, string | null $version): void |
|
| 347 | 347 | { |
| 348 | 348 | self::expectException(\InvalidArgumentException::class); |
| 349 | 349 | self::expectExceptionMessage('Scope and version or custom message must be provided.'); |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | { |
| 356 | 356 | $proxy = new Config\Proxy(EmptyInterface::class); |
| 357 | 357 | |
| 358 | - $this->assertSame(\sprintf('Proxy to `%s`', EmptyInterface::class), (string) $proxy); |
|
| 358 | + $this->assertSame(\sprintf('Proxy to `%s`', EmptyInterface::class), (string)$proxy); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | public function testProxyConfigNotInterfaceException(): void |
@@ -35,8 +35,8 @@ |
||
| 35 | 35 | $map = new \WeakMap(); |
| 36 | 36 | |
| 37 | 37 | $fn = function (\WeakMap $map): void { |
| 38 | - foreach ($this as $key => $value) { |
|
| 39 | - if (\is_object($value)) { |
|
| 38 | + foreach ($this as $key => $value){ |
|
| 39 | + if (\is_object($value)){ |
|
| 40 | 40 | $map->offsetSet($value, $key); |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -35,8 +35,10 @@ |
||
| 35 | 35 | $map = new \WeakMap(); |
| 36 | 36 | |
| 37 | 37 | $fn = function (\WeakMap $map): void { |
| 38 | - foreach ($this as $key => $value) { |
|
| 39 | - if (\is_object($value)) { |
|
| 38 | + foreach ($this as $key => $value) |
|
| 39 | + { |
|
| 40 | + if (\is_object($value)) |
|
| 41 | + { |
|
| 40 | 42 | $map->offsetSet($value, $key); |
| 41 | 43 | } |
| 42 | 44 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | |
| 19 | 19 | public function __destruct() |
| 20 | 20 | { |
| 21 | - if ($this->closure !== null) { |
|
| 21 | + if ($this->closure !== null){ |
|
| 22 | 22 | ($this->closure)(); |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -13,12 +13,14 @@ |
||
| 13 | 13 | { |
| 14 | 14 | (static function (): void { |
| 15 | 15 | $container = new Container(); |
| 16 | - $finalizer = new class { |
|
| 16 | + $finalizer = new class |
|
| 17 | + { |
|
| 17 | 18 | public ?\Closure $closure = null; |
| 18 | 19 | |
| 19 | 20 | public function __destruct() |
| 20 | 21 | { |
| 21 | - if ($this->closure !== null) { |
|
| 22 | + if ($this->closure !== null) |
|
| 23 | + { |
|
| 22 | 24 | ($this->closure)(); |
| 23 | 25 | } |
| 24 | 26 | } |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | self::assertNull(ContainerScope::getContainer()); |
| 34 | 34 | |
| 35 | - try { |
|
| 35 | + try{ |
|
| 36 | 36 | self::assertTrue(ContainerScope::runScope($container, static function (): never { |
| 37 | 37 | throw new RuntimeException('exception'); |
| 38 | 38 | })); |
| 39 | - } catch (\Throwable $e) { |
|
| 39 | + }catch (\Throwable $e){ |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | self::assertInstanceOf(RuntimeException::class, $e); |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | return $c->get('bucket')->getName() == 'b' && $c->has('other'); |
| 84 | 84 | })); |
| 85 | 85 | |
| 86 | - try { |
|
| 86 | + try{ |
|
| 87 | 87 | self::assertTrue($c->runScope([ |
| 88 | 88 | 'bucket' => new Bucket('b'), |
| 89 | 89 | 'other' => new SampleClass(), |
| 90 | 90 | ], static function () use ($c): void { |
| 91 | 91 | throw new RuntimeException('exception'); |
| 92 | 92 | })); |
| 93 | - } catch (\Throwable) { |
|
| 93 | + }catch (\Throwable){ |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | self::assertSame('a', $c->get('bucket')->getName()); |
@@ -32,11 +32,14 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | self::assertNull(ContainerScope::getContainer()); |
| 34 | 34 | |
| 35 | - try { |
|
| 35 | + try |
|
| 36 | + { |
|
| 36 | 37 | self::assertTrue(ContainerScope::runScope($container, static function (): never { |
| 37 | 38 | throw new RuntimeException('exception'); |
| 38 | 39 | })); |
| 39 | - } catch (\Throwable $e) { |
|
| 40 | + } |
|
| 41 | + catch (\Throwable $e) |
|
| 42 | + { |
|
| 40 | 43 | } |
| 41 | 44 | |
| 42 | 45 | self::assertInstanceOf(RuntimeException::class, $e); |
@@ -83,14 +86,17 @@ discard block |
||
| 83 | 86 | return $c->get('bucket')->getName() == 'b' && $c->has('other'); |
| 84 | 87 | })); |
| 85 | 88 | |
| 86 | - try { |
|
| 89 | + try |
|
| 90 | + { |
|
| 87 | 91 | self::assertTrue($c->runScope([ |
| 88 | 92 | 'bucket' => new Bucket('b'), |
| 89 | 93 | 'other' => new SampleClass(), |
| 90 | 94 | ], static function () use ($c): void { |
| 91 | 95 | throw new RuntimeException('exception'); |
| 92 | 96 | })); |
| 93 | - } catch (\Throwable) { |
|
| 97 | + } |
|
| 98 | + catch (\Throwable) |
|
| 99 | + { |
|
| 94 | 100 | } |
| 95 | 101 | |
| 96 | 102 | self::assertSame('a', $c->get('bucket')->getName()); |
@@ -135,7 +141,9 @@ discard block |
||
| 135 | 141 | public function testHasInstanceAfterMakeWithoutAliasInScope(): void |
| 136 | 142 | { |
| 137 | 143 | $container = new Container(); |
| 138 | - $container->bindSingleton('test', new #[Singleton] class {}); |
|
| 144 | + $container->bindSingleton('test', new #[Singleton] class |
|
| 145 | + { |
|
| 146 | +}); |
|
| 139 | 147 | $container->make('test'); |
| 140 | 148 | |
| 141 | 149 | $container->runScoped(static function (Container $container): void { |