@@ -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 | $this->assertSame( |
| 142 | 145 | <<<MARKDOWN |
| 143 | 146 | Can't resolve `invalid`: undefined class or binding `invalid`. |
@@ -169,9 +172,12 @@ discard block |
||
| 169 | 172 | { |
| 170 | 173 | $this->expectException(ContainerException::class); |
| 171 | 174 | |
| 172 | - try { |
|
| 175 | + try |
|
| 176 | + { |
|
| 173 | 177 | $container->get(ClassWithUndefinedDependency::class); |
| 174 | - } catch (ContainerException $e) { |
|
| 178 | + } |
|
| 179 | + catch (ContainerException $e) |
|
| 180 | + { |
|
| 175 | 181 | $this->assertSame($message, $e->getMessage()); |
| 176 | 182 | |
| 177 | 183 | throw $e; |
@@ -165,7 +165,8 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | $root = self::makeContainer(); |
| 167 | 167 | |
| 168 | - try { |
|
| 168 | + try |
|
| 169 | + { |
|
| 169 | 170 | $root->runScoped(static function (Container $c1): void { |
| 170 | 171 | $c1->runScoped(static function (Container $c2): void { |
| 171 | 172 | $c2->runScoped(static function (Container $c3): void { |
@@ -173,7 +174,9 @@ discard block |
||
| 173 | 174 | }, name: 'root'); |
| 174 | 175 | }); |
| 175 | 176 | }); |
| 176 | - } catch (NamedScopeDuplicationException $e) { |
|
| 177 | + } |
|
| 178 | + catch (NamedScopeDuplicationException $e) |
|
| 179 | + { |
|
| 177 | 180 | $this->assertSame('root', $e->getScope()); |
| 178 | 181 | throw $e; |
| 179 | 182 | } |
@@ -188,14 +191,17 @@ discard block |
||
| 188 | 191 | { |
| 189 | 192 | self::expectException(BadScopeException::class); |
| 190 | 193 | |
| 191 | - try { |
|
| 194 | + try |
|
| 195 | + { |
|
| 192 | 196 | $root = self::makeContainer(); |
| 193 | 197 | $root->runScoped(static function (Container $c1): void { |
| 194 | 198 | $c1->runScoped(static function (Container $c2): void { |
| 195 | 199 | $c2->get(AttrScopeFoo::class); |
| 196 | 200 | }); |
| 197 | 201 | }, name: 'bar'); |
| 198 | - } catch (BadScopeException $e) { |
|
| 202 | + } |
|
| 203 | + catch (BadScopeException $e) |
|
| 204 | + { |
|
| 199 | 205 | $this->assertSame('foo', $e->getScope()); |
| 200 | 206 | throw $e; |
| 201 | 207 | } |
@@ -63,7 +63,8 @@ discard block |
||
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | 65 | $this->assertCount(5, $result); |
| 66 | - foreach ($result as $suspendValue) { |
|
| 66 | + foreach ($result as $suspendValue) |
|
| 67 | + { |
|
| 67 | 68 | $this->assertSame(self::TEST_DATA, $suspendValue); |
| 68 | 69 | } |
| 69 | 70 | } |
@@ -81,7 +82,8 @@ discard block |
||
| 81 | 82 | ); |
| 82 | 83 | |
| 83 | 84 | $this->assertCount(2, $result); |
| 84 | - foreach ($result as $suspendValue) { |
|
| 85 | + foreach ($result as $suspendValue) |
|
| 86 | + { |
|
| 85 | 87 | $this->assertSame(self::TEST_DATA, $suspendValue); |
| 86 | 88 | } |
| 87 | 89 | } |
@@ -114,9 +116,12 @@ discard block |
||
| 114 | 116 | $result = ''; |
| 115 | 117 | $result .= Fiber::suspend('foo'); |
| 116 | 118 | $result .= Fiber::suspend('bar'); |
| 117 | - try { |
|
| 119 | + try |
|
| 120 | + { |
|
| 118 | 121 | $result .= Fiber::suspend('error'); |
| 119 | - } catch (\Throwable $e) { |
|
| 122 | + } |
|
| 123 | + catch (\Throwable $e) |
|
| 124 | + { |
|
| 120 | 125 | $result .= $e->getMessage(); |
| 121 | 126 | } |
| 122 | 127 | return $result . Fiber::suspend('baz'); |
@@ -150,7 +155,8 @@ discard block |
||
| 150 | 155 | $c1 = $container ?? new Container(); |
| 151 | 156 | $c1->bindSingleton('resource', new stdClass()); |
| 152 | 157 | |
| 153 | - $result = $c1->runScoped(static function (Container $c2) use ($load) { |
|
| 158 | + $result = $c1->runScoped(static function (Container $c2) use ($load) |
|
| 159 | + { |
|
| 154 | 160 | // check local binding |
| 155 | 161 | self::assertTrue($c2->has('foo')); |
| 156 | 162 | self::assertInstanceOf(DateTime::class, $c2->get('foo')); |
@@ -163,7 +169,8 @@ discard block |
||
| 163 | 169 | $resource = $c3->get('resource'); |
| 164 | 170 | self::assertInstanceOf(DateTimeImmutable::class, $c3->get('bar')); |
| 165 | 171 | self::assertInstanceOf(stdClass::class, $resource); |
| 166 | - foreach (self::TEST_DATA as $key => $value) { |
|
| 172 | + foreach (self::TEST_DATA as $key => $value) |
|
| 173 | + { |
|
| 167 | 174 | $resource->$key = $value; |
| 168 | 175 | $load === null or $load(); |
| 169 | 176 | Fiber::suspend($value); |
@@ -21,8 +21,10 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | $root = self::makeContainer(); |
| 23 | 23 | |
| 24 | - $obj = $root->runScoped(static function (Container $c1) { |
|
| 25 | - $obj = $c1->runScoped(static function (Container $c2) { |
|
| 24 | + $obj = $root->runScoped(static function (Container $c1) |
|
| 25 | + { |
|
| 26 | + $obj = $c1->runScoped(static function (Container $c2) |
|
| 27 | + { |
|
| 26 | 28 | $obj = $c2->get(AttrScopeFooFinalize::class); |
| 27 | 29 | |
| 28 | 30 | self::assertFalse($obj->finalized); |
@@ -46,8 +48,10 @@ discard block |
||
| 46 | 48 | $root->bindSingleton(LoggerInterface::class, FileLogger::class); |
| 47 | 49 | |
| 48 | 50 | $obj2 = null; |
| 49 | - $obj = $root->runScoped(static function (Container $c1) use (&$obj2) { |
|
| 50 | - $obj = $c1->runScoped(static function (Container $c2) use (&$obj2) { |
|
| 51 | + $obj = $root->runScoped(static function (Container $c1) use (&$obj2) |
|
| 52 | + { |
|
| 53 | + $obj = $c1->runScoped(static function (Container $c2) use (&$obj2) |
|
| 54 | + { |
|
| 51 | 55 | $obj = $c2->get(AttrScopeFooFinalize::class); |
| 52 | 56 | $obj2 = $c2->get(AttrScopeFooFinalize::class); |
| 53 | 57 | |
@@ -77,8 +81,10 @@ discard block |
||
| 77 | 81 | $root->bindSingleton(LoggerInterface::class, FileLogger::class); |
| 78 | 82 | |
| 79 | 83 | $obj2 = null; |
| 80 | - $obj = $root->runScoped(static function (Container $c1) use (&$obj2) { |
|
| 81 | - $obj = $c1->runScoped(static function (Container $c2) use (&$obj2) { |
|
| 84 | + $obj = $root->runScoped(static function (Container $c1) use (&$obj2) |
|
| 85 | + { |
|
| 86 | + $obj = $c1->runScoped(static function (Container $c2) use (&$obj2) |
|
| 87 | + { |
|
| 82 | 88 | $obj = $c2->get(AttrFinalize::class); |
| 83 | 89 | $obj2 = $c2->get(AttrFinalize::class); |
| 84 | 90 | |
@@ -124,12 +130,15 @@ discard block |
||
| 124 | 130 | self::expectException(FinalizersException::class); |
| 125 | 131 | self::expectExceptionMessage('An exception has been thrown during finalization of the scope `foo`'); |
| 126 | 132 | |
| 127 | - try { |
|
| 133 | + try |
|
| 134 | + { |
|
| 128 | 135 | $root->runScoped(static function (Container $c1): void { |
| 129 | 136 | $obj = $c1->get(AttrScopeFooFinalize::class); |
| 130 | 137 | $obj->throwException = true; |
| 131 | 138 | }, name: 'foo'); |
| 132 | - } catch (FinalizersException $e) { |
|
| 139 | + } |
|
| 140 | + catch (FinalizersException $e) |
|
| 141 | + { |
|
| 133 | 142 | $this->assertSame('foo', $e->getScope()); |
| 134 | 143 | $this->assertCount(1, $e->getExceptions()); |
| 135 | 144 | // Contains the message from the inner exception. |
@@ -147,13 +156,16 @@ discard block |
||
| 147 | 156 | self::expectException(FinalizersException::class); |
| 148 | 157 | self::expectExceptionMessage('3 exceptions have been thrown during finalization of the scope `foo`'); |
| 149 | 158 | |
| 150 | - try { |
|
| 159 | + try |
|
| 160 | + { |
|
| 151 | 161 | $root->runScoped(static function (Container $c1): void { |
| 152 | 162 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
| 153 | 163 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
| 154 | 164 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
| 155 | 165 | }, name: 'foo'); |
| 156 | - } catch (FinalizersException $e) { |
|
| 166 | + } |
|
| 167 | + catch (FinalizersException $e) |
|
| 168 | + { |
|
| 157 | 169 | $this->assertSame('foo', $e->getScope()); |
| 158 | 170 | $this->assertCount(3, $e->getExceptions()); |
| 159 | 171 | // Contains the message from the inner exception. |
@@ -124,7 +124,8 @@ |
||
| 124 | 124 | $reflection = $target->getReflection(); |
| 125 | 125 | $this->assertSame($hasReflection, $reflection !== null); |
| 126 | 126 | $this->assertNull($target->getObject()); |
| 127 | - if ($hasReflection) { |
|
| 127 | + if ($hasReflection) |
|
| 128 | + { |
|
| 128 | 129 | $this->assertInstanceOf(\ReflectionMethod::class, $reflection); |
| 129 | 130 | $this->assertSame($action, $reflection->getName()); |
| 130 | 131 | } |
@@ -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 | $this->assertEqualsWithDelta(1.0, $item->getQuality(), PHP_FLOAT_EPSILON); |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | - if ($quality < 0) { |
|
| 67 | + if ($quality < 0) |
|
| 68 | + { |
|
| 66 | 69 | $this->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 | { |
| 90 | 90 | $core = $this->getCore(); |
| 91 | 91 | |
| 92 | - $core->setHandler(function ($req, $resp) { |
|
| 92 | + $core->setHandler(function ($req, $resp) |
|
| 93 | + { |
|
| 93 | 94 | echo 'hello!'; |
| 94 | 95 | |
| 95 | 96 | return $resp->withAddedHeader('hello', 'value'); |
@@ -105,7 +106,8 @@ discard block |
||
| 105 | 106 | { |
| 106 | 107 | $core = $this->getCore(); |
| 107 | 108 | |
| 108 | - $core->setHandler(function ($req, $resp) { |
|
| 109 | + $core->setHandler(function ($req, $resp) |
|
| 110 | + { |
|
| 109 | 111 | echo 'hello!'; |
| 110 | 112 | $resp->getBody()->write('world '); |
| 111 | 113 | |
@@ -289,7 +291,8 @@ discard block |
||
| 289 | 291 | TraceKind::SERVER, |
| 290 | 292 | ) |
| 291 | 293 | ->willReturnCallback( |
| 292 | - function ($name, $callback, $attributes, $scoped, $traceKind) { |
|
| 294 | + function ($name, $callback, $attributes, $scoped, $traceKind) |
|
| 295 | + { |
|
| 293 | 296 | $this->assertSame($attributes, [ |
| 294 | 297 | 'http.method' => 'GET', |
| 295 | 298 | 'http.url' => 'http://example.org/path', |
@@ -68,7 +68,8 @@ |
||
| 68 | 68 | $this->assertSame([], $entity->getValue()); |
| 69 | 69 | |
| 70 | 70 | $entity['a'] = 90; |
| 71 | - foreach ($entity as $key => $value) { |
|
| 71 | + foreach ($entity as $key => $value) |
|
| 72 | + { |
|
| 72 | 73 | $this->assertSame('a', $key); |
| 73 | 74 | $this->assertSame(90, $value); |
| 74 | 75 | } |
@@ -76,7 +76,8 @@ |
||
| 76 | 76 | |
| 77 | 77 | $this->rules->method('has')->willReturn(true); |
| 78 | 78 | $this->rules->method('get') |
| 79 | - ->willReturnCallback(function (...$args) use (&$series) { |
|
| 79 | + ->willReturnCallback(function (...$args) use (&$series) |
|
| 80 | + { |
|
| 80 | 81 | [$expectedArgs, $return] = \array_shift($series); |
| 81 | 82 | $this->assertSame($expectedArgs, $args); |
| 82 | 83 | |