@@ -60,7 +60,8 @@ discard block |
||
60 | 60 | |
61 | 61 | public function testMiddlewareProcessingEventShouldBeDispatched(): void |
62 | 62 | { |
63 | - $middleware = new class implements MiddlewareInterface { |
|
63 | + $middleware = new class implements MiddlewareInterface |
|
64 | + { |
|
64 | 65 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
65 | 66 | { |
66 | 67 | return (new ResponseFactory(new HttpConfig(['headers' => []])))->createResponse(200); |
@@ -89,7 +90,8 @@ discard block |
||
89 | 90 | $this->container->getBinder('http') |
90 | 91 | ->bind(ServerRequestInterface::class, static fn(CurrentRequest $cr) => $cr->get()); |
91 | 92 | |
92 | - $middleware = new class implements MiddlewareInterface { |
|
93 | + $middleware = new class implements MiddlewareInterface |
|
94 | + { |
|
93 | 95 | public function process( |
94 | 96 | ServerRequestInterface $request, |
95 | 97 | RequestHandlerInterface $handler, |
@@ -81,7 +81,8 @@ |
||
81 | 81 | $bootloader = $this->getBootloadManager(); |
82 | 82 | |
83 | 83 | $bootloader->bootload([ |
84 | - new class () extends Bootloader { |
|
84 | + new class () extends Bootloader |
|
85 | + { |
|
85 | 86 | public const BINDINGS = ['abc' => self::class]; |
86 | 87 | public const SINGLETONS = ['single' => self::class]; |
87 | 88 |
@@ -47,7 +47,8 @@ discard block |
||
47 | 47 | { |
48 | 48 | $kernel = TestCore::create(['root' => __DIR__])->run(); |
49 | 49 | |
50 | - $d = new class() implements DispatcherInterface { |
|
50 | + $d = new class() implements DispatcherInterface |
|
51 | + { |
|
51 | 52 | public static function canServe(EnvironmentInterface $env): bool |
52 | 53 | { |
53 | 54 | return true; |
@@ -67,7 +68,8 @@ discard block |
||
67 | 68 | { |
68 | 69 | $kernel = TestCore::create(['root' => __DIR__])->run(); |
69 | 70 | |
70 | - $d = new class() implements DispatcherInterface { |
|
71 | + $d = new class() implements DispatcherInterface |
|
72 | + { |
|
71 | 73 | public function canServe(): bool |
72 | 74 | { |
73 | 75 | return true; |
@@ -90,7 +92,8 @@ discard block |
||
90 | 92 | { |
91 | 93 | $kernel = TestCore::create(['root' => __DIR__])->run(); |
92 | 94 | |
93 | - $d = new class() implements DispatcherInterface { |
|
95 | + $d = new class() implements DispatcherInterface |
|
96 | + { |
|
94 | 97 | public static function canServe(EnvironmentInterface $env): bool |
95 | 98 | { |
96 | 99 | return true; |
@@ -159,7 +162,8 @@ discard block |
||
159 | 162 | |
160 | 163 | public function testEventsShouldBeDispatched(): void |
161 | 164 | { |
162 | - $testDispatcher = new class implements DispatcherInterface { |
|
165 | + $testDispatcher = new class implements DispatcherInterface |
|
166 | + { |
|
163 | 167 | public static function canServe(EnvironmentInterface $env): bool |
164 | 168 | { |
165 | 169 | return true; |
@@ -48,7 +48,8 @@ discard block |
||
48 | 48 | |
49 | 49 | public function testInjection(): void |
50 | 50 | { |
51 | - $factory = new class () implements LogsInterface { |
|
51 | + $factory = new class () implements LogsInterface |
|
52 | + { |
|
52 | 53 | public function getLogger(string $channel): LoggerInterface |
53 | 54 | { |
54 | 55 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -65,7 +66,8 @@ discard block |
||
65 | 66 | |
66 | 67 | public function testInjectionNullableChannel(): void |
67 | 68 | { |
68 | - $factory = new class () implements LogsInterface { |
|
69 | + $factory = new class () implements LogsInterface |
|
70 | + { |
|
69 | 71 | public function getLogger(?string $channel): LoggerInterface |
70 | 72 | { |
71 | 73 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -82,7 +84,8 @@ discard block |
||
82 | 84 | |
83 | 85 | public function testInjectionWithAttribute(): void |
84 | 86 | { |
85 | - $factory = new class () implements LogsInterface { |
|
87 | + $factory = new class () implements LogsInterface |
|
88 | + { |
|
86 | 89 | public function getLogger(?string $channel): LoggerInterface |
87 | 90 | { |
88 | 91 | $mock = \Mockery::mock(LoggerInterface::class); |
@@ -24,7 +24,8 @@ discard block |
||
24 | 24 | $queue = m::mock(QueueInterface::class) |
25 | 25 | ); |
26 | 26 | |
27 | - if (!\is_array($payload)) { |
|
27 | + if (!\is_array($payload)) |
|
28 | + { |
|
28 | 29 | $this->markTestIncomplete('QueueInterface does not support non-array payloads'); |
29 | 30 | return; |
30 | 31 | } |
@@ -49,7 +50,8 @@ discard block |
||
49 | 50 | $queue = m::mock(QueueInterface::class) |
50 | 51 | ); |
51 | 52 | |
52 | - if (!\is_array($payload)) { |
|
53 | + if (!\is_array($payload)) |
|
54 | + { |
|
53 | 55 | $this->markTestIncomplete('QueueInterface does not support non-array payloads'); |
54 | 56 | return; |
55 | 57 | } |
@@ -37,12 +37,15 @@ discard block |
||
37 | 37 | */ |
38 | 38 | protected function availableReflections(): \Generator |
39 | 39 | { |
40 | - foreach ($this->finder->getIterator() as $file) { |
|
40 | + foreach ($this->finder->getIterator() as $file) |
|
41 | + { |
|
41 | 42 | $reflection = new ReflectionFile((string)$file); |
42 | 43 | |
43 | - if ($reflection->hasIncludes()) { |
|
44 | + if ($reflection->hasIncludes()) |
|
45 | + { |
|
44 | 46 | // We are not analyzing files which has includes, it's not safe to require such reflections |
45 | - if ($this->debug) { |
|
47 | + if ($this->debug) |
|
48 | + { |
|
46 | 49 | $this->getLogger()->warning( |
47 | 50 | \sprintf('File `%s` has includes and excluded from analysis', (string) $file), |
48 | 51 | ['file' => $file] |
@@ -69,7 +72,8 @@ discard block |
||
69 | 72 | protected function classReflection(string $class): \ReflectionClass |
70 | 73 | { |
71 | 74 | $loader = static function ($class): void { |
72 | - if ($class === LocatorException::class) { |
|
75 | + if ($class === LocatorException::class) |
|
76 | + { |
|
73 | 77 | return; |
74 | 78 | } |
75 | 79 | |
@@ -79,16 +83,21 @@ discard block |
||
79 | 83 | //To suspend class dependency exception |
80 | 84 | \spl_autoload_register($loader); |
81 | 85 | |
82 | - try { |
|
86 | + try |
|
87 | + { |
|
83 | 88 | //In some cases reflection can thrown an exception if class invalid or can not be loaded, |
84 | 89 | //we are going to handle such exception and convert it soft exception |
85 | 90 | return new \ReflectionClass($class); |
86 | - } catch (\Throwable $e) { |
|
87 | - if ($e instanceof LocatorException && $e->getPrevious() != null) { |
|
91 | + } |
|
92 | + catch (\Throwable $e) |
|
93 | + { |
|
94 | + if ($e instanceof LocatorException && $e->getPrevious() != null) |
|
95 | + { |
|
88 | 96 | $e = $e->getPrevious(); |
89 | 97 | } |
90 | 98 | |
91 | - if ($this->debug) { |
|
99 | + if ($this->debug) |
|
100 | + { |
|
92 | 101 | $this->getLogger()->error( |
93 | 102 | \sprintf('%s: %s in %s:%s', $class, $e->getMessage(), $e->getFile(), $e->getLine()), |
94 | 103 | ['error' => $e] |
@@ -96,7 +105,9 @@ discard block |
||
96 | 105 | } |
97 | 106 | |
98 | 107 | throw new LocatorException($e->getMessage(), (int) $e->getCode(), $e); |
99 | - } finally { |
|
108 | + } |
|
109 | + finally |
|
110 | + { |
|
100 | 111 | \spl_autoload_unregister($loader); |
101 | 112 | } |
102 | 113 | } |
@@ -112,7 +123,8 @@ discard block |
||
112 | 123 | protected function enumReflection(string $enum): \ReflectionEnum |
113 | 124 | { |
114 | 125 | $loader = static function (string $enum): void { |
115 | - if ($enum === LocatorException::class) { |
|
126 | + if ($enum === LocatorException::class) |
|
127 | + { |
|
116 | 128 | return; |
117 | 129 | } |
118 | 130 | |
@@ -122,16 +134,21 @@ discard block |
||
122 | 134 | //To suspend class dependency exception |
123 | 135 | \spl_autoload_register($loader); |
124 | 136 | |
125 | - try { |
|
137 | + try |
|
138 | + { |
|
126 | 139 | //In some enum reflection can thrown an exception if enum invalid or can not be loaded, |
127 | 140 | //we are going to handle such exception and convert it soft exception |
128 | 141 | return new \ReflectionEnum($enum); |
129 | - } catch (\Throwable $e) { |
|
130 | - if ($e instanceof LocatorException && $e->getPrevious() != null) { |
|
142 | + } |
|
143 | + catch (\Throwable $e) |
|
144 | + { |
|
145 | + if ($e instanceof LocatorException && $e->getPrevious() != null) |
|
146 | + { |
|
131 | 147 | $e = $e->getPrevious(); |
132 | 148 | } |
133 | 149 | |
134 | - if ($this->debug) { |
|
150 | + if ($this->debug) |
|
151 | + { |
|
135 | 152 | $this->getLogger()->error( |
136 | 153 | \sprintf('%s: %s in %s:%s', $enum, $e->getMessage(), $e->getFile(), $e->getLine()), |
137 | 154 | ['error' => $e] |
@@ -139,7 +156,9 @@ discard block |
||
139 | 156 | } |
140 | 157 | |
141 | 158 | throw new LocatorException($e->getMessage(), (int) $e->getCode(), $e); |
142 | - } finally { |
|
159 | + } |
|
160 | + finally |
|
161 | + { |
|
143 | 162 | \spl_autoload_unregister($loader); |
144 | 163 | } |
145 | 164 | } |
@@ -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 | self::assertSame('foo', $e->getScope()); |
134 | 143 | self::assertCount(1, $e->getExceptions()); |
135 | 144 | // Contains the message from the inner exception. |
@@ -153,13 +162,16 @@ discard block |
||
153 | 162 | self::expectException(FinalizersException::class); |
154 | 163 | self::expectExceptionMessage('3 exceptions have been thrown during finalization of the scope `foo`'); |
155 | 164 | |
156 | - try { |
|
165 | + try |
|
166 | + { |
|
157 | 167 | $root->runScoped(static function (Container $c1): void { |
158 | 168 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
159 | 169 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
160 | 170 | $c1->get(AttrScopeFooFinalize::class)->throwException = true; |
161 | 171 | }, name: 'foo'); |
162 | - } catch (FinalizersException $e) { |
|
172 | + } |
|
173 | + catch (FinalizersException $e) |
|
174 | + { |
|
163 | 175 | self::assertSame('foo', $e->getScope()); |
164 | 176 | self::assertCount(3, $e->getExceptions()); |
165 | 177 | // Contains the message from the inner exception. |
@@ -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 | self::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 | self::assertSame('foo', $e->getScope()); |
200 | 206 | throw $e; |
201 | 207 | } |
@@ -63,7 +63,8 @@ discard block |
||
63 | 63 | ); |
64 | 64 | |
65 | 65 | self::assertCount(5, $result); |
66 | - foreach ($result as $suspendValue) { |
|
66 | + foreach ($result as $suspendValue) |
|
67 | + { |
|
67 | 68 | self::assertSame(self::TEST_DATA, $suspendValue); |
68 | 69 | } |
69 | 70 | } |
@@ -81,7 +82,8 @@ discard block |
||
81 | 82 | ); |
82 | 83 | |
83 | 84 | self::assertCount(2, $result); |
84 | - foreach ($result as $suspendValue) { |
|
85 | + foreach ($result as $suspendValue) |
|
86 | + { |
|
85 | 87 | self::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,20 +155,23 @@ 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')); |
157 | 163 | |
158 | 164 | return $c2->runScoped( |
159 | - static function (ContainerInterface $c3) use ($load) { |
|
165 | + static function (ContainerInterface $c3) use ($load) |
|
166 | + { |
|
160 | 167 | // check local binding |
161 | 168 | self::assertTrue($c3->has('bar')); |
162 | 169 | |
163 | 170 | $resource = $c3->get('resource'); |
164 | 171 | self::assertInstanceOf(DateTimeImmutable::class, $c3->get('bar')); |
165 | 172 | self::assertInstanceOf(stdClass::class, $resource); |
166 | - foreach (self::TEST_DATA as $key => $value) { |
|
173 | + foreach (self::TEST_DATA as $key => $value) |
|
174 | + { |
|
167 | 175 | $resource->$key = $value; |
168 | 176 | $load === null or $load(); |
169 | 177 | Fiber::suspend($value); |