1 | <?php |
||
9 | class Response |
||
10 | { |
||
11 | /** |
||
12 | * Properties |
||
13 | * |
||
14 | */ |
||
15 | private $headers = []; // Set all headers to send |
||
16 | private $statusCode; // Set statuscode to use |
||
17 | private $body; // Body to send with response |
||
18 | |||
19 | |||
20 | |||
21 | /** |
||
22 | * Set headers. |
||
23 | * |
||
24 | * @param string $header type of header to set |
||
|
|||
25 | * |
||
26 | * @return $this |
||
27 | */ |
||
28 | 1 | public function setStatusCode($value) |
|
36 | |||
37 | |||
38 | |||
39 | /** |
||
40 | * Set headers. |
||
41 | * |
||
42 | * @param string $header type of header to set |
||
43 | * |
||
44 | * @return $this |
||
45 | */ |
||
46 | public function addHeader($header) |
||
47 | { |
||
48 | $this->headers[] = $header; |
||
49 | } |
||
50 | |||
51 | |||
52 | |||
53 | /** |
||
54 | * Check if headers are already sent and throw exception if it is. |
||
55 | * |
||
56 | * @return void |
||
57 | * |
||
58 | * @throws Exception |
||
59 | */ |
||
60 | 1 | public function checkIfHeadersAlreadySent() |
|
66 | |||
67 | |||
68 | |||
69 | /** |
||
70 | * Send headers. |
||
71 | * |
||
72 | * @return $this |
||
73 | */ |
||
74 | public function sendHeaders() |
||
95 | |||
96 | |||
97 | |||
98 | /** |
||
99 | * Set the body. |
||
100 | * |
||
101 | * @param callable|string $body either a string or a callable that |
||
102 | * can generate the body. |
||
103 | * |
||
104 | * @return this |
||
105 | */ |
||
106 | 1 | public function setBody($body) |
|
119 | |||
120 | |||
121 | |||
122 | /** |
||
123 | * Get the body. |
||
124 | * |
||
125 | * @return void |
||
126 | */ |
||
127 | 1 | public function getBody() |
|
131 | |||
132 | |||
133 | |||
134 | /** |
||
135 | * Send response with an optional statuscode. |
||
136 | * |
||
137 | * @param integer $statusCode optional statuscode to send. |
||
138 | * |
||
139 | * @return void |
||
140 | */ |
||
141 | public function send($statusCode = null) |
||
152 | |||
153 | |||
154 | |||
155 | /** |
||
156 | * Send JSON response with an optional statuscode. |
||
157 | * |
||
158 | * @param mixed $data to be encoded as json. |
||
159 | * @param integer $statusCode optional statuscode to send. |
||
160 | * |
||
161 | * @return void |
||
162 | */ |
||
163 | public function sendJson($data, $statusCode = null) |
||
175 | |||
176 | |||
177 | |||
178 | /** |
||
179 | * Redirect to another page. |
||
180 | * |
||
181 | * @param string $url to redirect to |
||
182 | * |
||
183 | * @return void |
||
184 | */ |
||
185 | public function redirect($url) |
||
190 | } |
||
191 |
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.