@@ -29,7 +29,8 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public function setUp(): void |
| 31 | 31 | { |
| 32 | - if (!\class_exists(Kernel::class)) { |
|
| 32 | + if (!\class_exists(Kernel::class)) |
|
| 33 | + { |
|
| 33 | 34 | $this->markTestSkipped('A "spiral/framework" dependency is required to run these tests'); |
| 34 | 35 | } |
| 35 | 36 | |
@@ -42,14 +43,16 @@ discard block |
||
| 42 | 43 | |
| 43 | 44 | $this->storage = new Storage($this->dir() . '/Fixtures/'); |
| 44 | 45 | |
| 45 | - foreach (static::STORE as $name) { |
|
| 46 | + foreach (static::STORE as $name) |
|
| 47 | + { |
|
| 46 | 48 | $this->storage->store($name); |
| 47 | 49 | } |
| 48 | 50 | } |
| 49 | 51 | |
| 50 | 52 | public function tearDown(): void |
| 51 | 53 | { |
| 52 | - foreach (static::STORE as $name) { |
|
| 54 | + foreach (static::STORE as $name) |
|
| 55 | + { |
|
| 53 | 56 | $this->storage->restore($name); |
| 54 | 57 | } |
| 55 | 58 | } |
@@ -135,9 +135,12 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | $container = new Container(); |
| 137 | 137 | |
| 138 | - try { |
|
| 138 | + try |
|
| 139 | + { |
|
| 139 | 140 | $container->get('invalid'); |
| 140 | - } catch (ContainerException $e) { |
|
| 141 | + } |
|
| 142 | + catch (ContainerException $e) |
|
| 143 | + { |
|
| 141 | 144 | self::assertSame(<<<MARKDOWN |
| 142 | 145 | Can't resolve `invalid`: undefined class or binding `invalid`. |
| 143 | 146 | Container trace list: |
@@ -166,9 +169,12 @@ discard block |
||
| 166 | 169 | { |
| 167 | 170 | $this->expectException(ContainerException::class); |
| 168 | 171 | |
| 169 | - try { |
|
| 172 | + try |
|
| 173 | + { |
|
| 170 | 174 | $container->get(ClassWithUndefinedDependency::class); |
| 171 | - } catch (ContainerException $e) { |
|
| 175 | + } |
|
| 176 | + catch (ContainerException $e) |
|
| 177 | + { |
|
| 172 | 178 | self::assertSame($message, $e->getMessage()); |
| 173 | 179 | |
| 174 | 180 | throw $e; |
@@ -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 | ], 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(function (Container $container): void { |
@@ -181,7 +181,9 @@ discard block |
||
| 181 | 181 | public function testHasShouldReturnTrueWhenSingletonIsAlreadyConstructed(): void |
| 182 | 182 | { |
| 183 | 183 | $container = new Container(); |
| 184 | - $class = new #[Singleton] class {}; |
|
| 184 | + $class = new #[Singleton] class |
|
| 185 | + { |
|
| 186 | +}; |
|
| 185 | 187 | |
| 186 | 188 | self::assertFalse($container->has($class::class)); |
| 187 | 189 | |
@@ -194,7 +196,8 @@ discard block |
||
| 194 | 196 | { |
| 195 | 197 | return new |
| 196 | 198 | #[Singleton] |
| 197 | - class { |
|
| 199 | + class |
|
| 200 | + { |
|
| 198 | 201 | public string $baz = 'baz'; |
| 199 | 202 | }; |
| 200 | 203 | } |
@@ -76,15 +76,21 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function testException(): void |
| 78 | 78 | { |
| 79 | - try { |
|
| 79 | + try |
|
| 80 | + { |
|
| 80 | 81 | fopen('spiral://non-exists', 'rb'); |
| 81 | - } catch (\Throwable $e) { |
|
| 82 | + } |
|
| 83 | + catch (\Throwable $e) |
|
| 84 | + { |
|
| 82 | 85 | self::assertStringContainsString('failed to open stream', $e->getMessage()); |
| 83 | 86 | } |
| 84 | 87 | |
| 85 | - try { |
|
| 88 | + try |
|
| 89 | + { |
|
| 86 | 90 | filemtime('spiral://non-exists'); |
| 87 | - } catch (\Throwable $e) { |
|
| 91 | + } |
|
| 92 | + catch (\Throwable $e) |
|
| 93 | + { |
|
| 88 | 94 | self::assertStringContainsString('stat failed', $e->getMessage()); |
| 89 | 95 | } |
| 90 | 96 | } |
@@ -94,15 +100,21 @@ discard block |
||
| 94 | 100 | */ |
| 95 | 101 | public function testExceptionPHP8(): void |
| 96 | 102 | { |
| 97 | - try { |
|
| 103 | + try |
|
| 104 | + { |
|
| 98 | 105 | fopen('spiral://non-exists', 'rb'); |
| 99 | - } catch (\Throwable $e) { |
|
| 106 | + } |
|
| 107 | + catch (\Throwable $e) |
|
| 108 | + { |
|
| 100 | 109 | self::assertStringContainsString('Failed to open stream', $e->getMessage()); |
| 101 | 110 | } |
| 102 | 111 | |
| 103 | - try { |
|
| 112 | + try |
|
| 113 | + { |
|
| 104 | 114 | filemtime('spiral://non-exists'); |
| 105 | - } catch (\Throwable $e) { |
|
| 115 | + } |
|
| 116 | + catch (\Throwable $e) |
|
| 117 | + { |
|
| 106 | 118 | self::assertStringContainsString('stat failed', $e->getMessage()); |
| 107 | 119 | } |
| 108 | 120 | } |
@@ -21,7 +21,8 @@ discard block |
||
| 21 | 21 | public static function emptyItemProvider(): iterable |
| 22 | 22 | { |
| 23 | 23 | $values = ['', ' ']; |
| 24 | - foreach ($values as $value) { |
|
| 24 | + foreach ($values as $value) |
|
| 25 | + { |
|
| 25 | 26 | yield from [ |
| 26 | 27 | [AcceptHeaderItem::fromString($value)], |
| 27 | 28 | [new AcceptHeaderItem($value)], |
@@ -58,11 +59,13 @@ discard block |
||
| 58 | 59 | #[DataProvider('qualityBoundariesProvider')] |
| 59 | 60 | public function testItemQualityBoundaries(float $quality, AcceptHeaderItem $item): void |
| 60 | 61 | { |
| 61 | - if ($quality > 1) { |
|
| 62 | + if ($quality > 1) |
|
| 63 | + { |
|
| 62 | 64 | self::assertEqualsWithDelta(1.0, $item->getQuality(), PHP_FLOAT_EPSILON); |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | - if ($quality < 0) { |
|
| 67 | + if ($quality < 0) |
|
| 68 | + { |
|
| 66 | 69 | self::assertEqualsWithDelta(0.0, $item->getQuality(), PHP_FLOAT_EPSILON); |
| 67 | 70 | } |
| 68 | 71 | |
@@ -73,7 +76,8 @@ discard block |
||
| 73 | 76 | public static function qualityBoundariesProvider(): iterable |
| 74 | 77 | { |
| 75 | 78 | $qualities = [-1, 0, 0.5, 1, 2]; |
| 76 | - foreach ($qualities as $quality) { |
|
| 79 | + foreach ($qualities as $quality) |
|
| 80 | + { |
|
| 77 | 81 | yield from [ |
| 78 | 82 | [$quality, AcceptHeaderItem::fromString("*;q=$quality")], |
| 79 | 83 | [$quality, AcceptHeaderItem::fromString("*;Q=$quality")], |
@@ -106,9 +110,11 @@ discard block |
||
| 106 | 110 | ] |
| 107 | 111 | ]; |
| 108 | 112 | |
| 109 | - foreach ($set as $params) { |
|
| 113 | + foreach ($set as $params) |
|
| 114 | + { |
|
| 110 | 115 | $formattedParams = []; |
| 111 | - foreach ($params['passed'] as $k => $v) { |
|
| 116 | + foreach ($params['passed'] as $k => $v) |
|
| 117 | + { |
|
| 112 | 118 | $formattedParams[] = "$k=$v"; |
| 113 | 119 | } |
| 114 | 120 | |
@@ -89,7 +89,8 @@ discard block |
||
| 89 | 89 | $headers = $acceptHeader->getAll(); |
| 90 | 90 | self::assertCount(count($expected), $headers); |
| 91 | 91 | |
| 92 | - foreach ($expected as $i => $value) { |
|
| 92 | + foreach ($expected as $i => $value) |
|
| 93 | + { |
|
| 93 | 94 | self::assertSame($value, $headers[$i]->getValue()); |
| 94 | 95 | } |
| 95 | 96 | } |
@@ -126,7 +127,8 @@ discard block |
||
| 126 | 127 | $headers = $acceptHeader->getAll(); |
| 127 | 128 | self::assertCount(count($expected), $headers); |
| 128 | 129 | |
| 129 | - foreach ($expected as $i => $value) { |
|
| 130 | + foreach ($expected as $i => $value) |
|
| 131 | + { |
|
| 130 | 132 | self::assertSame($value, (string)$headers[$i]); |
| 131 | 133 | } |
| 132 | 134 | } |
@@ -23,7 +23,8 @@ |
||
| 23 | 23 | 'create:jobHandler', |
| 24 | 24 | ]; |
| 25 | 25 | |
| 26 | - foreach ($strings as $string) { |
|
| 26 | + foreach ($strings as $string) |
|
| 27 | + { |
|
| 27 | 28 | self::assertStringContainsString($string, $result); |
| 28 | 29 | } |
| 29 | 30 | } |
@@ -130,17 +130,22 @@ discard block |
||
| 130 | 130 | ]; |
| 131 | 131 | |
| 132 | 132 | $reflectionMethods = []; |
| 133 | - foreach ($reflection->getMethods() as $method) { |
|
| 134 | - if ($method->getDeclaringClass()->name !== $reflection->name) { |
|
| 133 | + foreach ($reflection->getMethods() as $method) |
|
| 134 | + { |
|
| 135 | + if ($method->getDeclaringClass()->name !== $reflection->name) |
|
| 136 | + { |
|
| 135 | 137 | continue; |
| 136 | 138 | } |
| 137 | 139 | |
| 138 | 140 | $reflectionMethods[$method->name] = $method; |
| 139 | 141 | self::assertArrayHasKey($method->name, $methods); |
| 140 | 142 | |
| 141 | - if (!$method->hasReturnType()) { |
|
| 143 | + if (!$method->hasReturnType()) |
|
| 144 | + { |
|
| 142 | 145 | self::assertNull($methods[$method->name]['hint']); |
| 143 | - } else { |
|
| 146 | + } |
|
| 147 | + else |
|
| 148 | + { |
|
| 144 | 149 | self::assertEquals($methods[$method->name]['hint'], $method->getReturnType()->getName()); |
| 145 | 150 | } |
| 146 | 151 | } |
@@ -180,8 +185,10 @@ discard block |
||
| 180 | 185 | ]; |
| 181 | 186 | |
| 182 | 187 | $reflectionMethods = []; |
| 183 | - foreach ($reflection->getMethods() as $method) { |
|
| 184 | - if ($method->getDeclaringClass()->name !== $reflection->name) { |
|
| 188 | + foreach ($reflection->getMethods() as $method) |
|
| 189 | + { |
|
| 190 | + if ($method->getDeclaringClass()->name !== $reflection->name) |
|
| 191 | + { |
|
| 185 | 192 | continue; |
| 186 | 193 | } |
| 187 | 194 | $reflectionMethods[$method->name] = $method; |