PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/sdk/google/guzzlehttp/psr7/src/ServerRequest.php +31 -31 1.2.5 → 1.4.2 View file →
@@ -1,14 +1,14 @@
1 1 <?php
2 2
3 3 declare (strict_types=1);
4 -namespace Dudlewebs\WPMCS\GuzzleHttp\Psr7;
4 +namespace Dudlewebs\WPMCS\GCP\GuzzleHttp\Psr7;
5 5
6 6 use InvalidArgumentException;
7 -use Dudlewebs\WPMCS\Psr\Http\Message\ServerRequestInterface;
8 -use Dudlewebs\WPMCS\Psr\Http\Message\StreamInterface;
9 -use Dudlewebs\WPMCS\Psr\Http\Message\UploadedFileInterface;
10 -use Dudlewebs\WPMCS\Psr\Http\Message\UriInterface;
7 +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\ServerRequestInterface;
8 +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\StreamInterface;
9 +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\UploadedFileInterface;
10 +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\UriInterface;
11 11 /**
12 12 * Server-side HTTP request
13 13 *
14 14 * Extends the Request definition to add methods for accessing incoming data,
@@ -67,17 +67,17 @@
67 67 * @param array $files An array which respect $_FILES structure
68 68 *
69 69 * @throws InvalidArgumentException for unrecognized values
70 70 */
71 - public static function normalizeFiles(array $files): array
71 + public static function normalizeFiles(array $files) : array
72 72 {
73 73 $normalized = [];
74 74 foreach ($files as $key => $value) {
75 75 if ($value instanceof UploadedFileInterface) {
76 76 $normalized[$key] = $value;
77 - } elseif (is_array($value) && isset($value['tmp_name'])) {
77 + } elseif (\is_array($value) && isset($value['tmp_name'])) {
78 78 $normalized[$key] = self::createUploadedFileFromSpec($value);
79 - } elseif (is_array($value)) {
79 + } elseif (\is_array($value)) {
80 80 $normalized[$key] = self::normalizeFiles($value);
81 81 continue;
82 82 } else {
83 83 throw new InvalidArgumentException('Invalid value in files specification');
@@ -96,9 +96,9 @@
96 96 * @return UploadedFileInterface|UploadedFileInterface[]
97 97 */
98 98 private static function createUploadedFileFromSpec(array $value)
99 99 {
100 - if (is_array($value['tmp_name'])) {
100 + if (\is_array($value['tmp_name'])) {
101 101 return self::normalizeNestedFileSpec($value);
102 102 }
103 103 return new UploadedFile($value['tmp_name'], (int) $value['size'], (int) $value['error'], $value['name'], $value['type']);
104 104 }
@@ -109,12 +109,12 @@
109 109 * UploadedFileInterface instances.
110 110 *
111 111 * @return UploadedFileInterface[]
112 112 */
113 - private static function normalizeNestedFileSpec(array $files = []): array
113 + private static function normalizeNestedFileSpec(array $files = []) : array
114 114 {
115 115 $normalizedFiles = [];
116 - foreach (array_keys($files['tmp_name']) as $key) {
116 + foreach (\array_keys($files['tmp_name']) as $key) {
117 117 $spec = ['tmp_name' => $files['tmp_name'][$key], 'size' => $files['size'][$key] ?? null, 'error' => $files['error'][$key] ?? null, 'name' => $files['name'][$key] ?? null, 'type' => $files['type'][$key] ?? null];
118 118 $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec);
119 119 }
120 120 return $normalizedFiles;
@@ -126,22 +126,22 @@
126 126 * $_COOKIE
127 127 * $_FILES
128 128 * $_SERVER
129 129 */
130 - public static function fromGlobals(): ServerRequestInterface
130 + public static function fromGlobals() : ServerRequestInterface
131 131 {
132 132 $method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
133 - $headers = getallheaders();
133 + $headers = \getallheaders();
134 134 $uri = self::getUriFromGlobals();
135 135 $body = new CachingStream(new LazyOpenStream('php://input', 'r+'));
136 - $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1';
136 + $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? \str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1';
137 137 $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER);
138 138 return $serverRequest->withCookieParams($_COOKIE)->withQueryParams($_GET)->withParsedBody($_POST)->withUploadedFiles(self::normalizeFiles($_FILES));
139 139 }
140 - private static function extractHostAndPortFromAuthority(string $authority): array
140 + private static function extractHostAndPortFromAuthority(string $authority) : array
141 141 {
142 142 $uri = 'http://' . $authority;
143 - $parts = parse_url($uri);
143 + $parts = \parse_url($uri);
144 144 if (\false === $parts) {
145 145 return [null, null];
146 146 }
147 147 $host = $parts['host'] ?? null;
@@ -150,9 +150,9 @@
150 150 }
151 151 /**
152 152 * Get a Uri populated with values from $_SERVER.
153 153 */
154 - public static function getUriFromGlobals(): UriInterface
154 + public static function getUriFromGlobals() : UriInterface
155 155 {
156 156 $uri = new Uri('');
157 157 $uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http');
158 158 $hasPort = \false;
@@ -174,9 +174,9 @@
174 174 $uri = $uri->withPort($_SERVER['SERVER_PORT']);
175 175 }
176 176 $hasQuery = \false;
177 177 if (isset($_SERVER['REQUEST_URI'])) {
178 - $requestUriParts = explode('?', $_SERVER['REQUEST_URI'], 2);
178 + $requestUriParts = \explode('?', $_SERVER['REQUEST_URI'], 2);
179 179 $uri = $uri->withPath($requestUriParts[0]);
180 180 if (isset($requestUriParts[1])) {
181 181 $hasQuery = \true;
182 182 $uri = $uri->withQuery($requestUriParts[1]);
@@ -186,37 +186,37 @@
186 186 $uri = $uri->withQuery($_SERVER['QUERY_STRING']);
187 187 }
188 188 return $uri;
189 189 }
190 - public function getServerParams(): array
190 + public function getServerParams() : array
191 191 {
192 192 return $this->serverParams;
193 193 }
194 - public function getUploadedFiles(): array
194 + public function getUploadedFiles() : array
195 195 {
196 196 return $this->uploadedFiles;
197 197 }
198 - public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface
198 + public function withUploadedFiles(array $uploadedFiles) : ServerRequestInterface
199 199 {
200 200 $new = clone $this;
201 201 $new->uploadedFiles = $uploadedFiles;
202 202 return $new;
203 203 }
204 - public function getCookieParams(): array
204 + public function getCookieParams() : array
205 205 {
206 206 return $this->cookieParams;
207 207 }
208 - public function withCookieParams(array $cookies): ServerRequestInterface
208 + public function withCookieParams(array $cookies) : ServerRequestInterface
209 209 {
210 210 $new = clone $this;
211 211 $new->cookieParams = $cookies;
212 212 return $new;
213 213 }
214 - public function getQueryParams(): array
214 + public function getQueryParams() : array
215 215 {
216 216 return $this->queryParams;
217 217 }
218 - public function withQueryParams(array $query): ServerRequestInterface
218 + public function withQueryParams(array $query) : ServerRequestInterface
219 219 {
220 220 $new = clone $this;
221 221 $new->queryParams = $query;
222 222 return $new;
@@ -227,15 +227,15 @@
227 227 public function getParsedBody()
228 228 {
229 229 return $this->parsedBody;
230 230 }
231 - public function withParsedBody($data): ServerRequestInterface
231 + public function withParsedBody($data) : ServerRequestInterface
232 232 {
233 233 $new = clone $this;
234 234 $new->parsedBody = $data;
235 235 return $new;
236 236 }
237 - public function getAttributes(): array
237 + public function getAttributes() : array
238 238 {
239 239 return $this->attributes;
240 240 }
241 241 /**
@@ -242,22 +242,22 @@
242 242 * @return mixed
243 243 */
244 244 public function getAttribute($attribute, $default = null)
245 245 {
246 - if (\false === array_key_exists($attribute, $this->attributes)) {
246 + if (\false === \array_key_exists($attribute, $this->attributes)) {
247 247 return $default;
248 248 }
249 249 return $this->attributes[$attribute];
250 250 }
251 - public function withAttribute($attribute, $value): ServerRequestInterface
251 + public function withAttribute($attribute, $value) : ServerRequestInterface
252 252 {
253 253 $new = clone $this;
254 254 $new->attributes[$attribute] = $value;
255 255 return $new;
256 256 }
257 - public function withoutAttribute($attribute): ServerRequestInterface
257 + public function withoutAttribute($attribute) : ServerRequestInterface
258 258 {
259 - if (\false === array_key_exists($attribute, $this->attributes)) {
259 + if (\false === \array_key_exists($attribute, $this->attributes)) {
260 260 return $this;
261 261 }
262 262 $new = clone $this;
263 263 unset($new->attributes[$attribute]);