@@ -72,7 +72,7 @@ |
||
72 | 72 | |
73 | 73 | private function resolveExpirationInterval(mixed $expiration): \DateInterval |
74 | 74 | { |
75 | - if ($expiration === null) { |
|
75 | + if ($expiration === null){ |
|
76 | 76 | return $this->expiration; |
77 | 77 | } |
78 | 78 |
@@ -72,7 +72,8 @@ |
||
72 | 72 | |
73 | 73 | private function resolveExpirationInterval(mixed $expiration): \DateInterval |
74 | 74 | { |
75 | - if ($expiration === null) { |
|
75 | + if ($expiration === null) |
|
76 | + { |
|
76 | 77 | return $this->expiration; |
77 | 78 | } |
78 | 79 |
@@ -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 |
@@ -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); |
@@ -12,13 +12,13 @@ |
||
12 | 12 | { |
13 | 13 | public function testInternalServicesDontBlockContainer(): void |
14 | 14 | { |
15 | - (static function () { |
|
15 | + (static function (){ |
|
16 | 16 | $container = new Container(); |
17 | 17 | $finalizer = new class { |
18 | 18 | public ?\Closure $closure = null; |
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 | } |
@@ -12,18 +12,22 @@ |
||
12 | 12 | { |
13 | 13 | public function testInternalServicesDontBlockContainer(): void |
14 | 14 | { |
15 | - (static function () { |
|
15 | + (static function () |
|
16 | + { |
|
16 | 17 | $container = new Container(); |
17 | - $finalizer = new class { |
|
18 | + $finalizer = new class |
|
19 | + { |
|
18 | 20 | public ?\Closure $closure = null; |
19 | 21 | public function __destruct() |
20 | 22 | { |
21 | - if ($this->closure !== null) { |
|
23 | + if ($this->closure !== null) |
|
24 | + { |
|
22 | 25 | ($this->closure)(); |
23 | 26 | } |
24 | 27 | } |
25 | 28 | }; |
26 | - $finalizer->closure = static function () use ($container) { |
|
29 | + $finalizer->closure = static function () use ($container) |
|
30 | + { |
|
27 | 31 | $container->hasInstance('finalizer'); |
28 | 32 | }; |
29 | 33 | $container->bind('finalizer', $finalizer); |