@@ -39,7 +39,7 @@ |
||
39 | 39 | $mode = $stream->isWritable() ? 'r+' : 'r'; |
40 | 40 | } elseif ($stream->isWritable()) { |
41 | 41 | $mode = 'w'; |
42 | - } else { |
|
42 | + }else { |
|
43 | 43 | throw new \InvalidArgumentException('The stream must be readable, ' |
44 | 44 | . 'writable, or both.'); |
45 | 45 | } |
@@ -18,31 +18,31 @@ discard block |
||
18 | 18 | public static function toString(MessageInterface $message): string |
19 | 19 | { |
20 | 20 | if ($message instanceof RequestInterface) { |
21 | - $msg = trim($message->getMethod() . ' ' |
|
21 | + $msg = trim($message->getMethod().' ' |
|
22 | 22 | . $message->getRequestTarget()) |
23 | - . ' HTTP/' . $message->getProtocolVersion(); |
|
23 | + . ' HTTP/'.$message->getProtocolVersion(); |
|
24 | 24 | if (!$message->hasHeader('host')) { |
25 | - $msg .= "\r\nHost: " . $message->getUri()->getHost(); |
|
25 | + $msg .= "\r\nHost: ".$message->getUri()->getHost(); |
|
26 | 26 | } |
27 | 27 | } elseif ($message instanceof ResponseInterface) { |
28 | - $msg = 'HTTP/' . $message->getProtocolVersion() . ' ' |
|
29 | - . $message->getStatusCode() . ' ' |
|
28 | + $msg = 'HTTP/'.$message->getProtocolVersion().' ' |
|
29 | + . $message->getStatusCode().' ' |
|
30 | 30 | . $message->getReasonPhrase(); |
31 | - } else { |
|
31 | + }else { |
|
32 | 32 | throw new \InvalidArgumentException('Unknown message type'); |
33 | 33 | } |
34 | 34 | |
35 | 35 | foreach ($message->getHeaders() as $name => $values) { |
36 | 36 | if (strtolower($name) === 'set-cookie') { |
37 | 37 | foreach ($values as $value) { |
38 | - $msg .= "\r\n{$name}: " . $value; |
|
38 | + $msg .= "\r\n{$name}: ".$value; |
|
39 | 39 | } |
40 | - } else { |
|
41 | - $msg .= "\r\n{$name}: " . implode(', ', $values); |
|
40 | + }else { |
|
41 | + $msg .= "\r\n{$name}: ".implode(', ', $values); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | - return "{$msg}\r\n\r\n" . $message->getBody(); |
|
45 | + return "{$msg}\r\n\r\n".$message->getBody(); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public static function parseRequestUri(string $path, array $headers): string |
176 | 176 | { |
177 | - $hostKey = array_filter(array_keys($headers), function ($k) { |
|
177 | + $hostKey = array_filter(array_keys($headers), function($k) { |
|
178 | 178 | // Numeric array keys are converted to int by PHP. |
179 | 179 | $k = (string) $k; |
180 | 180 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $host = $headers[reset($hostKey)][0]; |
190 | 190 | $scheme = substr($host, -4) === ':443' ? 'https' : 'http'; |
191 | 191 | |
192 | - return $scheme . '://' . $host . '/' . ltrim($path, '/'); |
|
192 | + return $scheme.'://'.$host.'/'.ltrim($path, '/'); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | // between status-code and reason-phrase is required. But browsers accept |
231 | 231 | // responses without space and reason as well. |
232 | 232 | if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) { |
233 | - throw new \InvalidArgumentException('Invalid response string: ' . $data['start-line']); |
|
233 | + throw new \InvalidArgumentException('Invalid response string: '.$data['start-line']); |
|
234 | 234 | } |
235 | 235 | $parts = explode(' ', $data['start-line'], 3); |
236 | 236 |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } elseif (is_array($value)) { |
97 | 97 | $normalized[$key] = self::normalizeFiles($value); |
98 | 98 | continue; |
99 | - } else { |
|
99 | + }else { |
|
100 | 100 | throw new InvalidArgumentException('Invalid value in files specification'); |
101 | 101 | } |
102 | 102 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | private static function extractHostAndPortFromAuthority(string $authority): array |
184 | 184 | { |
185 | - $uri = 'http://' . $authority; |
|
185 | + $uri = 'http://'.$authority; |
|
186 | 186 | $parts = parse_url($uri); |
187 | 187 | if (false === $parts) { |
188 | 188 | return [null, null]; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | if ($path[0] === '/' && (!isset($newPath[0]) || $newPath[0] !== '/')) { |
42 | 42 | // Re-add the leading slash if necessary for cases like "/.." |
43 | - $newPath = '/' . $newPath; |
|
43 | + $newPath = '/'.$newPath; |
|
44 | 44 | } elseif ($newPath !== '' && ($segment === '.' || $segment === '..')) { |
45 | 45 | // Add the trailing slash if necessary |
46 | 46 | // If newPath is not empty, then $segment must be set and is the last segment from the foreach |
@@ -70,23 +70,23 @@ discard block |
||
70 | 70 | $targetAuthority = $rel->getAuthority(); |
71 | 71 | $targetPath = self::removeDotSegments($rel->getPath()); |
72 | 72 | $targetQuery = $rel->getQuery(); |
73 | - } else { |
|
73 | + }else { |
|
74 | 74 | $targetAuthority = $base->getAuthority(); |
75 | 75 | if ($rel->getPath() === '') { |
76 | 76 | $targetPath = $base->getPath(); |
77 | 77 | $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery(); |
78 | - } else { |
|
78 | + }else { |
|
79 | 79 | if ($rel->getPath()[0] === '/') { |
80 | 80 | $targetPath = $rel->getPath(); |
81 | - } else { |
|
81 | + }else { |
|
82 | 82 | if ($targetAuthority != '' && $base->getPath() === '') { |
83 | - $targetPath = '/' . $rel->getPath(); |
|
84 | - } else { |
|
83 | + $targetPath = '/'.$rel->getPath(); |
|
84 | + }else { |
|
85 | 85 | $lastSlashPos = strrpos($base->getPath(), '/'); |
86 | 86 | if ($lastSlashPos === false) { |
87 | 87 | $targetPath = $rel->getPath(); |
88 | - } else { |
|
89 | - $targetPath = substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath(); |
|
88 | + }else { |
|
89 | + $targetPath = substr($base->getPath(), 0, $lastSlashPos + 1).$rel->getPath(); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
@@ -180,12 +180,12 @@ discard block |
||
180 | 180 | foreach ($sourceSegments as $i => $segment) { |
181 | 181 | if (isset($targetSegments[$i]) && $segment === $targetSegments[$i]) { |
182 | 182 | unset($sourceSegments[$i], $targetSegments[$i]); |
183 | - } else { |
|
183 | + }else { |
|
184 | 184 | break; |
185 | 185 | } |
186 | 186 | } |
187 | 187 | $targetSegments[] = $targetLastSegment; |
188 | - $relativePath = str_repeat('../', count($sourceSegments)) . implode('/', $targetSegments); |
|
188 | + $relativePath = str_repeat('../', count($sourceSegments)).implode('/', $targetSegments); |
|
189 | 189 | |
190 | 190 | // A reference to am empty last segment or an empty first sub-segment must be prefixed with "./". |
191 | 191 | // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | if ($base->getAuthority() != '' && $base->getPath() === '') { |
197 | 197 | // In this case an extra slash is added by resolve() automatically. So we must not add one here. |
198 | 198 | $relativePath = ".$relativePath"; |
199 | - } else { |
|
199 | + }else { |
|
200 | 200 | $relativePath = "./$relativePath"; |
201 | 201 | } |
202 | 202 | } |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | $this->stream = $stream; |
62 | 62 | $meta = stream_get_meta_data($this->stream); |
63 | 63 | $this->seekable = $meta['seekable']; |
64 | - $this->readable = (bool)preg_match(self::READABLE_MODES, $meta['mode']); |
|
65 | - $this->writable = (bool)preg_match(self::WRITABLE_MODES, $meta['mode']); |
|
64 | + $this->readable = (bool) preg_match(self::READABLE_MODES, $meta['mode']); |
|
65 | + $this->writable = (bool) preg_match(self::WRITABLE_MODES, $meta['mode']); |
|
66 | 66 | $this->uri = $this->getMetadata('uri'); |
67 | 67 | } |
68 | 68 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | } |
208 | 208 | if (fseek($this->stream, $offset, $whence) === -1) { |
209 | 209 | throw new \RuntimeException('Unable to seek to stream position ' |
210 | - . $offset . ' with whence ' . var_export($whence, true)); |
|
210 | + . $offset.' with whence '.var_export($whence, true)); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | return null; |
64 | 64 | } elseif ($this->limit === -1) { |
65 | 65 | return $length - $this->offset; |
66 | - } else { |
|
66 | + }else { |
|
67 | 67 | return min($this->limit, $length - $this->offset); |
68 | 68 | } |
69 | 69 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $this->stream->seek($offset); |
118 | 118 | } elseif ($current > $offset) { |
119 | 119 | throw new \RuntimeException("Could not seek to stream offset $offset"); |
120 | - } else { |
|
120 | + }else { |
|
121 | 121 | $this->stream->read($offset - $current); |
122 | 122 | } |
123 | 123 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $size = $this->cacheEntireStream(); |
68 | 68 | } |
69 | 69 | $byte = $size + $offset; |
70 | - } else { |
|
70 | + }else { |
|
71 | 71 | throw new \InvalidArgumentException('Invalid whence'); |
72 | 72 | } |
73 | 73 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $this->read($diff); |
81 | 81 | $diff = $byte - $this->stream->getSize(); |
82 | 82 | } |
83 | - } else { |
|
83 | + }else { |
|
84 | 84 | // We can just do a normal seek since we've already seen this byte. |
85 | 85 | $this->stream->seek($byte); |
86 | 86 | } |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | /** @var string */ |
116 | 116 | $encodedUrl = preg_replace_callback( |
117 | 117 | '%[^:/@?&=#]+%usD', |
118 | - static function ($matches) { |
|
118 | + static function($matches) { |
|
119 | 119 | return urlencode($matches[0]); |
120 | 120 | }, |
121 | 121 | $url |
122 | 122 | ); |
123 | 123 | |
124 | - $result = parse_url($prefix . $encodedUrl); |
|
124 | + $result = parse_url($prefix.$encodedUrl); |
|
125 | 125 | |
126 | 126 | if ($result === false) { |
127 | 127 | return false; |
@@ -169,21 +169,21 @@ discard block |
||
169 | 169 | |
170 | 170 | // weak type checks to also accept null until we can add scalar type hints |
171 | 171 | if ($scheme != '') { |
172 | - $uri .= $scheme . ':'; |
|
172 | + $uri .= $scheme.':'; |
|
173 | 173 | } |
174 | 174 | |
175 | - if ($authority != ''|| $scheme === 'file') { |
|
176 | - $uri .= '//' . $authority; |
|
175 | + if ($authority != '' || $scheme === 'file') { |
|
176 | + $uri .= '//'.$authority; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | $uri .= $path; |
180 | 180 | |
181 | 181 | if ($query != '') { |
182 | - $uri .= '?' . $query; |
|
182 | + $uri .= '?'.$query; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | if ($fragment != '') { |
186 | - $uri .= '#' . $fragment; |
|
186 | + $uri .= '#'.$fragment; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | return $uri; |
@@ -370,11 +370,11 @@ discard block |
||
370 | 370 | { |
371 | 371 | $authority = $this->host; |
372 | 372 | if ($this->userInfo !== '') { |
373 | - $authority = $this->userInfo . '@' . $authority; |
|
373 | + $authority = $this->userInfo.'@'.$authority; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | if ($this->port !== null) { |
377 | - $authority .= ':' . $this->port; |
|
377 | + $authority .= ':'.$this->port; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | return $authority; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | { |
432 | 432 | $info = $this->filterUserInfoComponent($user); |
433 | 433 | if ($password !== null) { |
434 | - $info .= ':' . $this->filterUserInfoComponent($password); |
|
434 | + $info .= ':'.$this->filterUserInfoComponent($password); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | if ($this->userInfo === $info) { |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | ? $this->filterQueryAndFragment($parts['fragment']) |
560 | 560 | : ''; |
561 | 561 | if (isset($parts['pass'])) { |
562 | - $this->userInfo .= ':' . $this->filterUserInfoComponent($parts['pass']); |
|
562 | + $this->userInfo .= ':'.$this->filterUserInfoComponent($parts['pass']); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | $this->removeDefaultPort(); |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | } |
592 | 592 | |
593 | 593 | return preg_replace_callback( |
594 | - '/(?:[^%' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . ']+|%(?![A-Fa-f0-9]{2}))/', |
|
594 | + '/(?:[^%'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.']+|%(?![A-Fa-f0-9]{2}))/', |
|
595 | 595 | [$this, 'rawurlencodeMatchZero'], |
596 | 596 | $component |
597 | 597 | ); |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | |
648 | 648 | $decodedKeys = array_map('rawurldecode', $keys); |
649 | 649 | |
650 | - return array_filter(explode('&', $current), function ($part) use ($decodedKeys) { |
|
650 | + return array_filter(explode('&', $current), function($part) use ($decodedKeys) { |
|
651 | 651 | return !in_array(rawurldecode(explode('=', $part)[0]), $decodedKeys, true); |
652 | 652 | }); |
653 | 653 | } |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | $queryString = strtr($key, self::QUERY_SEPARATORS_REPLACEMENT); |
661 | 661 | |
662 | 662 | if ($value !== null) { |
663 | - $queryString .= '=' . strtr($value, self::QUERY_SEPARATORS_REPLACEMENT); |
|
663 | + $queryString .= '='.strtr($value, self::QUERY_SEPARATORS_REPLACEMENT); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | return $queryString; |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | } |
688 | 688 | |
689 | 689 | return preg_replace_callback( |
690 | - '/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/', |
|
690 | + '/(?:[^'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.'%:@\/]++|%(?![A-Fa-f0-9]{2}))/', |
|
691 | 691 | [$this, 'rawurlencodeMatchZero'], |
692 | 692 | $path |
693 | 693 | ); |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | } |
708 | 708 | |
709 | 709 | return preg_replace_callback( |
710 | - '/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', |
|
710 | + '/(?:[^'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.'%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', |
|
711 | 711 | [$this, 'rawurlencodeMatchZero'], |
712 | 712 | $str |
713 | 713 | ); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | { |
186 | 186 | $regex = '/(?:%[A-Fa-f0-9]{2})++/'; |
187 | 187 | |
188 | - $callback = function (array $match) { |
|
188 | + $callback = function(array $match) { |
|
189 | 189 | return strtoupper($match[0]); |
190 | 190 | }; |
191 | 191 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | { |
202 | 202 | $regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i'; |
203 | 203 | |
204 | - $callback = function (array $match) { |
|
204 | + $callback = function(array $match) { |
|
205 | 205 | return rawurldecode($match[0]); |
206 | 206 | }; |
207 | 207 |