1 | <?php declare(strict_types=1); |
||
14 | class ServerRequest extends Request implements ServerRequestInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | private $attributes = []; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | private $cookieParams = []; |
||
25 | |||
26 | /** |
||
27 | * @var null|array|object |
||
28 | */ |
||
29 | private $parsedBody; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | private $queryParams = []; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | private $serverParams; |
||
40 | |||
41 | /** |
||
42 | * @var array |
||
43 | */ |
||
44 | private $uploadedFiles; |
||
45 | |||
46 | |||
47 | /** |
||
48 | * Server request constructor. |
||
49 | * |
||
50 | * @param array $serverParams Server parameters, typically from $_SERVER |
||
51 | * @param array $uploadedFiles Upload file information, a tree of UploadedFiles |
||
52 | * @param null|string $uri URI for the request, if any. |
||
53 | * @param null|string $method HTTP method for the request, if any. |
||
54 | * @param string|resource|StreamInterface $body Messages body, if any. |
||
55 | * @param array $headers Headers for the message, if any. |
||
56 | * @throws \InvalidArgumentException for any invalid value. |
||
57 | */ |
||
58 | 10 | public function __construct( |
|
73 | |||
74 | 10 | private function parseBody(): void |
|
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | 2 | public function getServerParams(): array |
|
103 | |||
104 | /** |
||
105 | * {@inheritdoc} |
||
106 | */ |
||
107 | 2 | public function getUploadedFiles(): array |
|
111 | |||
112 | /** |
||
113 | * {@inheritdoc} |
||
114 | */ |
||
115 | 1 | public function withUploadedFiles(array $uploadedFiles) |
|
123 | |||
124 | /** |
||
125 | * {@inheritdoc} |
||
126 | */ |
||
127 | 2 | public function getCookieParams(): array |
|
131 | |||
132 | /** |
||
133 | * {@inheritdoc} |
||
134 | */ |
||
135 | 1 | public function withCookieParams(array $cookies) |
|
141 | |||
142 | /** |
||
143 | * {@inheritdoc} |
||
144 | */ |
||
145 | 4 | public function getQueryParams(): array |
|
149 | |||
150 | /** |
||
151 | * {@inheritdoc} |
||
152 | */ |
||
153 | 1 | public function withQueryParams(array $query) |
|
160 | |||
161 | /** |
||
162 | * {@inheritdoc} |
||
163 | */ |
||
164 | 4 | public function getParsedBody() |
|
168 | |||
169 | /** |
||
170 | * {@inheritdoc} |
||
171 | */ |
||
172 | 1 | public function withParsedBody($data) |
|
178 | |||
179 | /** |
||
180 | * {@inheritdoc} |
||
181 | */ |
||
182 | 2 | public function getAttributes(): array |
|
186 | |||
187 | /** |
||
188 | * {@inheritdoc} |
||
189 | */ |
||
190 | 1 | public function getAttribute($attribute, $default = null) |
|
198 | |||
199 | /** |
||
200 | * {@inheritdoc} |
||
201 | */ |
||
202 | 1 | public function withAttribute($attribute, $value) |
|
208 | |||
209 | /** |
||
210 | * {@inheritdoc} |
||
211 | */ |
||
212 | 1 | public function withoutAttribute($attribute) |
|
222 | |||
223 | /** |
||
224 | * Sets request attributes |
||
225 | * |
||
226 | * This method returns a new instance. |
||
227 | * |
||
228 | * @param array $attributes |
||
229 | * @return self |
||
230 | */ |
||
231 | 1 | public function withAttributes(array $attributes): ServerRequest |
|
237 | |||
238 | /** |
||
239 | * Recursively validate the structure in an uploaded files array. |
||
240 | * |
||
241 | * @param array $uploadedFiles |
||
242 | * @throws \InvalidArgumentException if any leaf is not an UploadedFileInterface instance. |
||
243 | */ |
||
244 | 10 | private function validateUploadedFiles(array $uploadedFiles): void |
|
257 | |||
258 | 2 | public static function fromGlobals(): ServerRequest |
|
271 | |||
272 | /** |
||
273 | * @param SwooleHttRequest $request |
||
274 | * @return ServerRequest |
||
275 | */ |
||
276 | 4 | public static function fromSwoole(SwooleHttRequest $request): ServerRequest |
|
318 | } |
||
319 |