1 | <?php |
||
17 | class ServerRequest extends Request implements ServerRequestInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var array|object|string |
||
21 | */ |
||
22 | protected $parsedBody; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $serverParams; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $attributes; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $cookieParams; |
||
38 | |||
39 | /** |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $queryParams; |
||
43 | |||
44 | /** |
||
45 | * @var UploadedFileInterface[] |
||
46 | */ |
||
47 | protected $uploadedFiles; |
||
48 | |||
49 | /** |
||
50 | * @param array $serverParams Server parameters, typically from $_SERVER |
||
51 | * @param array $uploadedFiles Upload file information, a tree of UploadedFiles |
||
52 | * @param string $uri URI for the request, if any. |
||
53 | * @param string $method HTTP method for the request, if any. |
||
54 | * @param string|resource|StreamInterface $body Message body, if any. |
||
55 | * @param array $headers Headers for the message, if any. |
||
56 | * @param array $cookies Cookies for the message, if any. |
||
57 | * @param array $queryParams Query params for the message, if any. |
||
58 | * @param array|object $parsedBody The deserialized body parameters, if any. |
||
59 | * @param string $protocol HTTP protocol version. |
||
|
|||
60 | * |
||
61 | * @throws InvalidArgumentException for any invalid value. |
||
62 | */ |
||
63 | 5 | public function __construct( |
|
87 | |||
88 | /** |
||
89 | * @inheritDoc |
||
90 | */ |
||
91 | 4 | public function getServerParams() : array |
|
95 | |||
96 | /** |
||
97 | * @inheritDoc |
||
98 | */ |
||
99 | 4 | public function getCookieParams() : array |
|
103 | |||
104 | /** |
||
105 | * @inheritDoc |
||
106 | */ |
||
107 | public function withCookieParams(array $cookies) |
||
108 | { |
||
109 | $new = clone $this; |
||
110 | $new->cookieParams = $cookies; |
||
111 | |||
112 | return $new; |
||
113 | } |
||
114 | |||
115 | /** |
||
116 | * @inheritDoc |
||
117 | */ |
||
118 | 4 | public function getQueryParams() : array |
|
122 | |||
123 | /** |
||
124 | * @inheritDoc |
||
125 | */ |
||
126 | public function withQueryParams(array $query) |
||
127 | { |
||
128 | $new = clone $this; |
||
129 | $new->queryParams = $query; |
||
130 | |||
131 | return $new; |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * @inheritDoc |
||
136 | */ |
||
137 | 4 | public function getUploadedFiles() : array |
|
141 | |||
142 | /** |
||
143 | * @inheritDoc |
||
144 | */ |
||
145 | public function withUploadedFiles(array $uploadedFiles) |
||
146 | { |
||
147 | $this->validateUploadedFiles($uploadedFiles); |
||
148 | |||
149 | $new = clone $this; |
||
150 | $new->uploadedFiles = $uploadedFiles; |
||
151 | |||
152 | return $new; |
||
153 | } |
||
154 | |||
155 | /** |
||
156 | * @inheritDoc |
||
157 | */ |
||
158 | public function getParsedBody() |
||
159 | { |
||
160 | return $this->parsedBody; |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * @inheritDoc |
||
165 | */ |
||
166 | public function withParsedBody($data) |
||
167 | { |
||
168 | $new = clone $this; |
||
169 | $new->parsedBody = $data; |
||
170 | |||
171 | return $new; |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * @inheritDoc |
||
176 | */ |
||
177 | 1 | public function getAttributes() : array |
|
181 | |||
182 | /** |
||
183 | * @inheritDoc |
||
184 | */ |
||
185 | 1 | public function getAttribute($name, $default = null) |
|
189 | |||
190 | /** |
||
191 | * @inheritDoc |
||
192 | */ |
||
193 | 1 | public function withAttribute($name, $value) |
|
200 | |||
201 | /** |
||
202 | * @inheritDoc |
||
203 | */ |
||
204 | 1 | public function withoutAttribute($name) |
|
211 | |||
212 | /** |
||
213 | * Recursively validate the structure in an uploaded files array. |
||
214 | * |
||
215 | * @param array $uploadedFiles |
||
216 | * |
||
217 | * @throws InvalidArgumentException if any leaf is not an UploadedFileInterface instance. |
||
218 | */ |
||
219 | 5 | protected function validateUploadedFiles(array $uploadedFiles) |
|
232 | } |
||
233 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.