@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public function testInvalidInjector(): void |
| 41 | 41 | { |
| 42 | - $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an " . |
|
| 42 | + $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an ". |
|
| 43 | 43 | "instance of InjectorInterface for 'Spiral\Tests\Core\Fixtures\TestConfig'"; |
| 44 | 44 | $this->expectException(InjectionException::class); |
| 45 | 45 | $this->expectExceptionMessage($excepted); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | public function testInvalidRuntimeInjector(): void |
| 67 | 67 | { |
| 68 | - $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an " . |
|
| 68 | + $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an ". |
|
| 69 | 69 | "instance of InjectorInterface for 'Spiral\Tests\Core\Fixtures\TestConfig'"; |
| 70 | 70 | $this->expectException(InjectionException::class); |
| 71 | 71 | $this->expectExceptionMessage($excepted); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $container->bind(ConfigsInterface::class, $configurator); |
| 103 | 103 | |
| 104 | 104 | $configurator->shouldReceive('createInjection') |
| 105 | - ->with(m::on(static function (ReflectionClass $r) { |
|
| 105 | + ->with(m::on(static function (ReflectionClass $r){ |
|
| 106 | 106 | return $r->getName() === TestConfig::class; |
| 107 | 107 | }), null) |
| 108 | 108 | ->andReturn($expected); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $container->bind(ConfigsInterface::class, $configurator); |
| 120 | 120 | |
| 121 | 121 | $configurator->shouldReceive('createInjection') |
| 122 | - ->with(m::on(static function (ReflectionClass $r) { |
|
| 122 | + ->with(m::on(static function (ReflectionClass $r){ |
|
| 123 | 123 | return $r->getName() === TestConfig::class; |
| 124 | 124 | }), 'context') |
| 125 | 125 | ->andReturn($expected); |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | public function testExtendedInjectorAnonClassObjectParam(): void |
| 208 | 208 | { |
| 209 | 209 | $container = new Container(); |
| 210 | - $container->bind(stdClass::class, new Injectable(new class implements Container\InjectorInterface { |
|
| 211 | - public function createInjection(\ReflectionClass $class, object|string|null $context = null): object |
|
| 210 | + $container->bind(stdClass::class, new Injectable(new class implements Container\InjectorInterface{ |
|
| 211 | + public function createInjection(\ReflectionClass $class, object | string | null $context = null): object |
|
| 212 | 212 | { |
| 213 | 213 | return (object)['context' => $context]; |
| 214 | 214 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | public function testExtendedInjectorAnonClassMixedParam(): void |
| 224 | 224 | { |
| 225 | 225 | $container = new Container(); |
| 226 | - $container->bind(stdClass::class, new Injectable(new class implements Container\InjectorInterface { |
|
| 226 | + $container->bind(stdClass::class, new Injectable(new class implements Container\InjectorInterface{ |
|
| 227 | 227 | public function createInjection(\ReflectionClass $class, mixed $context = null): object |
| 228 | 228 | { |
| 229 | 229 | return (object)['context' => $context]; |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class ExtendedContextInjector implements InjectorInterface |
| 14 | 14 | { |
| 15 | - public function createInjection(\ReflectionClass $class, \ReflectionParameter|string|null $context = null): object |
|
| 15 | + public function createInjection(\ReflectionClass $class, \ReflectionParameter | string | null $context = null): object |
|
| 16 | 16 | { |
| 17 | 17 | return (object)['context' => $context]; |
| 18 | 18 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | use DestructorTrait; |
| 20 | 20 | |
| 21 | 21 | private State $state; |
| 22 | - private FactoryInterface|Factory $factory; |
|
| 22 | + private FactoryInterface | Factory $factory; |
|
| 23 | 23 | |
| 24 | 24 | public function __construct(Registry $constructor) |
| 25 | 25 | { |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | * @throws ContainerException |
| 48 | 48 | * @throws \Throwable |
| 49 | 49 | */ |
| 50 | - public function get(string|Autowire $id, \Stringable|string|null $context = null): mixed |
|
| 50 | + public function get(string | Autowire $id, \Stringable | string | null $context = null): mixed |
|
| 51 | 51 | { |
| 52 | - if ($id instanceof Autowire) { |
|
| 52 | + if ($id instanceof Autowire){ |
|
| 53 | 53 | return $id->resolve($this->factory); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -49,7 +49,8 @@ |
||
| 49 | 49 | */ |
| 50 | 50 | public function get(string|Autowire $id, \Stringable|string|null $context = null): mixed |
| 51 | 51 | { |
| 52 | - if ($id instanceof Autowire) { |
|
| 52 | + if ($id instanceof Autowire) |
|
| 53 | + { |
|
| 53 | 54 | return $id->resolve($this->factory); |
| 54 | 55 | } |
| 55 | 56 | |
@@ -17,9 +17,9 @@ |
||
| 17 | 17 | public function __construct( |
| 18 | 18 | public readonly string $alias, |
| 19 | 19 | public string $class, |
| 20 | - public \Stringable|string|null $context = null, |
|
| 20 | + public \Stringable | string | null $context = null, |
|
| 21 | 21 | public ?bool $singleton = null, |
| 22 | 22 | public ?\ReflectionClass $reflection = null, |
| 23 | - ) { |
|
| 23 | + ){ |
|
| 24 | 24 | } |
| 25 | 25 | } |
@@ -34,24 +34,24 @@ discard block |
||
| 34 | 34 | yield [$from(fn(string $string = self::STRING_CONST) => 0), 'string $string = self::STRING_CONST']; |
| 35 | 35 | yield [ |
| 36 | 36 | $from(fn(string $string = ProxyClassRendererTest::STRING_CONST) => 0), |
| 37 | - 'string $string = \\' . self::class . '::STRING_CONST', |
|
| 37 | + 'string $string = \\'.self::class.'::STRING_CONST', |
|
| 38 | 38 | ]; |
| 39 | - yield [$from(fn(string|int $string = self::INT_CONST) => 0), 'string|int $string = self::INT_CONST']; |
|
| 39 | + yield [$from(fn(string | int $string = self::INT_CONST) => 0), 'string|int $string = self::INT_CONST']; |
|
| 40 | 40 | yield [$from(fn(mixed $string = 42) => 0), 'mixed $string = 42']; |
| 41 | 41 | yield [$from(fn(int $string = 42) => 0), 'int $string = 42']; |
| 42 | 42 | yield [$from(fn(float $string = 42) => 0), 'float $string = 42.0']; |
| 43 | 43 | yield [$from(fn(?bool $string = false) => 0), '?bool $string = false']; |
| 44 | - yield [$from(fn(bool|null $string = true) => 0), '?bool $string = true']; |
|
| 44 | + yield [$from(fn(bool | null $string = true) => 0), '?bool $string = true']; |
|
| 45 | 45 | yield [$from(fn(object $string = null) => 0), '?object $string = NULL']; |
| 46 | 46 | yield [$from(fn(iterable $string = null) => 0), '?iterable $string = NULL']; |
| 47 | 47 | yield [$from(fn(Countable&ArrayAccess $val) => 0), '\Countable&\ArrayAccess $val']; |
| 48 | 48 | yield [$from(fn(string ...$val) => 0), 'string ...$val']; |
| 49 | - yield [$from(fn(string|int ...$val) => 0), 'string|int ...$val']; |
|
| 50 | - yield [$from(fn(string|int &$link) => 0), 'string|int &$link']; |
|
| 49 | + yield [$from(fn(string | int ...$val) => 0), 'string|int ...$val']; |
|
| 50 | + yield [$from(fn(string | int &$link) => 0), 'string|int &$link']; |
|
| 51 | 51 | yield [$from(self::withSelf(...)), \sprintf('\%s $self = new self()', self::class)]; |
| 52 | 52 | yield [$from(fn(object $link = new \stdClass()) => 0), 'object $link = new \stdClass()']; |
| 53 | 53 | yield [ |
| 54 | - $from(fn(#[Proxy] float|int|\stdClass|null $string = new \stdClass(1, 2, bar: "\n'zero")) => 0), |
|
| 54 | + $from(fn(#[Proxy] float | int | \stdClass | null $string = new \stdClass(1, 2, bar: "\n'zero")) => 0), |
|
| 55 | 55 | "\stdClass|int|float|null \$string = new \stdClass(1, 2, bar: '\n\'zero')", |
| 56 | 56 | ]; |
| 57 | 57 | yield [ |
@@ -76,18 +76,18 @@ discard block |
||
| 76 | 76 | public const INT_CONST = 42; |
| 77 | 77 | |
| 78 | 78 | #[ExpectedAttribute('public function test1(...$variadic)')] |
| 79 | - public function test1(...$variadic) {} |
|
| 79 | + public function test1(...$variadic){} |
|
| 80 | 80 | #[ExpectedAttribute('public function test2(string|int $string = self::INT_CONST): string|int')] |
| 81 | - public function test2(string|int $string = self::INT_CONST): string|int {} |
|
| 81 | + public function test2(string | int $string = self::INT_CONST): string | int {} |
|
| 82 | 82 | #[ExpectedAttribute('public function test3(object $obj = new \stdClass(new \stdClass(), new \stdClass()))')] |
| 83 | - public function test3(object $obj = new stdClass(new stdClass(), new stdClass())) {} |
|
| 84 | - #[ExpectedAttribute('public function test4(): \\' . ProxyClassRendererTest::class)] |
|
| 83 | + public function test3(object $obj = new stdClass(new stdClass(), new stdClass())){} |
|
| 84 | + #[ExpectedAttribute('public function test4(): \\'.ProxyClassRendererTest::class)] |
|
| 85 | 85 | public function test4(): ProxyClassRendererTest {} |
| 86 | 86 | #[ExpectedAttribute('public function &test5(): string')] |
| 87 | 87 | public function &test5(): string {} |
| 88 | 88 | }; |
| 89 | 89 | |
| 90 | - foreach ((new \ReflectionClass($class))->getMethods() as $method) { |
|
| 90 | + foreach ((new \ReflectionClass($class))->getMethods() as $method){ |
|
| 91 | 91 | $expected = $method->getAttributes(ExpectedAttribute::class)[0]->newInstance(); |
| 92 | 92 | |
| 93 | 93 | yield [$method, $expected->value]; |
@@ -117,6 +117,6 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | public function __construct( |
| 119 | 119 | public readonly string $value, |
| 120 | - ) { |
|
| 120 | + ){ |
|
| 121 | 121 | } |
| 122 | 122 | } |
@@ -72,22 +72,28 @@ |
||
| 72 | 72 | |
| 73 | 73 | public static function provideRenderMethod(): iterable |
| 74 | 74 | { |
| 75 | - $class = new class { |
|
| 75 | + $class = new class |
|
| 76 | + { |
|
| 76 | 77 | public const INT_CONST = 42; |
| 77 | 78 | |
| 78 | 79 | #[ExpectedAttribute('public function test1(...$variadic)')] |
| 79 | - public function test1(...$variadic) {} |
|
| 80 | + public function test1(...$variadic) |
|
| 81 | + { |
|
| 82 | +} |
|
| 80 | 83 | #[ExpectedAttribute('public function test2(string|int $string = self::INT_CONST): string|int')] |
| 81 | 84 | public function test2(string|int $string = self::INT_CONST): string|int {} |
| 82 | 85 | #[ExpectedAttribute('public function test3(object $obj = new \stdClass(new \stdClass(), new \stdClass()))')] |
| 83 | - public function test3(object $obj = new stdClass(new stdClass(), new stdClass())) {} |
|
| 86 | + public function test3(object $obj = new stdClass(new stdClass(), new stdClass())) |
|
| 87 | + { |
|
| 88 | +} |
|
| 84 | 89 | #[ExpectedAttribute('public function test4(): \\' . ProxyClassRendererTest::class)] |
| 85 | 90 | public function test4(): ProxyClassRendererTest {} |
| 86 | 91 | #[ExpectedAttribute('public function &test5(): string')] |
| 87 | 92 | public function &test5(): string {} |
| 88 | 93 | }; |
| 89 | 94 | |
| 90 | - foreach ((new \ReflectionClass($class))->getMethods() as $method) { |
|
| 95 | + foreach ((new \ReflectionClass($class))->getMethods() as $method) |
|
| 96 | + { |
|
| 91 | 97 | $expected = $method->getAttributes(ExpectedAttribute::class)[0]->newInstance(); |
| 92 | 98 | |
| 93 | 99 | yield [$method, $expected->value]; |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | $proxy = $$var; |
| 72 | 72 | self::assertSame(['foo', 'bar', 'baz', 69], $proxy->extraVariadic('foo', 'bar', 'baz', 69)); |
| 73 | 73 | self::assertSame( |
| 74 | - ['foo' => 'foo','zap' => 'bar', 'gas' => 69], |
|
| 74 | + ['foo' => 'foo', 'zap' => 'bar', 'gas' => 69], |
|
| 75 | 75 | $proxy->extraVariadic(foo: 'foo', zap: 'bar', gas: 69), |
| 76 | 76 | ); |
| 77 | 77 | }); |
@@ -28,7 +28,8 @@ discard block |
||
| 28 | 28 | $root->bindSingleton(MockInterface::class, Stub\MockInterfaceImpl::class); |
| 29 | 29 | $root->bindSingleton(EmptyInterface::class, Stub\MockInterfaceImpl::class); |
| 30 | 30 | |
| 31 | - $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy(magicCall: true)] EmptyInterface $empty) use ($var) { |
|
| 31 | + $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy(magicCall: true)] EmptyInterface $empty) use ($var) |
|
| 32 | + { |
|
| 32 | 33 | /** @var MockInterfaceImpl $proxy */ |
| 33 | 34 | $proxy = $$var; |
| 34 | 35 | $proxy->bar(name: 'foo'); // Possible to run |
@@ -47,7 +48,8 @@ discard block |
||
| 47 | 48 | $root->bindSingleton(MockInterface::class, Stub\MockInterfaceImpl::class); |
| 48 | 49 | $root->bindSingleton(EmptyInterface::class, Stub\MockInterfaceImpl::class); |
| 49 | 50 | |
| 50 | - $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) { |
|
| 51 | + $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) |
|
| 52 | + { |
|
| 51 | 53 | /** @var MockInterfaceImpl $proxy */ |
| 52 | 54 | $proxy = $$var; |
| 53 | 55 | self::assertSame(['foo', 'bar', 'baz', 69], $proxy->extra('foo', 'bar', 'baz', 69)); |
@@ -66,7 +68,8 @@ discard block |
||
| 66 | 68 | $root->bindSingleton(MockInterface::class, Stub\MockInterfaceImpl::class); |
| 67 | 69 | $root->bindSingleton(EmptyInterface::class, Stub\MockInterfaceImpl::class); |
| 68 | 70 | |
| 69 | - $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) { |
|
| 71 | + $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) |
|
| 72 | + { |
|
| 70 | 73 | /** @var MockInterfaceImpl $proxy */ |
| 71 | 74 | $proxy = $$var; |
| 72 | 75 | self::assertSame(['foo', 'bar', 'baz', 69], $proxy->extraVariadic('foo', 'bar', 'baz', 69)); |
@@ -90,7 +93,8 @@ discard block |
||
| 90 | 93 | $root->bindSingleton(MockInterface::class, Stub\MockInterfaceImpl::class); |
| 91 | 94 | $root->bindSingleton(EmptyInterface::class, Stub\MockInterfaceImpl::class); |
| 92 | 95 | |
| 93 | - $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) { |
|
| 96 | + $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) |
|
| 97 | + { |
|
| 94 | 98 | /** @var MockInterfaceImpl $proxy */ |
| 95 | 99 | $proxy = $$var; |
| 96 | 100 | $str = 'bar'; |
@@ -112,7 +116,8 @@ discard block |
||
| 112 | 116 | $root->bindSingleton(MockInterface::class, Stub\MockInterfaceImpl::class); |
| 113 | 117 | $root->bindSingleton(EmptyInterface::class, Stub\MockInterfaceImpl::class); |
| 114 | 118 | |
| 115 | - $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) { |
|
| 119 | + $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) |
|
| 120 | + { |
|
| 116 | 121 | /** @var MockInterfaceImpl $proxy */ |
| 117 | 122 | $proxy = $$var; |
| 118 | 123 | |
@@ -137,7 +142,8 @@ discard block |
||
| 137 | 142 | $root->bindSingleton(MockInterface::class, Stub\MockInterfaceImpl::class); |
| 138 | 143 | $root->bindSingleton(EmptyInterface::class, Stub\MockInterfaceImpl::class); |
| 139 | 144 | |
| 140 | - $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) { |
|
| 145 | + $root->invoke(static function (#[Proxy] MockInterface $mock, #[Proxy] EmptyInterface $empty) use ($var) |
|
| 146 | + { |
|
| 141 | 147 | /** @var MockInterfaceImpl $proxy */ |
| 142 | 148 | $proxy = $$var; |
| 143 | 149 | $str1 = 'bar'; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | return $name; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public function qux(int|string $age = 42): string|int |
|
| 18 | + public function qux(int | string $age = 42): string | int |
|
| 19 | 19 | { |
| 20 | 20 | return $age; |
| 21 | 21 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | public function concat(string $prefix, string &$byLink): array |
| 39 | 39 | { |
| 40 | - $byLink = $prefix . $byLink; |
|
| 40 | + $byLink = $prefix.$byLink; |
|
| 41 | 41 | return \func_get_args(); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | public function concatMultiple(string $prefix, string &...$byLink): array |
| 50 | 50 | { |
| 51 | - foreach ($byLink as $k => $link) { |
|
| 52 | - $byLink[$k] = $prefix . $link; |
|
| 51 | + foreach ($byLink as $k => $link){ |
|
| 52 | + $byLink[$k] = $prefix.$link; |
|
| 53 | 53 | unset($link); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -48,7 +48,8 @@ |
||
| 48 | 48 | |
| 49 | 49 | public function concatMultiple(string $prefix, string &...$byLink): array |
| 50 | 50 | { |
| 51 | - foreach ($byLink as $k => $link) { |
|
| 51 | + foreach ($byLink as $k => $link) |
|
| 52 | + { |
|
| 52 | 53 | $byLink[$k] = $prefix . $link; |
| 53 | 54 | unset($link); |
| 54 | 55 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | public function baz(string $name, int $age): string; |
| 14 | 14 | |
| 15 | - public function qux(string|int $age = 42): string|int; |
|
| 15 | + public function qux(string | int $age = 42): string | int; |
|
| 16 | 16 | |
| 17 | 17 | public function space(mixed $test age = 42): mixed; |
| 18 | 18 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | FiberHelper::runInFiber( |
| 32 | 32 | self::functionScopedTestDataIterator(), |
| 33 | - static function (mixed $suspendValue) { |
|
| 33 | + static function (mixed $suspendValue){ |
|
| 34 | 34 | self::assertNull(ContainerScope::getContainer()); |
| 35 | 35 | self::assertTrue(\in_array($suspendValue, self::TEST_DATA, true)); |
| 36 | 36 | }, |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | 65 | self::assertCount(5, $result); |
| 66 | - foreach ($result as $suspendValue) { |
|
| 66 | + foreach ($result as $suspendValue){ |
|
| 67 | 67 | self::assertSame(self::TEST_DATA, $suspendValue); |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | 83 | self::assertCount(2, $result); |
| 84 | - foreach ($result as $suspendValue) { |
|
| 84 | + foreach ($result as $suspendValue){ |
|
| 85 | 85 | self::assertSame(self::TEST_DATA, $suspendValue); |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $this->expectExceptionMessage('test'); |
| 93 | 93 | |
| 94 | 94 | FiberHelper::runInFiber( |
| 95 | - static function () { |
|
| 95 | + static function (){ |
|
| 96 | 96 | return (new Container())->runScoped( |
| 97 | 97 | function (): string { |
| 98 | 98 | $result = ''; |
@@ -114,15 +114,15 @@ discard block |
||
| 114 | 114 | public function testCatchThrownException(): void |
| 115 | 115 | { |
| 116 | 116 | $result = FiberHelper::runInFiber( |
| 117 | - static function () { |
|
| 117 | + static function (){ |
|
| 118 | 118 | return (new Container())->runScoped( |
| 119 | 119 | function (): string { |
| 120 | 120 | $result = ''; |
| 121 | 121 | $result .= Fiber::suspend('foo'); |
| 122 | 122 | $result .= Fiber::suspend('bar'); |
| 123 | - try { |
|
| 123 | + try{ |
|
| 124 | 124 | $result .= Fiber::suspend('error'); |
| 125 | - } catch (\Throwable $e) { |
|
| 125 | + }catch (\Throwable $e){ |
|
| 126 | 126 | $result .= $e->getMessage(); |
| 127 | 127 | } |
| 128 | 128 | $result .= Fiber::suspend('baz'); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | ?callable $load = null, |
| 153 | 153 | ?Container $container = null, |
| 154 | 154 | ): callable { |
| 155 | - return static function () use ($load, $container): array { |
|
| 155 | + return static function () use ($load, $container) : array { |
|
| 156 | 156 | // The function should be called in a fiber |
| 157 | 157 | self::assertNotNull(Fiber::getCurrent()); |
| 158 | 158 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | $resource = $c3->get('resource'); |
| 174 | 174 | self::assertInstanceOf(DateTimeImmutable::class, $c3->get('bar')); |
| 175 | 175 | self::assertInstanceOf(stdClass::class, $resource); |
| 176 | - foreach (self::TEST_DATA as $key => $value) { |
|
| 176 | + foreach (self::TEST_DATA as $key => $value){ |
|
| 177 | 177 | $resource->$key = $value; |
| 178 | 178 | $load === null or $load(); |
| 179 | 179 | Fiber::suspend($value); |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | }, ['foo' => new DateTime()]); |
| 187 | 187 | self::assertFalse($c1->has('foo')); |
| 188 | 188 | |
| 189 | - self::assertSame(self::TEST_DATA, (array) $result); |
|
| 190 | - return (array) $result; |
|
| 189 | + self::assertSame(self::TEST_DATA, (array)$result); |
|
| 190 | + return (array)$result; |
|
| 191 | 191 | }; |
| 192 | 192 | } |
| 193 | 193 | } |
@@ -30,7 +30,8 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | FiberHelper::runInFiber( |
| 32 | 32 | self::functionScopedTestDataIterator(), |
| 33 | - static function (mixed $suspendValue) { |
|
| 33 | + static function (mixed $suspendValue) |
|
| 34 | + { |
|
| 34 | 35 | self::assertNull(ContainerScope::getContainer()); |
| 35 | 36 | self::assertTrue(\in_array($suspendValue, self::TEST_DATA, true)); |
| 36 | 37 | }, |
@@ -63,7 +64,8 @@ discard block |
||
| 63 | 64 | ); |
| 64 | 65 | |
| 65 | 66 | self::assertCount(5, $result); |
| 66 | - foreach ($result as $suspendValue) { |
|
| 67 | + foreach ($result as $suspendValue) |
|
| 68 | + { |
|
| 67 | 69 | self::assertSame(self::TEST_DATA, $suspendValue); |
| 68 | 70 | } |
| 69 | 71 | } |
@@ -81,7 +83,8 @@ discard block |
||
| 81 | 83 | ); |
| 82 | 84 | |
| 83 | 85 | self::assertCount(2, $result); |
| 84 | - foreach ($result as $suspendValue) { |
|
| 86 | + foreach ($result as $suspendValue) |
|
| 87 | + { |
|
| 85 | 88 | self::assertSame(self::TEST_DATA, $suspendValue); |
| 86 | 89 | } |
| 87 | 90 | } |
@@ -92,7 +95,8 @@ discard block |
||
| 92 | 95 | $this->expectExceptionMessage('test'); |
| 93 | 96 | |
| 94 | 97 | FiberHelper::runInFiber( |
| 95 | - static function () { |
|
| 98 | + static function () |
|
| 99 | + { |
|
| 96 | 100 | return (new Container())->runScoped( |
| 97 | 101 | function (): string { |
| 98 | 102 | $result = ''; |
@@ -114,15 +118,19 @@ discard block |
||
| 114 | 118 | public function testCatchThrownException(): void |
| 115 | 119 | { |
| 116 | 120 | $result = FiberHelper::runInFiber( |
| 117 | - static function () { |
|
| 121 | + static function () |
|
| 122 | + { |
|
| 118 | 123 | return (new Container())->runScoped( |
| 119 | 124 | function (): string { |
| 120 | 125 | $result = ''; |
| 121 | 126 | $result .= Fiber::suspend('foo'); |
| 122 | 127 | $result .= Fiber::suspend('bar'); |
| 123 | - try { |
|
| 128 | + try |
|
| 129 | + { |
|
| 124 | 130 | $result .= Fiber::suspend('error'); |
| 125 | - } catch (\Throwable $e) { |
|
| 131 | + } |
|
| 132 | + catch (\Throwable $e) |
|
| 133 | + { |
|
| 126 | 134 | $result .= $e->getMessage(); |
| 127 | 135 | } |
| 128 | 136 | $result .= Fiber::suspend('baz'); |
@@ -160,20 +168,23 @@ discard block |
||
| 160 | 168 | $c1 = $container ?? new Container(); |
| 161 | 169 | $c1->bindSingleton('resource', new stdClass()); |
| 162 | 170 | |
| 163 | - $result = $c1->runScoped(static function (Container $c2) use ($load) { |
|
| 171 | + $result = $c1->runScoped(static function (Container $c2) use ($load) |
|
| 172 | + { |
|
| 164 | 173 | // check local binding |
| 165 | 174 | self::assertTrue($c2->has('foo')); |
| 166 | 175 | self::assertInstanceOf(DateTime::class, $c2->get('foo')); |
| 167 | 176 | |
| 168 | 177 | return $c2->runScoped( |
| 169 | - static function (ContainerInterface $c3) use ($load) { |
|
| 178 | + static function (ContainerInterface $c3) use ($load) |
|
| 179 | + { |
|
| 170 | 180 | // check local binding |
| 171 | 181 | self::assertTrue($c3->has('bar')); |
| 172 | 182 | |
| 173 | 183 | $resource = $c3->get('resource'); |
| 174 | 184 | self::assertInstanceOf(DateTimeImmutable::class, $c3->get('bar')); |
| 175 | 185 | self::assertInstanceOf(stdClass::class, $resource); |
| 176 | - foreach (self::TEST_DATA as $key => $value) { |
|
| 186 | + foreach (self::TEST_DATA as $key => $value) |
|
| 187 | + { |
|
| 177 | 188 | $resource->$key = $value; |
| 178 | 189 | $load === null or $load(); |
| 179 | 190 | Fiber::suspend($value); |