@@ -19,7 +19,7 @@ |
||
| 19 | 19 | private S3ClientInterface $client, |
| 20 | 20 | private string $bucket, |
| 21 | 21 | private ?string $prefix = null |
| 22 | - ) { |
|
| 22 | + ){ |
|
| 23 | 23 | parent::__construct(); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $name ??= $this->default; |
| 38 | 38 | |
| 39 | - if (!isset($this->resolvers[$name])) { |
|
| 39 | + if (!isset($this->resolvers[$name])){ |
|
| 40 | 40 | throw new \InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name)); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public function add(string $name, UriResolverInterface $resolver, bool $overwrite = false): void |
| 47 | 47 | { |
| 48 | - if ($overwrite === false && isset($this->resolvers[$name])) { |
|
| 48 | + if ($overwrite === false && isset($this->resolvers[$name])){ |
|
| 49 | 49 | throw new \InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name)); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -36,7 +36,8 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $name ??= $this->default; |
| 38 | 38 | |
| 39 | - if (!isset($this->resolvers[$name])) { |
|
| 39 | + if (!isset($this->resolvers[$name])) |
|
| 40 | + { |
|
| 40 | 41 | throw new \InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name)); |
| 41 | 42 | } |
| 42 | 43 | |
@@ -45,7 +46,8 @@ discard block |
||
| 45 | 46 | |
| 46 | 47 | public function add(string $name, UriResolverInterface $resolver, bool $overwrite = false): void |
| 47 | 48 | { |
| 48 | - if ($overwrite === false && isset($this->resolvers[$name])) { |
|
| 49 | + if ($overwrite === false && isset($this->resolvers[$name])) |
|
| 50 | + { |
|
| 49 | 51 | throw new \InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name)); |
| 50 | 52 | } |
| 51 | 53 | |
@@ -43,10 +43,10 @@ |
||
| 43 | 43 | |
| 44 | 44 | private function registerManager(BinderInterface $binder): void |
| 45 | 45 | { |
| 46 | - $binder->bindSingleton(DistributionInterface::class, static function (DistributionConfig $config) { |
|
| 46 | + $binder->bindSingleton(DistributionInterface::class, static function (DistributionConfig $config){ |
|
| 47 | 47 | $manager = new Manager($config->getDefaultDriver()); |
| 48 | 48 | |
| 49 | - foreach ($config->getResolvers() as $name => $resolver) { |
|
| 49 | + foreach ($config->getResolvers() as $name => $resolver){ |
|
| 50 | 50 | $manager->add($name, $resolver); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -43,10 +43,12 @@ |
||
| 43 | 43 | |
| 44 | 44 | private function registerManager(BinderInterface $binder): void |
| 45 | 45 | { |
| 46 | - $binder->bindSingleton(DistributionInterface::class, static function (DistributionConfig $config) { |
|
| 46 | + $binder->bindSingleton(DistributionInterface::class, static function (DistributionConfig $config) |
|
| 47 | + { |
|
| 47 | 48 | $manager = new Manager($config->getDefaultDriver()); |
| 48 | 49 | |
| 49 | - foreach ($config->getResolvers() as $name => $resolver) { |
|
| 50 | + foreach ($config->getResolvers() as $name => $resolver) |
|
| 51 | + { |
|
| 50 | 52 | $manager->add($name, $resolver); |
| 51 | 53 | } |
| 52 | 54 | |
@@ -26,14 +26,14 @@ |
||
| 26 | 26 | parent::setUp(); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - protected function bind(string $alias, string|array|callable|object $resolver): void |
|
| 29 | + protected function bind(string $alias, string | array | callable | object $resolver): void |
|
| 30 | 30 | { |
| 31 | 31 | $binder = $this->constructor->get('binder', BinderInterface::class); |
| 32 | 32 | \assert($binder instanceof BinderInterface); |
| 33 | 33 | $binder->bind($alias, $resolver); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - protected function bindSingleton(string $alias, string|array|callable|object $resolver): void |
|
| 36 | + protected function bindSingleton(string $alias, string | array | callable | object $resolver): void |
|
| 37 | 37 | { |
| 38 | 38 | $binder = $this->constructor->get('binder', BinderInterface::class); |
| 39 | 39 | \assert($binder instanceof BinderInterface); |
@@ -106,7 +106,7 @@ |
||
| 106 | 106 | new DateTimeImmutable(), |
| 107 | 107 | new EngineVAZ2101(), |
| 108 | 108 | ], |
| 109 | - validate: false |
|
| 109 | + validate : false |
|
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | 112 | $this->assertCount(2, $result); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $fiz = new DateTime(); |
| 23 | 23 | |
| 24 | 24 | $result = $this->resolveClosure( |
| 25 | - static fn(DateTimeInterface &...$dates) => $dates, |
|
| 25 | + static fn(DateTimeInterface & ...$dates) => $dates, |
|
| 26 | 26 | [[$foo, &$bar, &$baz, $fiz]] |
| 27 | 27 | ); |
| 28 | 28 | $this->assertCount(4, $result); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $fiz = new DateTime(); |
| 52 | 52 | |
| 53 | 53 | $result = $this->resolveClosure( |
| 54 | - static fn(DateTimeInterface &...$dates) => $dates, |
|
| 54 | + static fn(DateTimeInterface & ...$dates) => $dates, |
|
| 55 | 55 | ['dates' => [$foo, &$bar, &$baz, $fiz]] |
| 56 | 56 | ); |
| 57 | 57 | $this->assertCount(4, $result); |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | int &$foo, |
| 90 | 90 | object &$bar, |
| 91 | 91 | &$baz, |
| 92 | - ?ColorInterface &$nullable, |
|
| 93 | - EngineInterface &$object, // from container |
|
| 94 | - DateTimeInterface &...$dates // collect all unnamed DateTimeInterface objects |
|
| 92 | + ?ColorInterface & $nullable, |
|
| 93 | + EngineInterface & $object, // from container |
|
| 94 | + DateTimeInterface & ...$dates // collect all unnamed DateTimeInterface objects |
|
| 95 | 95 | ) => null, |
| 96 | 96 | [ |
| 97 | 97 | 'dates' => [ |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | $this->bindSingleton(DateTimeInterface::class, $time = new DateTimeImmutable()); |
| 21 | 21 | |
| 22 | 22 | $result = $this->resolveClosure( |
| 23 | - static fn(string|DateTimeInterface $time) => null, |
|
| 23 | + static fn(string | DateTimeInterface $time) => null, |
|
| 24 | 24 | [] |
| 25 | 25 | ); |
| 26 | 26 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | public function testUnionType(): void |
| 126 | 126 | { |
| 127 | 127 | $this->validateClosureArguments( |
| 128 | - fn (array|Traversable $a, array|Traversable $b) => null, |
|
| 128 | + fn (array | Traversable $a, array | Traversable $b) => null, |
|
| 129 | 129 | [[1, 2, NAN], new EmptyIterator()] |
| 130 | 130 | ); |
| 131 | 131 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | public function testNullableUnionType(): void |
| 134 | 134 | { |
| 135 | 135 | $this->validateClosureArguments( |
| 136 | - fn (null|array|Traversable $a, null|array|Traversable $b) => null, |
|
| 136 | + fn (null | array | Traversable $a, null | array | Traversable $b) => null, |
|
| 137 | 137 | [null, new EmptyIterator()] |
| 138 | 138 | ); |
| 139 | 139 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | public function testWrongUnionType(): void |
| 197 | 197 | { |
| 198 | 198 | $this->validateClosureArguments( |
| 199 | - fn (array|Traversable $a) => null, |
|
| 199 | + fn (array | Traversable $a) => null, |
|
| 200 | 200 | ['foo'], |
| 201 | 201 | 'a' |
| 202 | 202 | ); |
@@ -329,14 +329,14 @@ discard block |
||
| 329 | 329 | ?string $invalidParameter = null, |
| 330 | 330 | string $exceptionClass = InvalidArgumentException::class, |
| 331 | 331 | ): void { |
| 332 | - try { |
|
| 332 | + try{ |
|
| 333 | 333 | $this->createResolver()->validateArguments(new ReflectionFunction($closure), $arguments); |
| 334 | - } catch (ValidationException $e) { |
|
| 334 | + }catch (ValidationException $e){ |
|
| 335 | 335 | $this->assertInstanceOf($exceptionClass, $e, 'Expected other exception.'); |
| 336 | - if ($invalidParameter === null) { |
|
| 336 | + if ($invalidParameter === null){ |
|
| 337 | 337 | throw $e; |
| 338 | 338 | } |
| 339 | - if ($e->getParameter() !== $invalidParameter) { |
|
| 339 | + if ($e->getParameter() !== $invalidParameter){ |
|
| 340 | 340 | $this->fail( |
| 341 | 341 | \sprintf( |
| 342 | 342 | 'The other argument has been failed: `%s` instead of `%s`.', |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | $this->assertTrue(true, 'Invalid value has been failed.'); |
| 349 | 349 | return; |
| 350 | 350 | } |
| 351 | - if ($invalidParameter === null) { |
|
| 351 | + if ($invalidParameter === null){ |
|
| 352 | 352 | $this->assertTrue(true, 'Valid argument value has been failed.'); |
| 353 | 353 | return; |
| 354 | 354 | } |
@@ -329,14 +329,19 @@ discard block |
||
| 329 | 329 | ?string $invalidParameter = null, |
| 330 | 330 | string $exceptionClass = InvalidArgumentException::class, |
| 331 | 331 | ): void { |
| 332 | - try { |
|
| 332 | + try |
|
| 333 | + { |
|
| 333 | 334 | $this->createResolver()->validateArguments(new ReflectionFunction($closure), $arguments); |
| 334 | - } catch (ValidationException $e) { |
|
| 335 | + } |
|
| 336 | + catch (ValidationException $e) |
|
| 337 | + { |
|
| 335 | 338 | $this->assertInstanceOf($exceptionClass, $e, 'Expected other exception.'); |
| 336 | - if ($invalidParameter === null) { |
|
| 339 | + if ($invalidParameter === null) |
|
| 340 | + { |
|
| 337 | 341 | throw $e; |
| 338 | 342 | } |
| 339 | - if ($e->getParameter() !== $invalidParameter) { |
|
| 343 | + if ($e->getParameter() !== $invalidParameter) |
|
| 344 | + { |
|
| 340 | 345 | $this->fail( |
| 341 | 346 | \sprintf( |
| 342 | 347 | 'The other argument has been failed: `%s` instead of `%s`.', |
@@ -348,7 +353,8 @@ discard block |
||
| 348 | 353 | $this->assertTrue(true, 'Invalid value has been failed.'); |
| 349 | 354 | return; |
| 350 | 355 | } |
| 351 | - if ($invalidParameter === null) { |
|
| 356 | + if ($invalidParameter === null) |
|
| 357 | + { |
|
| 352 | 358 | $this->assertTrue(true, 'Valid argument value has been failed.'); |
| 353 | 359 | return; |
| 354 | 360 | } |
@@ -83,7 +83,7 @@ |
||
| 83 | 83 | public function testNullableUnionDefaultScalar(): void |
| 84 | 84 | { |
| 85 | 85 | $result = $this->resolveClosure( |
| 86 | - static fn(null|int|string $param = 42) => $param |
|
| 86 | + static fn(null | int | string $param = 42) => $param |
|
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | 89 | $this->assertSame([42], $result); |