@@ -27,7 +27,8 @@ |
||
27 | 27 | * @param bool $useSlimErrors Throw Slim exceptions for error responses. |
28 | 28 | */ |
29 | 29 | public function __construct(public bool $useSlimErrors = false) |
30 | - { } |
|
30 | + { |
|
31 | +} |
|
31 | 32 | |
32 | 33 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
33 | 34 | { |
@@ -97,7 +97,7 @@ |
||
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - protected function getBody(ResponseInterface $response): string|null |
|
100 | + protected function getBody(ResponseInterface $response): string | null |
|
101 | 101 | { |
102 | 102 | $body = (string)$response->getBody(); |
103 | 103 | return $body !== '' ? $body : null; |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * Run a set of guards. |
24 | 24 | */ |
25 | 25 | public function guard( |
26 | - \ReflectionObject|\ReflectionMethod $subject, |
|
26 | + \ReflectionObject | \ReflectionMethod $subject, |
|
27 | 27 | ServerRequestInterface $request, |
28 | 28 | ResponseInterface $response, |
29 | 29 | ): ?ResponseInterface { |
@@ -19,7 +19,7 @@ |
||
19 | 19 | return $this->guardian; |
20 | 20 | } |
21 | 21 | |
22 | - protected function guard(\ReflectionObject|\ReflectionMethod $subject): ?ResponseInterface |
|
22 | + protected function guard(\ReflectionObject | \ReflectionMethod $subject): ?ResponseInterface |
|
23 | 23 | { |
24 | 24 | return $this->getGuardian()->guard($subject, $this->getRequest(), $this->getResponse()); |
25 | 25 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return $this |
26 | 26 | */ |
27 | - protected function header(string $header, string|int|\Stringable $value, bool $add = false): static |
|
27 | + protected function header(string $header, string | int | \Stringable $value, bool $add = false): static |
|
28 | 28 | { |
29 | 29 | $response = $add |
30 | 30 | ? $this->getResponse()->withAddedHeader($header, (string)$value) |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param int|string $status |
48 | 48 | * @return $this |
49 | 49 | */ |
50 | - protected function status(int|string $status): static |
|
50 | + protected function status(int | string $status): static |
|
51 | 51 | { |
52 | 52 | if (is_string($status)) { |
53 | 53 | [$status, $phrase] = explode(' ', $status, 2) + [1 => '']; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param string $url |
135 | 135 | * @param int|string $status 301 (Moved Permanently), 302 (Found), 303 (See Other) or 307 (Temporary Redirect) |
136 | 136 | */ |
137 | - protected function redirect(string $url, int|string $status = 303): static |
|
137 | + protected function redirect(string $url, int | string $status = 303): static |
|
138 | 138 | { |
139 | 139 | if ($status < 300 || $status >= 400) { |
140 | 140 | throw new \DomainException("Invalid status code $status for redirect"); |
@@ -35,9 +35,12 @@ discard block |
||
35 | 35 | $this->initialResponse = $this->createMock(ResponseInterface::class); |
36 | 36 | $this->finalResponse = $this->createMock(ResponseInterface::class); |
37 | 37 | |
38 | - $this->controller = new class ($this) extends Controller { |
|
38 | + $this->controller = new class ($this) extends Controller |
|
39 | + { |
|
39 | 40 | public $called; |
40 | - public function __construct(protected ControllerTest $test) { } |
|
41 | + public function __construct(protected ControllerTest $test) |
|
42 | + { |
|
43 | +} |
|
41 | 44 | |
42 | 45 | public function process(int $foo, string $bar = 'red'): static { |
43 | 46 | $this->called = __FUNCTION__; |
@@ -124,14 +127,19 @@ discard block |
||
124 | 127 | |
125 | 128 | public function testBefore() |
126 | 129 | { |
127 | - $controller = new class ($this) extends Controller { |
|
128 | - function __construct(protected ControllerTest $test) { } |
|
130 | + $controller = new class ($this) extends Controller |
|
131 | + { |
|
132 | + function __construct(protected ControllerTest $test) |
|
133 | + { |
|
134 | +} |
|
129 | 135 | |
130 | - function before() { |
|
136 | + function before() |
|
137 | + { |
|
131 | 138 | return $this->paymentRequired(); |
132 | 139 | } |
133 | 140 | |
134 | - function process() { |
|
141 | + function process() |
|
142 | + { |
|
135 | 143 | $this->test->fail("Process should not be called"); |
136 | 144 | } |
137 | 145 | }; |
@@ -149,9 +157,12 @@ discard block |
||
149 | 157 | |
150 | 158 | public function testClassGuard() |
151 | 159 | { |
152 | - $controller = new #[PaymentRequired] class ($this) extends Controller { |
|
160 | + $controller = new #[PaymentRequired] class ($this) extends Controller |
|
161 | + { |
|
153 | 162 | public $called; |
154 | - public function __construct(protected ControllerTest $test) { } |
|
163 | + public function __construct(protected ControllerTest $test) |
|
164 | + { |
|
165 | +} |
|
155 | 166 | |
156 | 167 | public function process(): static { |
157 | 168 | $this->called = __FUNCTION__; |
@@ -174,12 +185,16 @@ discard block |
||
174 | 185 | |
175 | 186 | public function testMethodGuard() |
176 | 187 | { |
177 | - $controller = new class ($this) extends Controller { |
|
188 | + $controller = new class ($this) extends Controller |
|
189 | + { |
|
178 | 190 | public $called; |
179 | - function __construct(protected ControllerTest $test) { } |
|
191 | + function __construct(protected ControllerTest $test) |
|
192 | + { |
|
193 | +} |
|
180 | 194 | |
181 | 195 | #[PaymentRequired] |
182 | - function process() { |
|
196 | + function process() |
|
197 | + { |
|
183 | 198 | $this->called = __FUNCTION__; |
184 | 199 | return $this->ok(); |
185 | 200 | } |
@@ -200,9 +215,12 @@ discard block |
||
200 | 215 | |
201 | 216 | public function testNopGuard() |
202 | 217 | { |
203 | - $controller = new #[NopGuard] class ($this) extends Controller { |
|
218 | + $controller = new #[NopGuard] class ($this) extends Controller |
|
219 | + { |
|
204 | 220 | public $called; |
205 | - public function __construct(protected ControllerTest $test) { } |
|
221 | + public function __construct(protected ControllerTest $test) |
|
222 | + { |
|
223 | +} |
|
206 | 224 | |
207 | 225 | public function process(): static { |
208 | 226 | $this->called = __FUNCTION__; |
@@ -4,7 +4,8 @@ |
||
4 | 4 | |
5 | 5 | trait InContextOf |
6 | 6 | { |
7 | - public function inContextOf(object $object, \Closure $function) { |
|
7 | + public function inContextOf(object $object, \Closure $function) |
|
8 | + { |
|
8 | 9 | return $function->bindTo($this, $object)(); |
9 | 10 | } |
10 | 11 | } |
@@ -61,14 +61,18 @@ |
||
61 | 61 | $response = $this->createMock(ResponseInterface::class); |
62 | 62 | $response->method('getStatusCode')->willReturn($code); |
63 | 63 | |
64 | - $controller = new class ($this, $response) extends Controller { |
|
65 | - public function __construct(public TestCase $test, protected ResponseInterface $response) {} |
|
64 | + $controller = new class ($this, $response) extends Controller |
|
65 | + { |
|
66 | + public function __construct(public TestCase $test, protected ResponseInterface $response) |
|
67 | + { |
|
68 | +} |
|
66 | 69 | |
67 | 70 | protected function getResponse(): ResponseInterface { |
68 | 71 | return $this->response; |
69 | 72 | } |
70 | 73 | |
71 | - public function assertResponseStatus(string $type) { |
|
74 | + public function assertResponseStatus(string $type) |
|
75 | + { |
|
72 | 76 | $this->test->assertSame($type === 'informational', $this->isInformational(), 'isInformational'); |
73 | 77 | $this->test->assertSame($type === 'successful', $this->isSuccessful(), 'isSuccessful'); |
74 | 78 | $this->test->assertSame($type === 'redirect', $this->isRedirection(), 'isRedirection'); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $response = $this->createMock(ResponseInterface::class); |
44 | 44 | $response->method('getBody')->willReturn($stream); |
45 | 45 | $response->expects($this->once())->method('withHeader') |
46 | - ->with( 'Content-Type', $contentType) |
|
46 | + ->with('Content-Type', $contentType) |
|
47 | 47 | ->willReturnSelf(); |
48 | 48 | |
49 | 49 | $controller = $this->createPartialMock(Controller::class, ['getResponse']); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $response = $this->createMock(ResponseInterface::class); |
100 | 100 | $response->method('getBody')->willReturn($stream); |
101 | 101 | $response->expects($this->once())->method('withHeader') |
102 | - ->with( 'Content-Type', 'application/json') |
|
102 | + ->with('Content-Type', 'application/json') |
|
103 | 103 | ->willReturnSelf(); |
104 | 104 | |
105 | 105 | $controller = $this->createPartialMock(Controller::class, ['getResponse']); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @dataProvider statusProvider |
29 | 29 | */ |
30 | - public function testStatus(int|string $status, int $code, string $phrase) |
|
30 | + public function testStatus(int | string $status, int $code, string $phrase) |
|
31 | 31 | { |
32 | 32 | $response = $this->createMock(ResponseInterface::class); |
33 | 33 | $response->expects($this->once())->method('withStatus')->with($code, $phrase)->willReturnSelf(); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * Test 'redirect' function |
206 | 206 | * @dataProvider redirectStatusProvider |
207 | 207 | */ |
208 | - public function testRedirect(int|string $status) |
|
208 | + public function testRedirect(int | string $status) |
|
209 | 209 | { |
210 | 210 | $controller = $this->createPartialMock(Controller::class, ['status', 'header', 'output']); |
211 | 211 |