1 | <?php |
||
8 | class Response |
||
9 | { |
||
10 | /** |
||
11 | * @var array $headers set all headers to send. |
||
12 | * @var array $statusCode set statuscode to use. |
||
13 | * @var string $body body to send with response. |
||
14 | * @var string $filename a filename to send for download. |
||
15 | */ |
||
16 | private $headers = []; |
||
17 | private $statusCode = null; |
||
18 | private $body = null; |
||
19 | private $filename = null; |
||
20 | |||
21 | |||
22 | |||
23 | /** |
||
24 | * Set status code to be sent as part of headers. |
||
25 | * |
||
26 | * @param int $value of response status code |
||
27 | * |
||
28 | * @return self |
||
29 | */ |
||
30 | 14 | public function setStatusCode(int $value = null) |
|
39 | |||
40 | |||
41 | |||
42 | /** |
||
43 | * Get status code to be sent as part of headers. |
||
44 | * |
||
45 | * @return integer value as status code or null if not set. |
||
46 | */ |
||
47 | 7 | public function getStatusCode() |
|
51 | |||
52 | |||
53 | |||
54 | /** |
||
55 | * Set headers. |
||
56 | * |
||
57 | * @param string $header type of header to set |
||
58 | * |
||
59 | * @return self |
||
60 | */ |
||
61 | 7 | public function addHeader($header) |
|
66 | |||
67 | |||
68 | |||
69 | /** |
||
70 | * Get all headers. |
||
71 | * |
||
72 | * @return array with headers |
||
73 | */ |
||
74 | 1 | public function getHeaders() : array |
|
78 | |||
79 | |||
80 | |||
81 | /** |
||
82 | * Send headers. |
||
83 | * |
||
84 | * @return self |
||
85 | */ |
||
86 | 1 | public function sendHeaders() |
|
102 | |||
103 | |||
104 | |||
105 | /** |
||
106 | * Set the body. |
||
107 | * |
||
108 | * @param callable|string $body either a string or a callable that |
||
109 | * can generate the body. |
||
110 | * |
||
111 | * @return self |
||
112 | */ |
||
113 | 8 | public function setBody($body) |
|
128 | |||
129 | |||
130 | |||
131 | /** |
||
132 | * Get the body. |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | 8 | public function getBody() |
|
140 | |||
141 | |||
142 | |||
143 | /** |
||
144 | * Send a file to be downloaded by the user. |
||
145 | * |
||
146 | * @param string $filename to the file to download. |
||
147 | * |
||
148 | * @return self |
||
149 | */ |
||
150 | public function addFile(string $filename) : object |
||
174 | |||
175 | |||
176 | |||
177 | /** |
||
178 | * Send a file to be downloaded by the user. |
||
179 | * |
||
180 | * @param string $filename to the file to download. |
||
|
|||
181 | * |
||
182 | * @return self |
||
183 | */ |
||
184 | public function sendFile() : object |
||
194 | |||
195 | |||
196 | |||
197 | /** |
||
198 | * Send response supporting several ways of receiving response $data. |
||
199 | * |
||
200 | * @param mixed $data to use as optional base for creating response. |
||
201 | * |
||
202 | * @return self |
||
203 | */ |
||
204 | 6 | public function send($data = null) |
|
240 | |||
241 | |||
242 | |||
243 | /** |
||
244 | * Send JSON response with an optional statuscode. |
||
245 | * |
||
246 | * @param mixed $data to be encoded as json. |
||
247 | * @param integer $statusCode optional statuscode to send. |
||
248 | * |
||
249 | * @return self |
||
250 | */ |
||
251 | 1 | public function sendJson($data, $statusCode = null) |
|
257 | |||
258 | |||
259 | |||
260 | /** |
||
261 | * Set body with JSON data. |
||
262 | * |
||
263 | * @param mixed $data to be encoded as json. |
||
264 | * |
||
265 | * @return self |
||
266 | */ |
||
267 | 3 | public function setJsonBody($data) |
|
273 | |||
274 | |||
275 | |||
276 | /** |
||
277 | * Redirect to another page. |
||
278 | * |
||
279 | * @param string $url to redirect to |
||
280 | * |
||
281 | * @return self |
||
282 | */ |
||
283 | 2 | public function redirect(string $url) : object |
|
289 | } |
||
290 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.