@@ -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 | } |
@@ -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 |
@@ -34,14 +34,18 @@ |
||
34 | 34 | $request = $this->createMock(ServerRequestInterface::class); |
35 | 35 | $request->method('getMethod')->willReturn($method); |
36 | 36 | |
37 | - $controller = new class ($this, $request) extends Controller { |
|
38 | - public function __construct(public CheckRequestTest $test, protected ServerRequestInterface $request) {} |
|
37 | + $controller = new class ($this, $request) extends Controller |
|
38 | + { |
|
39 | + public function __construct(public CheckRequestTest $test, protected ServerRequestInterface $request) |
|
40 | + { |
|
41 | +} |
|
39 | 42 | |
40 | 43 | protected function getRequest(): ServerRequestInterface { |
41 | 44 | return $this->request; |
42 | 45 | } |
43 | 46 | |
44 | - public function assertRequestMethod(string $method) { |
|
47 | + public function assertRequestMethod(string $method) |
|
48 | + { |
|
45 | 49 | $this->test->assertEquals($method === 'GET', $this->isGetRequest()); |
46 | 50 | $this->test->assertEquals($method === 'POST', $this->isPostRequest()); |
47 | 51 | $this->test->assertEquals($method === 'PUT', $this->isPutRequest()); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | abstract protected function getRequest(): ServerRequestInterface; |
16 | 16 | abstract protected function getResponse(): ResponseInterface; |
17 | 17 | |
18 | - abstract protected function header(string $header, string|int|\Stringable $value, bool $add = false): static; |
|
18 | + abstract protected function header(string $header, string | int | \Stringable $value, bool $add = false): static; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Pick the best content type |