@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | public function testInvalidInjector(): void |
46 | 46 | { |
47 | - $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an " . |
|
47 | + $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an ". |
|
48 | 48 | "instance of InjectorInterface for 'Spiral\Tests\Core\Fixtures\TestConfig'"; |
49 | 49 | $this->expectException(InjectionException::class); |
50 | 50 | $this->expectExceptionMessage($excepted); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | public function testInvalidRuntimeInjector(): void |
72 | 72 | { |
73 | - $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an " . |
|
73 | + $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an ". |
|
74 | 74 | "instance of InjectorInterface for 'Spiral\Tests\Core\Fixtures\TestConfig'"; |
75 | 75 | $this->expectException(InjectionException::class); |
76 | 76 | $this->expectExceptionMessage($excepted); |
@@ -200,10 +200,10 @@ discard block |
||
200 | 200 | public function testExtendedInjectorAnonClassObjectParam(): void |
201 | 201 | { |
202 | 202 | $container = new Container(); |
203 | - $container->bind(\stdClass::class, new Injectable(new class implements Container\InjectorInterface { |
|
204 | - public function createInjection(\ReflectionClass $class, object|string|null $context = null): object |
|
203 | + $container->bind(\stdClass::class, new Injectable(new class implements Container\InjectorInterface{ |
|
204 | + public function createInjection(\ReflectionClass $class, object | string | null $context = null): object |
|
205 | 205 | { |
206 | - return (object) ['context' => $context]; |
|
206 | + return (object)['context' => $context]; |
|
207 | 207 | } |
208 | 208 | })); |
209 | 209 | |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | public function testExtendedInjectorAnonClassMixedParam(): void |
218 | 218 | { |
219 | 219 | $container = new Container(); |
220 | - $container->bind(\stdClass::class, new Injectable(new class implements Container\InjectorInterface { |
|
220 | + $container->bind(\stdClass::class, new Injectable(new class implements Container\InjectorInterface{ |
|
221 | 221 | public function createInjection(\ReflectionClass $class, mixed $context = null): object |
222 | 222 | { |
223 | - return (object) ['context' => $context]; |
|
223 | + return (object)['context' => $context]; |
|
224 | 224 | } |
225 | 225 | })); |
226 | 226 |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | { |
22 | 22 | $fiber = new \Fiber($callable); |
23 | 23 | $value = $fiber->start(); |
24 | - while (!$fiber->isTerminated()) { |
|
25 | - if ($check !== null) { |
|
26 | - try { |
|
24 | + while (!$fiber->isTerminated()){ |
|
25 | + if ($check !== null){ |
|
26 | + try{ |
|
27 | 27 | $value = $check($value); |
28 | - } catch (\Throwable $e) { |
|
28 | + }catch (\Throwable $e){ |
|
29 | 29 | $value = $fiber->throw($e); |
30 | 30 | continue; |
31 | 31 | } |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | /** Values that were suspended by the fiber. */ |
48 | 48 | $suspends = []; |
49 | 49 | $results = []; |
50 | - foreach ($callables as $key => $callable) { |
|
50 | + foreach ($callables as $key => $callable){ |
|
51 | 51 | $fiberGenerators[$key] = (static function () use ($callable) { |
52 | 52 | $fiber = new \Fiber($callable); |
53 | 53 | // Get ready |
54 | 54 | yield null; |
55 | 55 | |
56 | 56 | $value = yield $fiber->start(); |
57 | - while (!$fiber->isTerminated()) { |
|
57 | + while (!$fiber->isTerminated()){ |
|
58 | 58 | $value = yield $fiber->resume($value); |
59 | 59 | } |
60 | 60 | return $fiber->getReturn(); |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | |
67 | - while ($fiberGenerators !== []) { |
|
68 | - foreach ($fiberGenerators as $key => $generator) { |
|
69 | - try { |
|
67 | + while ($fiberGenerators !== []){ |
|
68 | + foreach ($fiberGenerators as $key => $generator){ |
|
69 | + try{ |
|
70 | 70 | $suspends[$key] = $generator->send($suspends[$key]); |
71 | - if (!$generator->valid()) { |
|
71 | + if (!$generator->valid()){ |
|
72 | 72 | $results[$key] = $generator->getReturn(); |
73 | 73 | unset($fiberGenerators[$key]); |
74 | 74 | } |
75 | - } catch (\Throwable $e) { |
|
75 | + }catch (\Throwable $e){ |
|
76 | 76 | unset($fiberGenerators[$key]); |
77 | 77 | $results[$key] = $e; |
78 | 78 | } |
@@ -21,11 +21,16 @@ discard block |
||
21 | 21 | { |
22 | 22 | $fiber = new \Fiber($callable); |
23 | 23 | $value = $fiber->start(); |
24 | - while (!$fiber->isTerminated()) { |
|
25 | - if ($check !== null) { |
|
26 | - try { |
|
24 | + while (!$fiber->isTerminated()) |
|
25 | + { |
|
26 | + if ($check !== null) |
|
27 | + { |
|
28 | + try |
|
29 | + { |
|
27 | 30 | $value = $check($value); |
28 | - } catch (\Throwable $e) { |
|
31 | + } |
|
32 | + catch (\Throwable $e) |
|
33 | + { |
|
29 | 34 | $value = $fiber->throw($e); |
30 | 35 | continue; |
31 | 36 | } |
@@ -47,14 +52,17 @@ discard block |
||
47 | 52 | /** Values that were suspended by the fiber. */ |
48 | 53 | $suspends = []; |
49 | 54 | $results = []; |
50 | - foreach ($callables as $key => $callable) { |
|
51 | - $fiberGenerators[$key] = (static function () use ($callable) { |
|
55 | + foreach ($callables as $key => $callable) |
|
56 | + { |
|
57 | + $fiberGenerators[$key] = (static function () use ($callable) |
|
58 | + { |
|
52 | 59 | $fiber = new \Fiber($callable); |
53 | 60 | // Get ready |
54 | 61 | yield null; |
55 | 62 | |
56 | 63 | $value = yield $fiber->start(); |
57 | - while (!$fiber->isTerminated()) { |
|
64 | + while (!$fiber->isTerminated()) |
|
65 | + { |
|
58 | 66 | $value = yield $fiber->resume($value); |
59 | 67 | } |
60 | 68 | return $fiber->getReturn(); |
@@ -64,15 +72,21 @@ discard block |
||
64 | 72 | } |
65 | 73 | |
66 | 74 | |
67 | - while ($fiberGenerators !== []) { |
|
68 | - foreach ($fiberGenerators as $key => $generator) { |
|
69 | - try { |
|
75 | + while ($fiberGenerators !== []) |
|
76 | + { |
|
77 | + foreach ($fiberGenerators as $key => $generator) |
|
78 | + { |
|
79 | + try |
|
80 | + { |
|
70 | 81 | $suspends[$key] = $generator->send($suspends[$key]); |
71 | - if (!$generator->valid()) { |
|
82 | + if (!$generator->valid()) |
|
83 | + { |
|
72 | 84 | $results[$key] = $generator->getReturn(); |
73 | 85 | unset($fiberGenerators[$key]); |
74 | 86 | } |
75 | - } catch (\Throwable $e) { |
|
87 | + } |
|
88 | + catch (\Throwable $e) |
|
89 | + { |
|
76 | 90 | unset($fiberGenerators[$key]); |
77 | 91 | $results[$key] = $e; |
78 | 92 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ); |
60 | 60 | |
61 | 61 | self::assertCount(5, $result); |
62 | - foreach ($result as $suspendValue) { |
|
62 | + foreach ($result as $suspendValue){ |
|
63 | 63 | self::assertSame(self::TEST_DATA, $suspendValue); |
64 | 64 | } |
65 | 65 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | ); |
78 | 78 | |
79 | 79 | self::assertCount(2, $result); |
80 | - foreach ($result as $suspendValue) { |
|
80 | + foreach ($result as $suspendValue){ |
|
81 | 81 | self::assertSame(self::TEST_DATA, $suspendValue); |
82 | 82 | } |
83 | 83 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $result = ''; |
94 | 94 | $result .= \Fiber::suspend('foo'); |
95 | 95 | $result .= \Fiber::suspend('bar'); |
96 | - return $result . \Fiber::suspend('error'); |
|
96 | + return $result.\Fiber::suspend('error'); |
|
97 | 97 | }, |
98 | 98 | ), |
99 | 99 | static fn(string $suspendValue): string => $suspendValue !== 'error' |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | $result = ''; |
111 | 111 | $result .= \Fiber::suspend('foo'); |
112 | 112 | $result .= \Fiber::suspend('bar'); |
113 | - try { |
|
113 | + try{ |
|
114 | 114 | $result .= \Fiber::suspend('error'); |
115 | - } catch (\Throwable $e) { |
|
115 | + }catch (\Throwable $e){ |
|
116 | 116 | $result .= $e->getMessage(); |
117 | 117 | } |
118 | - return $result . \Fiber::suspend('baz'); |
|
118 | + return $result.\Fiber::suspend('baz'); |
|
119 | 119 | }, |
120 | 120 | ), |
121 | 121 | static fn(string $suspendValue): string => $suspendValue !== 'error' |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | ?callable $load = null, |
139 | 139 | ?Container $container = null, |
140 | 140 | ): callable { |
141 | - return static function () use ($load, $container): array { |
|
141 | + return static function () use ($load, $container) : array { |
|
142 | 142 | // The function should be called in a fiber |
143 | 143 | self::assertNotNull(\Fiber::getCurrent()); |
144 | 144 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $resource = $c3->get('resource'); |
160 | 160 | self::assertInstanceOf(\DateTimeImmutable::class, $c3->get('bar')); |
161 | 161 | self::assertInstanceOf(\stdClass::class, $resource); |
162 | - foreach (self::TEST_DATA as $key => $value) { |
|
162 | + foreach (self::TEST_DATA as $key => $value){ |
|
163 | 163 | $resource->$key = $value; |
164 | 164 | $load === null or $load(); |
165 | 165 | \Fiber::suspend($value); |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | }, ['foo' => new \DateTime()]); |
173 | 173 | self::assertFalse($c1->has('foo')); |
174 | 174 | |
175 | - self::assertSame(self::TEST_DATA, (array) $result); |
|
176 | - return (array) $result; |
|
175 | + self::assertSame(self::TEST_DATA, (array)$result); |
|
176 | + return (array)$result; |
|
177 | 177 | }; |
178 | 178 | } |
179 | 179 | } |
@@ -59,7 +59,8 @@ discard block |
||
59 | 59 | ); |
60 | 60 | |
61 | 61 | self::assertCount(5, $result); |
62 | - foreach ($result as $suspendValue) { |
|
62 | + foreach ($result as $suspendValue) |
|
63 | + { |
|
63 | 64 | self::assertSame(self::TEST_DATA, $suspendValue); |
64 | 65 | } |
65 | 66 | } |
@@ -77,7 +78,8 @@ discard block |
||
77 | 78 | ); |
78 | 79 | |
79 | 80 | self::assertCount(2, $result); |
80 | - foreach ($result as $suspendValue) { |
|
81 | + foreach ($result as $suspendValue) |
|
82 | + { |
|
81 | 83 | self::assertSame(self::TEST_DATA, $suspendValue); |
82 | 84 | } |
83 | 85 | } |
@@ -110,9 +112,12 @@ discard block |
||
110 | 112 | $result = ''; |
111 | 113 | $result .= \Fiber::suspend('foo'); |
112 | 114 | $result .= \Fiber::suspend('bar'); |
113 | - try { |
|
115 | + try |
|
116 | + { |
|
114 | 117 | $result .= \Fiber::suspend('error'); |
115 | - } catch (\Throwable $e) { |
|
118 | + } |
|
119 | + catch (\Throwable $e) |
|
120 | + { |
|
116 | 121 | $result .= $e->getMessage(); |
117 | 122 | } |
118 | 123 | return $result . \Fiber::suspend('baz'); |
@@ -146,7 +151,8 @@ discard block |
||
146 | 151 | $c1 = $container ?? new Container(); |
147 | 152 | $c1->bindSingleton('resource', new \stdClass()); |
148 | 153 | |
149 | - $result = $c1->runScoped(static function (Container $c2) use ($load) { |
|
154 | + $result = $c1->runScoped(static function (Container $c2) use ($load) |
|
155 | + { |
|
150 | 156 | // check local binding |
151 | 157 | self::assertTrue($c2->has('foo')); |
152 | 158 | self::assertInstanceOf(\DateTime::class, $c2->get('foo')); |
@@ -159,7 +165,8 @@ discard block |
||
159 | 165 | $resource = $c3->get('resource'); |
160 | 166 | self::assertInstanceOf(\DateTimeImmutable::class, $c3->get('bar')); |
161 | 167 | self::assertInstanceOf(\stdClass::class, $resource); |
162 | - foreach (self::TEST_DATA as $key => $value) { |
|
168 | + foreach (self::TEST_DATA as $key => $value) |
|
169 | + { |
|
163 | 170 | $resource->$key = $value; |
164 | 171 | $load === null or $load(); |
165 | 172 | \Fiber::suspend($value); |
@@ -7,4 +7,4 @@ |
||
7 | 7 | use Spiral\Core\Attribute\Scope; |
8 | 8 | |
9 | 9 | #[Scope('foo')] |
10 | -final class AttrScopeFoo {} |
|
10 | +final class AttrScopeFoo{} |
@@ -7,4 +7,6 @@ |
||
7 | 7 | use Spiral\Core\Attribute\Scope; |
8 | 8 | |
9 | 9 | #[Scope('foo')] |
10 | -final class AttrScopeFoo {} |
|
10 | +final class AttrScopeFoo |
|
11 | +{ |
|
12 | +} |
@@ -10,7 +10,7 @@ |
||
10 | 10 | { |
11 | 11 | public function __construct( |
12 | 12 | protected ContainerInterface $container, |
13 | - ) {} |
|
13 | + ){} |
|
14 | 14 | |
15 | 15 | public function make(string $key): mixed |
16 | 16 | { |
@@ -10,7 +10,8 @@ |
||
10 | 10 | { |
11 | 11 | public function __construct( |
12 | 12 | protected ContainerInterface $container, |
13 | - ) {} |
|
13 | + ) { |
|
14 | +} |
|
14 | 15 | |
15 | 16 | public function make(string $key): mixed |
16 | 17 | { |
@@ -7,10 +7,10 @@ |
||
7 | 7 | final class Context implements ContextInterface |
8 | 8 | { |
9 | 9 | public function __construct( |
10 | - public \Stringable|string|null $value, |
|
11 | - ) {} |
|
10 | + public \Stringable | string | null $value, |
|
11 | + ){} |
|
12 | 12 | |
13 | - public function getValue(): \Stringable|string|null |
|
13 | + public function getValue(): \Stringable | string | null |
|
14 | 14 | { |
15 | 15 | return $this->value; |
16 | 16 | } |
@@ -8,7 +8,8 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | public \Stringable|string|null $value, |
11 | - ) {} |
|
11 | + ) { |
|
12 | +} |
|
12 | 13 | |
13 | 14 | public function getValue(): \Stringable|string|null |
14 | 15 | { |
@@ -13,7 +13,7 @@ |
||
13 | 13 | { |
14 | 14 | public function __construct( |
15 | 15 | private LoggerInterface $logger, |
16 | - ) {} |
|
16 | + ){} |
|
17 | 17 | |
18 | 18 | public function createInjection(\ReflectionClass $class, ?string $context = null): LoggerInterface |
19 | 19 | { |
@@ -13,7 +13,8 @@ |
||
13 | 13 | { |
14 | 14 | public function __construct( |
15 | 15 | private LoggerInterface $logger, |
16 | - ) {} |
|
16 | + ) { |
|
17 | +} |
|
17 | 18 | |
18 | 19 | public function createInjection(\ReflectionClass $class, ?string $context = null): LoggerInterface |
19 | 20 | { |
@@ -8,5 +8,5 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | public \DateTimeInterface $logger, |
11 | - ) {} |
|
11 | + ){} |
|
12 | 12 | } |
@@ -8,5 +8,6 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | public \DateTimeInterface $logger, |
11 | - ) {} |
|
11 | + ) { |
|
12 | +} |
|
12 | 13 | } |
@@ -9,4 +9,4 @@ |
||
9 | 9 | |
10 | 10 | #[Singleton] |
11 | 11 | #[Scope('foo')] |
12 | -final class AttrScopeFooSingleton {} |
|
12 | +final class AttrScopeFooSingleton{} |
@@ -9,4 +9,6 @@ |
||
9 | 9 | |
10 | 10 | #[Singleton] |
11 | 11 | #[Scope('foo')] |
12 | -final class AttrScopeFooSingleton {} |
|
12 | +final class AttrScopeFooSingleton |
|
13 | +{ |
|
14 | +} |