@@ -146,10 +146,10 @@ |
||
| 146 | 146 | return $headers; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * This static method will create a new Request object, based on the |
|
| 151 | - * current PHP request. |
|
| 152 | - */ |
|
| 149 | + /** |
|
| 150 | + * This static method will create a new Request object, based on the |
|
| 151 | + * current PHP request. |
|
| 152 | + */ |
|
| 153 | 153 | public static function getRequest(): Request |
| 154 | 154 | { |
| 155 | 155 | $serverArr = $_SERVER; |
@@ -175,13 +175,13 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public static function sendResponse(Response $response) |
| 177 | 177 | { |
| 178 | - header('HTTP/'.$response->getHttpVersion().' '.$response->getStatus().' '.$response->getStatusText()); |
|
| 178 | + header('HTTP/' . $response->getHttpVersion() . ' ' . $response->getStatus() . ' ' . $response->getStatusText()); |
|
| 179 | 179 | foreach ($response->getHeaders() as $key => $value) { |
| 180 | 180 | foreach ($value as $k => $v) { |
| 181 | 181 | if (0 === $k) { |
| 182 | - header($key.': '.$v); |
|
| 182 | + header($key . ': ' . $v); |
|
| 183 | 183 | } else { |
| 184 | - header($key.': '.$v, false); |
|
| 184 | + header($key . ': ' . $v, false); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | if (PHP_INT_SIZE > 4) { |
| 205 | 205 | // use the dedicated function on 64 Bit systems |
| 206 | 206 | // a workaround to make PHP more possible to use mmap based copy, see https://github.com/sabre-io/http/pull/119 |
| 207 | - $left = (int) $contentLength; |
|
| 207 | + $left = (int)$contentLength; |
|
| 208 | 208 | // copy with 4MiB chunks |
| 209 | 209 | $chunk_size = 4 * 1024 * 1024; |
| 210 | 210 | stream_set_chunk_size($output, $chunk_size); |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | if (null !== $contentRange && preg_match('/^bytes\s([0-9]+)-([0-9]+)\//i', $contentRange, $matches)) { |
| 215 | 215 | // 4kB should be the default page size on most architectures |
| 216 | 216 | $pageSize = 4096; |
| 217 | - $offset = (int) $matches[1]; |
|
| 217 | + $offset = (int)$matches[1]; |
|
| 218 | 218 | $delta = ($offset % $pageSize) > 0 ? ($pageSize - $offset % $pageSize) : 0; |
| 219 | 219 | if ($delta > 0) { |
| 220 | 220 | $left -= stream_copy_to_stream($body, $output, min($delta, $left)); |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | } else { |
| 241 | - fwrite($output, $body, (int) $contentLength); |
|
| 241 | + fwrite($output, $body, (int)$contentLength); |
|
| 242 | 242 | } |
| 243 | 243 | } else { |
| 244 | 244 | file_put_contents('php://output', $body); |
@@ -293,13 +293,13 @@ discard block |
||
| 293 | 293 | // (fast)cgi does not usually do this, however. |
| 294 | 294 | case 'PHP_AUTH_USER': |
| 295 | 295 | if (isset($serverArray['PHP_AUTH_PW'])) { |
| 296 | - $headers['Authorization'] = 'Basic '.base64_encode($value.':'.$serverArray['PHP_AUTH_PW']); |
|
| 296 | + $headers['Authorization'] = 'Basic ' . base64_encode($value . ':' . $serverArray['PHP_AUTH_PW']); |
|
| 297 | 297 | } |
| 298 | 298 | break; |
| 299 | 299 | |
| 300 | 300 | // Similarly, mod_php may also screw around with digest auth. |
| 301 | 301 | case 'PHP_AUTH_DIGEST': |
| 302 | - $headers['Authorization'] = 'Digest '.$value; |
|
| 302 | + $headers['Authorization'] = 'Digest ' . $value; |
|
| 303 | 303 | break; |
| 304 | 304 | |
| 305 | 305 | // Apache may prefix the HTTP_AUTHORIZATION header with |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | $r = new Request($method, $url, $headers); |
| 349 | 349 | $r->setHttpVersion($httpVersion); |
| 350 | 350 | $r->setRawServerData($serverArray); |
| 351 | - $r->setAbsoluteUrl($protocol.'://'.$hostName.$url); |
|
| 351 | + $r->setAbsoluteUrl($protocol . '://' . $hostName . $url); |
|
| 352 | 352 | |
| 353 | 353 | return $r; |
| 354 | 354 | } |
@@ -345,9 +345,9 @@ discard block |
||
| 345 | 345 | if (!empty($currentRoute)) { |
| 346 | 346 | $currentRoute = current($currentRoute); |
| 347 | 347 | $foundRoute = true; |
| 348 | - $this->runRouteMiddleware($currentRoute, 'before', $this->request, $this->response); |
|
| 348 | + $this->runRouteMiddleware($currentRoute, 'before', $this->request, $this->response); |
|
| 349 | 349 | $this->runRouteCommand($currentRoute['callback']); |
| 350 | - $this->runRouteMiddleware($currentRoute, 'after', $this->request, $this->response); |
|
| 350 | + $this->runRouteMiddleware($currentRoute, 'after', $this->request, $this->response); |
|
| 351 | 351 | } |
| 352 | 352 | } else { |
| 353 | 353 | foreach ($this->routes as $data) { |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | if ($this->request->validMethod($data['method'], $method)) { |
| 361 | 361 | $foundRoute = true; |
| 362 | 362 | |
| 363 | - $this->runRouteMiddleware($data, 'before', $this->reques, $this->response); |
|
| 363 | + $this->runRouteMiddleware($data, 'before', $this->reques, $this->response); |
|
| 364 | 364 | |
| 365 | 365 | array_shift($matched); |
| 366 | 366 | $matched = array_map(function($value) { |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | }, $matched); |
| 369 | 369 | |
| 370 | 370 | $this->runRouteCommand($data['callback'], $matched, $this->request); |
| 371 | - $this->runRouteMiddleware($data, 'after', $this->request, $this->response); |
|
| 371 | + $this->runRouteMiddleware($data, 'after', $this->request, $this->response); |
|
| 372 | 372 | break; |
| 373 | 373 | } |
| 374 | 374 | } |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | * |
| 401 | 401 | * @return bool |
| 402 | 402 | */ |
| 403 | - public function group($settings = null, $callback = null, $name =null) |
|
| 403 | + public function group($settings = null, $callback = null, $name = null) |
|
| 404 | 404 | { |
| 405 | 405 | if ($this->cacheLoaded) { |
| 406 | 406 | return true; |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | $this->criateRoute($route, $groupItem, $method, $callback, $settings); |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - private function criateRoute($route, $groupItem, $method, $callback, $settings){ |
|
| 563 | + private function criateRoute($route, $groupItem, $method, $callback, $settings) { |
|
| 564 | 564 | $routeName = is_string($callback) |
| 565 | 565 | ? strtolower(preg_replace( |
| 566 | 566 | '/[^\w]/i', '/', str_replace($this->namespaces['controllers'], '', $callback) |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | if (is_string($body) || null === $body) { |
| 62 | 62 | $stream = fopen('php://temp', 'r+'); |
| 63 | - fwrite($stream, (string) $body); |
|
| 63 | + fwrite($stream, (string)$body); |
|
| 64 | 64 | rewind($stream); |
| 65 | 65 | |
| 66 | 66 | return $stream; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | $contentLength = $this->getHeader('Content-Length'); |
| 97 | 97 | if (is_int($contentLength) || ctype_digit($contentLength)) { |
| 98 | - return stream_get_contents($body, (int) $contentLength); |
|
| 98 | + return stream_get_contents($body, (int)$contentLength); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | return stream_get_contents($body); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function setHeader(string $name, $value) |
| 206 | 206 | { |
| 207 | - $this->headers[strtolower($name)] = [$name, (array) $value]; |
|
| 207 | + $this->headers[strtolower($name)] = [$name, (array)$value]; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -237,12 +237,12 @@ discard block |
||
| 237 | 237 | if (isset($this->headers[$lName])) { |
| 238 | 238 | $this->headers[$lName][1] = array_merge( |
| 239 | 239 | $this->headers[$lName][1], |
| 240 | - (array) $value |
|
| 240 | + (array)$value |
|
| 241 | 241 | ); |
| 242 | 242 | } else { |
| 243 | 243 | $this->headers[$lName] = [ |
| 244 | 244 | $name, |
| 245 | - (array) $value, |
|
| 245 | + (array)$value, |
|
| 246 | 246 | ]; |
| 247 | 247 | } |
| 248 | 248 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $statusCode, |
| 167 | 167 | $statusText |
| 168 | 168 | ) = explode(' ', $status, 2); |
| 169 | - $statusCode = (int) $statusCode; |
|
| 169 | + $statusCode = (int)$statusCode; |
|
| 170 | 170 | } |
| 171 | 171 | if ($statusCode < 100 || $statusCode > 999) { |
| 172 | 172 | throw new \InvalidArgumentException('The HTTP status code must be exactly 3 digits'); |
@@ -183,10 +183,10 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function __toString(): string |
| 185 | 185 | { |
| 186 | - $str = 'HTTP/'.$this->httpVersion.' '.$this->getStatus().' '.$this->getStatusText()."\r\n"; |
|
| 186 | + $str = 'HTTP/' . $this->httpVersion . ' ' . $this->getStatus() . ' ' . $this->getStatusText() . "\r\n"; |
|
| 187 | 187 | foreach ($this->getHeaders() as $key => $value) { |
| 188 | 188 | foreach ($value as $v) { |
| 189 | - $str .= $key.': '.$v."\r\n"; |
|
| 189 | + $str .= $key . ': ' . $v . "\r\n"; |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | $str .= "\r\n"; |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | { |
| 115 | 115 | if (!$this->absoluteUrl) { |
| 116 | 116 | // Guessing we're a http endpoint. |
| 117 | - $this->absoluteUrl = 'http://'. |
|
| 118 | - ($this->getHeader('Host') ?? 'localhost'). |
|
| 117 | + $this->absoluteUrl = 'http://' . |
|
| 118 | + ($this->getHeader('Host') ?? 'localhost') . |
|
| 119 | 119 | $this->getUrl(); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -177,13 +177,13 @@ discard block |
||
| 177 | 177 | return trim(substr($uri, strlen($baseUri)), '/'); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if ($uri.'/' === $baseUri) { |
|
| 180 | + if ($uri . '/' === $baseUri) { |
|
| 181 | 181 | return ''; |
| 182 | 182 | } |
| 183 | 183 | // A special case, if the baseUri was accessed without a trailing |
| 184 | 184 | // slash, we'll accept it as well. |
| 185 | 185 | |
| 186 | - throw new \LogicException('Requested uri ('.$this->getUrl().') is out of base uri ('.$this->getBaseUrl().')'); |
|
| 186 | + throw new \LogicException('Requested uri (' . $this->getUrl() . ') is out of base uri (' . $this->getBaseUrl() . ')'); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | public function __toString(): string |
| 252 | 252 | { |
| 253 | - $out = $this->getMethod().' '.$this->getUrl().' HTTP/'.$this->getHttpVersion()."\r\n"; |
|
| 253 | + $out = $this->getMethod() . ' ' . $this->getUrl() . ' HTTP/' . $this->getHttpVersion() . "\r\n"; |
|
| 254 | 254 | |
| 255 | 255 | foreach ($this->getHeaders() as $key => $value) { |
| 256 | 256 | foreach ($value as $v) { |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | list($v) = explode(' ', $v, 2); |
| 259 | 259 | $v .= ' REDACTED'; |
| 260 | 260 | } |
| 261 | - $out .= $key.': '.$v."\r\n"; |
|
| 261 | + $out .= $key . ': ' . $v . "\r\n"; |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | $out .= "\r\n"; |