Skip to content

Commit 9694a0d

Browse files
committed
update test
1 parent 2a36b65 commit 9694a0d

File tree

3 files changed

+161
-94
lines changed

3 files changed

+161
-94
lines changed

src/Contracts/PhpRestfulApiResponse.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
interface PhpRestfulApiResponse extends ResponseInterface
1717
{
1818
/**
19-
* @param $data
19+
* @param array|null $data
2020
* @param $code
2121
* @param array $headers
2222
* @return Response|static
2323
*/
24-
public function withArray(array $data, $code = 200, array $headers = []);
24+
public function withArray($data, $code = 200, array $headers = []);
2525

2626
/**
2727
* @param $data
@@ -63,7 +63,7 @@ public function withError($message, $code, array $headers = []);
6363
* @param array $headers
6464
* @return mixed
6565
*/
66-
public function errorForbidden($message = '', array $headers = []);
66+
public function errorForbidden(string $message = '', array $headers = []);
6767

6868
/**
6969
* Generates a response with a 500 HTTP header and a given message.
@@ -72,7 +72,7 @@ public function errorForbidden($message = '', array $headers = []);
7272
* @param array $headers
7373
* @return mixed
7474
*/
75-
public function errorInternalError($message = '', array $headers = []);
75+
public function errorInternalError(string $message = '', array $headers = []);
7676

7777
/**
7878
* Generates a response with a 404 HTTP header and a given message.
@@ -81,7 +81,7 @@ public function errorInternalError($message = '', array $headers = []);
8181
* @param array $headers
8282
* @return mixed
8383
*/
84-
public function errorNotFound($message = '', array $headers = []);
84+
public function errorNotFound(string $message = '', array $headers = []);
8585

8686
/**
8787
* Generates a response with a 401 HTTP header and a given message.
@@ -90,7 +90,7 @@ public function errorNotFound($message = '', array $headers = []);
9090
* @param array $headers
9191
* @return mixed
9292
*/
93-
public function errorUnauthorized($message = '', array $headers = []);
93+
public function errorUnauthorized(string $message = '', array $headers = []);
9494

9595
/**
9696
* Generates a response with a 400 HTTP header and a given message.
@@ -108,7 +108,7 @@ public function errorWrongArgs(array $message, array $headers = []);
108108
* @param array $headers
109109
* @return mixed
110110
*/
111-
public function errorGone($message = '', array $headers = []);
111+
public function errorGone(string $message = '', array $headers = []);
112112

113113
/**
114114
* Generates a response with a 405 HTTP header and a given message.
@@ -117,7 +117,7 @@ public function errorGone($message = '', array $headers = []);
117117
* @param array $headers
118118
* @return mixed
119119
*/
120-
public function errorMethodNotAllowed($message = '', array $headers = []);
120+
public function errorMethodNotAllowed(string $message = '', array $headers = []);
121121

122122
/**
123123
* Generates a Response with a 431 HTTP header and a given message.
@@ -126,7 +126,7 @@ public function errorMethodNotAllowed($message = '', array $headers = []);
126126
* @param array $headers
127127
* @return mixed
128128
*/
129-
public function errorUnwillingToProcess($message = '', array $headers = []);
129+
public function errorUnwillingToProcess(string $message = '', array $headers = []);
130130

131131
/**
132132
* Generates a Response with a 422 HTTP header and a given message.
@@ -135,5 +135,5 @@ public function errorUnwillingToProcess($message = '', array $headers = []);
135135
* @param array $headers
136136
* @return mixed
137137
*/
138-
public function errorUnprocessable($message = '', array $headers = []);
138+
public function errorUnprocessable(string $message = '', array $headers = []);
139139
}

src/Response.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ public function withStatus($code, $reasonPhrase = '')
154154
}
155155

156156
/**
157-
* @param $data
157+
* @param array|null $data
158158
* @param $code
159159
* @param array $headers
160160
* @return Response|static
161161
*/
162-
public function withArray(array $data, $code = 200, array $headers = [])
162+
public function withArray($data, $code = 200, array $headers = [])
163163
{
164164
$new = clone $this;
165165
$new->setStatusCode($code);
@@ -257,7 +257,7 @@ public function withError($message, $code, array $headers = [])
257257
* @param array $headers
258258
* @return mixed
259259
*/
260-
public function errorForbidden($message = '', array $headers = [])
260+
public function errorForbidden(string $message = '', array $headers = [])
261261
{
262262
return $this->withError($message, 403, $headers);
263263
}
@@ -269,7 +269,7 @@ public function errorForbidden($message = '', array $headers = [])
269269
* @param array $headers
270270
* @return mixed
271271
*/
272-
public function errorInternalError($message = '', array $headers = [])
272+
public function errorInternalError(string $message = '', array $headers = [])
273273
{
274274
return $this->withError($message, 500, $headers);
275275
}
@@ -281,7 +281,7 @@ public function errorInternalError($message = '', array $headers = [])
281281
* @param array $headers
282282
* @return mixed
283283
*/
284-
public function errorNotFound($message = '', array $headers = [])
284+
public function errorNotFound(string $message = '', array $headers = [])
285285
{
286286
return $this->withError($message, 404, $headers);
287287
}
@@ -293,7 +293,7 @@ public function errorNotFound($message = '', array $headers = [])
293293
* @param array $headers
294294
* @return mixed
295295
*/
296-
public function errorUnauthorized($message = '', array $headers = [])
296+
public function errorUnauthorized(string $message = '', array $headers = [])
297297
{
298298
return $this->withError($message, 401, $headers);
299299
}
@@ -317,7 +317,7 @@ public function errorWrongArgs(array $message, array $headers = [])
317317
* @param array $headers
318318
* @return mixed
319319
*/
320-
public function errorGone($message = '', array $headers = [])
320+
public function errorGone(string $message = '', array $headers = [])
321321
{
322322
return $this->withError($message, 410, $headers);
323323
}
@@ -329,7 +329,7 @@ public function errorGone($message = '', array $headers = [])
329329
* @param array $headers
330330
* @return mixed
331331
*/
332-
public function errorMethodNotAllowed($message = '', array $headers = [])
332+
public function errorMethodNotAllowed(string $message = '', array $headers = [])
333333
{
334334
return $this->withError($message, 405, $headers);
335335
}
@@ -341,7 +341,7 @@ public function errorMethodNotAllowed($message = '', array $headers = [])
341341
* @param array $headers
342342
* @return mixed
343343
*/
344-
public function errorUnwillingToProcess($message = '', array $headers = [])
344+
public function errorUnwillingToProcess(string $message = '', array $headers = [])
345345
{
346346
return $this->withError($message, 431, $headers);
347347
}
@@ -353,7 +353,7 @@ public function errorUnwillingToProcess($message = '', array $headers = [])
353353
* @param array $headers
354354
* @return mixed
355355
*/
356-
public function errorUnprocessable($message = '', array $headers = [])
356+
public function errorUnprocessable(string $message = '', array $headers = [])
357357
{
358358
return $this->withError($message, 422, $headers);
359359
}
@@ -364,7 +364,7 @@ public function errorUnprocessable($message = '', array $headers = [])
364364
* @param int $code
365365
* @throws InvalidArgumentException on an invalid status code.
366366
*/
367-
private function setStatusCode($code)
367+
private function setStatusCode(int $code)
368368
{
369369
if (! is_numeric($code)
370370
|| is_float($code)

0 commit comments

Comments
 (0)