@@ -19,11 +19,11 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | function marshalProtocolVersionFromSapi(array $server) : string |
| 21 | 21 | { |
| 22 | - if (! isset($server['SERVER_PROTOCOL'])) { |
|
| 22 | + if (!isset($server['SERVER_PROTOCOL'])) { |
|
| 23 | 23 | return '1.1'; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - if (! preg_match('#^(HTTP/)?(?P<version>[1-9]\d*(?:\.\d)?)$#', $server['SERVER_PROTOCOL'], $matches)) { |
|
| 26 | + if (!preg_match('#^(HTTP/)?(?P<version>[1-9]\d*(?:\.\d)?)$#', $server['SERVER_PROTOCOL'], $matches)) { |
|
| 27 | 27 | throw Exception\UnrecognizedProtocolVersionException::forVersion( |
| 28 | 28 | (string) $server['SERVER_PROTOCOL'] |
| 29 | 29 | ); |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | // If the HTTP_AUTHORIZATION value is already set, or the callback is not |
| 33 | 33 | // callable, we return verbatim |
| 34 | 34 | if (isset($server['HTTP_AUTHORIZATION']) |
| 35 | - || ! is_callable($apacheRequestHeaderCallback) |
|
| 35 | + || !is_callable($apacheRequestHeaderCallback) |
|
| 36 | 36 | ) { |
| 37 | 37 | return $server; |
| 38 | 38 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param string[]|array[]|null $typeTree |
| 35 | 35 | * @return UploadedFile[]|array[] |
| 36 | 36 | */ |
| 37 | - $recursiveNormalize = function ( |
|
| 37 | + $recursiveNormalize = function( |
|
| 38 | 38 | array $tmpNameTree, |
| 39 | 39 | array $sizeTree, |
| 40 | 40 | array $errorTree, |
@@ -79,10 +79,10 @@ discard block |
||
| 79 | 79 | * @param array $files |
| 80 | 80 | * @return UploadedFile[] |
| 81 | 81 | */ |
| 82 | - $normalizeUploadedFileSpecification = function (array $files = []) use (&$recursiveNormalize) : array { |
|
| 83 | - if (! isset($files['tmp_name']) || ! is_array($files['tmp_name']) |
|
| 84 | - || ! isset($files['size']) || ! is_array($files['size']) |
|
| 85 | - || ! isset($files['error']) || ! is_array($files['error']) |
|
| 82 | + $normalizeUploadedFileSpecification = function(array $files = []) use (&$recursiveNormalize) : array { |
|
| 83 | + if (!isset($files['tmp_name']) || !is_array($files['tmp_name']) |
|
| 84 | + || !isset($files['size']) || !is_array($files['size']) |
|
| 85 | + || !isset($files['error']) || !is_array($files['error']) |
|
| 86 | 86 | ) { |
| 87 | 87 | throw new Exception\InvalidArgumentException(sprintf( |
| 88 | 88 | '$files provided to %s MUST contain each of the keys "tmp_name",' |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | if (strpos($key, 'CONTENT_') === 0) { |
| 49 | - $name = 'content-' . strtolower(substr($key, 8)); |
|
| 49 | + $name = 'content-'.strtolower(substr($key, 8)); |
|
| 50 | 50 | $headers[$name] = $value; |
| 51 | 51 | continue; |
| 52 | 52 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | // per PSR-7: attempt to set the Host header from a provided URI if no |
| 83 | 83 | // Host header is provided |
| 84 | - if (! $this->hasHeader('Host') && $this->uri->getHost()) { |
|
| 84 | + if (!$this->hasHeader('Host') && $this->uri->getHost()) { |
|
| 85 | 85 | $this->headerNames['host'] = 'Host'; |
| 86 | 86 | $this->headers['Host'] = [$this->getHostFromUri()]; |
| 87 | 87 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | $target = $this->uri->getPath(); |
| 142 | 142 | if ($this->uri->getQuery()) { |
| 143 | - $target .= '?' . $this->uri->getQuery(); |
|
| 143 | + $target .= '?'.$this->uri->getQuery(); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | if (empty($target)) { |
@@ -258,13 +258,13 @@ discard block |
||
| 258 | 258 | return $new; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - if (! $uri->getHost()) { |
|
| 261 | + if (!$uri->getHost()) { |
|
| 262 | 262 | return $new; |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | $host = $uri->getHost(); |
| 266 | 266 | if ($uri->getPort()) { |
| 267 | - $host .= ':' . $uri->getPort(); |
|
| 267 | + $host .= ':'.$uri->getPort(); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | $new->headerNames['host'] = 'Host'; |
@@ -291,14 +291,14 @@ discard block |
||
| 291 | 291 | */ |
| 292 | 292 | private function setMethod($method) : void |
| 293 | 293 | { |
| 294 | - if (! is_string($method)) { |
|
| 294 | + if (!is_string($method)) { |
|
| 295 | 295 | throw new Exception\InvalidArgumentException(sprintf( |
| 296 | 296 | 'Unsupported HTTP method; must be a string, received %s', |
| 297 | 297 | is_object($method) ? get_class($method) : gettype($method) |
| 298 | 298 | )); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if (! preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)) { |
|
| 301 | + if (!preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)) { |
|
| 302 | 302 | throw new Exception\InvalidArgumentException(sprintf( |
| 303 | 303 | 'Unsupported HTTP method "%s" provided', |
| 304 | 304 | $method |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | private function getHostFromUri() : string |
| 314 | 314 | { |
| 315 | 315 | $host = $this->uri->getHost(); |
| 316 | - $host .= $this->uri->getPort() ? ':' . $this->uri->getPort() : ''; |
|
| 316 | + $host .= $this->uri->getPort() ? ':'.$this->uri->getPort() : ''; |
|
| 317 | 317 | return $host; |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | private function setStatusCode($code, $reasonPhrase = '') : void |
| 171 | 171 | { |
| 172 | - if (! is_numeric($code) |
|
| 172 | + if (!is_numeric($code) |
|
| 173 | 173 | || is_float($code) |
| 174 | 174 | || $code < static::MIN_STATUS_CODE_VALUE |
| 175 | 175 | || $code > static::MAX_STATUS_CODE_VALUE |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | )); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if (! is_string($reasonPhrase)) { |
|
| 185 | + if (!is_string($reasonPhrase)) { |
|
| 186 | 186 | throw new Exception\InvalidArgumentException(sprintf( |
| 187 | 187 | 'Unsupported response reason phrase; must be a string, received %s', |
| 188 | 188 | is_object($reasonPhrase) ? get_class($reasonPhrase) : gettype($reasonPhrase) |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | public function getHeaders() : array |
| 45 | 45 | { |
| 46 | 46 | $headers = $this->headers; |
| 47 | - if (! $this->hasHeader('host') |
|
| 47 | + if (!$this->hasHeader('host') |
|
| 48 | 48 | && $this->uri->getHost() |
| 49 | 49 | ) { |
| 50 | 50 | $headers['Host'] = [$this->getHostFromUri()]; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function getHeader($header) : array |
| 60 | 60 | { |
| 61 | - if (! $this->hasHeader($header)) { |
|
| 61 | + if (!$this->hasHeader($header)) { |
|
| 62 | 62 | if (strtolower($header) === 'host' |
| 63 | 63 | && $this->uri->getHost() |
| 64 | 64 | ) { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public static function fromStream(StreamInterface $stream) : Request |
| 54 | 54 | { |
| 55 | - if (! $stream->isReadable() || ! $stream->isSeekable()) { |
|
| 55 | + if (!$stream->isReadable() || !$stream->isSeekable()) { |
|
| 56 | 56 | throw new Exception\InvalidArgumentException('Message stream must be both readable and seekable'); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | $body = (string) $request->getBody(); |
| 79 | 79 | $format = '%s %s HTTP/%s%s%s'; |
| 80 | 80 | |
| 81 | - if (! empty($headers)) { |
|
| 82 | - $headers = "\r\n" . $headers; |
|
| 81 | + if (!empty($headers)) { |
|
| 82 | + $headers = "\r\n".$headers; |
|
| 83 | 83 | } |
| 84 | - if (! empty($body)) { |
|
| 84 | + if (!empty($body)) { |
|
| 85 | 85 | $headers .= "\r\n\r\n"; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | $requestLine = self::getLine($stream); |
| 110 | 110 | |
| 111 | - if (! preg_match( |
|
| 111 | + if (!preg_match( |
|
| 112 | 112 | '#^(?P<method>[!\#$%&\'*+.^_`|~a-zA-Z0-9-]+) (?P<target>[^\s]+) HTTP/(?P<version>[1-9]\d*\.\d+)$#', |
| 113 | 113 | $requestLine, |
| 114 | 114 | $matches |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function __toString() : string |
| 66 | 66 | { |
| 67 | - if (! $this->isReadable()) { |
|
| 67 | + if (!$this->isReadable()) { |
|
| 68 | 68 | return ''; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function close() : void |
| 86 | 86 | { |
| 87 | - if (! $this->resource) { |
|
| 87 | + if (!$this->resource) { |
|
| 88 | 88 | return; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -138,12 +138,12 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function tell() : int |
| 140 | 140 | { |
| 141 | - if (! $this->resource) { |
|
| 141 | + if (!$this->resource) { |
|
| 142 | 142 | throw Exception\UntellableStreamException::dueToMissingResource(); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $result = ftell($this->resource); |
| 146 | - if (! is_int($result)) { |
|
| 146 | + if (!is_int($result)) { |
|
| 147 | 147 | throw Exception\UntellableStreamException::dueToPhpError(); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function eof() : bool |
| 157 | 157 | { |
| 158 | - if (! $this->resource) { |
|
| 158 | + if (!$this->resource) { |
|
| 159 | 159 | return true; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | public function isSeekable() : bool |
| 169 | 169 | { |
| 170 | - if (! $this->resource) { |
|
| 170 | + if (!$this->resource) { |
|
| 171 | 171 | return false; |
| 172 | 172 | } |
| 173 | 173 | |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function seek($offset, $whence = SEEK_SET) : void |
| 182 | 182 | { |
| 183 | - if (! $this->resource) { |
|
| 183 | + if (!$this->resource) { |
|
| 184 | 184 | throw Exception\UnseekableStreamException::dueToMissingResource(); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if (! $this->isSeekable()) { |
|
| 187 | + if (!$this->isSeekable()) { |
|
| 188 | 188 | throw Exception\UnseekableStreamException::dueToConfiguration(); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public function isWritable() : bool |
| 210 | 210 | { |
| 211 | - if (! $this->resource) { |
|
| 211 | + if (!$this->resource) { |
|
| 212 | 212 | return false; |
| 213 | 213 | } |
| 214 | 214 | |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public function write($string) : int |
| 231 | 231 | { |
| 232 | - if (! $this->resource) { |
|
| 232 | + if (!$this->resource) { |
|
| 233 | 233 | throw Exception\UnwritableStreamException::dueToMissingResource(); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - if (! $this->isWritable()) { |
|
| 236 | + if (!$this->isWritable()) { |
|
| 237 | 237 | throw Exception\UnwritableStreamException::dueToConfiguration(); |
| 238 | 238 | } |
| 239 | 239 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | public function isReadable() : bool |
| 253 | 253 | { |
| 254 | - if (! $this->resource) { |
|
| 254 | + if (!$this->resource) { |
|
| 255 | 255 | return false; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -266,11 +266,11 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | public function read($length) : string |
| 268 | 268 | { |
| 269 | - if (! $this->resource) { |
|
| 269 | + if (!$this->resource) { |
|
| 270 | 270 | throw Exception\UnreadableStreamException::dueToMissingResource(); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if (! $this->isReadable()) { |
|
| 273 | + if (!$this->isReadable()) { |
|
| 274 | 274 | throw Exception\UnreadableStreamException::dueToConfiguration(); |
| 275 | 275 | } |
| 276 | 276 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | public function getContents() : string |
| 290 | 290 | { |
| 291 | - if (! $this->isReadable()) { |
|
| 291 | + if (!$this->isReadable()) { |
|
| 292 | 292 | throw Exception\UnreadableStreamException::dueToConfiguration(); |
| 293 | 293 | } |
| 294 | 294 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | $metadata = stream_get_meta_data($this->resource); |
| 312 | - if (! array_key_exists($key, $metadata)) { |
|
| 312 | + if (!array_key_exists($key, $metadata)) { |
|
| 313 | 313 | return null; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | $resource = $stream; |
| 330 | 330 | |
| 331 | 331 | if (is_string($stream)) { |
| 332 | - set_error_handler(function ($e) use (&$error) { |
|
| 332 | + set_error_handler(function($e) use (&$error) { |
|
| 333 | 333 | if ($e !== E_WARNING) { |
| 334 | 334 | return; |
| 335 | 335 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | throw new Exception\InvalidArgumentException('Invalid stream reference provided'); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - if (! is_resource($resource) || 'stream' !== get_resource_type($resource)) { |
|
| 347 | + if (!is_resource($resource) || 'stream' !== get_resource_type($resource)) { |
|
| 348 | 348 | throw new Exception\InvalidArgumentException( |
| 349 | 349 | 'Invalid stream provided; must be a string stream identifier or stream resource' |
| 350 | 350 | ); |