@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $buffer = ''; |
| 41 | 41 | $maxSize = $this->maxSize; |
| 42 | 42 | $that = $this; |
| 43 | - $conn->on('data', $fn = function ($data) use (&$buffer, &$fn, $conn, $maxSize, $that) { |
|
| 43 | + $conn->on('data', $fn = function($data) use (&$buffer, &$fn, $conn, $maxSize, $that) { |
|
| 44 | 44 | // append chunk of data to buffer and look for end of request headers |
| 45 | 45 | $buffer .= $data; |
| 46 | 46 | $endOfHeader = \strpos($buffer, "\r\n\r\n"); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | try { |
| 70 | 70 | $request = $that->parseRequest( |
| 71 | - (string)\substr($buffer, 0, $endOfHeader + 2), |
|
| 71 | + (string) \substr($buffer, 0, $endOfHeader + 2), |
|
| 72 | 72 | $conn |
| 73 | 73 | ); |
| 74 | 74 | } catch (Exception $exception) { |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | if ($request->hasHeader('Transfer-Encoding')) { |
| 85 | 85 | $contentLength = null; |
| 86 | 86 | } elseif ($request->hasHeader('Content-Length')) { |
| 87 | - $contentLength = (int)$request->getHeaderLine('Content-Length'); |
|
| 87 | + $contentLength = (int) $request->getHeaderLine('Content-Length'); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | if ($contentLength === 0) { |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | // remember server params for all requests from this connection, reset on connection close |
| 164 | 164 | $this->connectionParams[$cid] = $serverParams; |
| 165 | - $params =& $this->connectionParams; |
|
| 166 | - $connection->on('close', function () use (&$params, $cid) { |
|
| 165 | + $params = & $this->connectionParams; |
|
| 166 | + $connection->on('close', function() use (&$params, $cid) { |
|
| 167 | 167 | assert(\is_array($params)); |
| 168 | 168 | unset($params[$cid]); |
| 169 | 169 | }); |
@@ -93,7 +93,7 @@ |
||
| 93 | 93 | */ |
| 94 | 94 | public function moveTo($targetPath) |
| 95 | 95 | { |
| 96 | - throw new RuntimeException('Not implemented'); |
|
| 96 | + throw new RuntimeException('Not implemented'); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -42,8 +42,8 @@ |
||
| 42 | 42 | $this->now = \microtime(true); |
| 43 | 43 | |
| 44 | 44 | // remember clock for current loop tick only and update on next tick |
| 45 | - $now =& $this->now; |
|
| 46 | - $this->loop->futureTick(function () use (&$now) { |
|
| 45 | + $now = & $this->now; |
|
| 46 | + $this->loop->futureTick(function() use (&$now) { |
|
| 47 | 47 | assert($now !== null); |
| 48 | 48 | $now = null; |
| 49 | 49 | }); |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | $this->idleConnections[] = $connection; |
| 102 | 102 | |
| 103 | 103 | $that = $this; |
| 104 | - $cleanUp = function () use ($connection, $that) { |
|
| 104 | + $cleanUp = function() use ($connection, $that) { |
|
| 105 | 105 | // call public method to support legacy PHP 5.3 |
| 106 | 106 | $that->cleanUpConnection($connection); |
| 107 | 107 | }; |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $that = $this; |
| 53 | - $next = function (ServerRequestInterface $request) use ($that, $position) { |
|
| 53 | + $next = function(ServerRequestInterface $request) use ($that, $position) { |
|
| 54 | 54 | return $that->call($request, $position + 1); |
| 55 | 55 | }; |
| 56 | 56 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | public static function iniSizeToBytes($size) |
| 17 | 17 | { |
| 18 | 18 | if (\is_numeric($size)) { |
| 19 | - return (int)$size; |
|
| 19 | + return (int) $size; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | $suffix = \strtoupper(\substr($size, -1)); |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | return $strippedSize * 1024 * 1024 * 1024; |
| 41 | 41 | } |
| 42 | 42 | if ($suffix === 'T') { |
| 43 | - return $strippedSize * 1024 * 1024 * 1024 * 1024; |
|
| 43 | + return $strippedSize * 1024 * 1024 * 1024 * 1024; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - return (int)$size; |
|
| 46 | + return (int) $size; |
|
| 47 | 47 | } |
| 48 | 48 | } |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | $this->size = $size; |
| 25 | 25 | |
| 26 | 26 | $that = $this; |
| 27 | - $pos =& $this->position; |
|
| 28 | - $input->on('data', function ($data) use ($that, &$pos, $size) { |
|
| 27 | + $pos = & $this->position; |
|
| 28 | + $input->on('data', function($data) use ($that, &$pos, $size) { |
|
| 29 | 29 | $that->emit('data', array($data)); |
| 30 | 30 | |
| 31 | 31 | $pos += \strlen($data); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $that->handleEnd(); |
| 34 | 34 | } |
| 35 | 35 | }); |
| 36 | - $input->on('error', function ($error) use ($that) { |
|
| 36 | + $input->on('error', function($error) use ($that) { |
|
| 37 | 37 | $that->emit('error', array($error)); |
| 38 | 38 | $that->close(); |
| 39 | 39 | }); |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | $var = \ini_get('max_input_vars'); |
| 85 | 85 | if ($var !== false) { |
| 86 | - $this->maxInputVars = (int)$var; |
|
| 86 | + $this->maxInputVars = (int) $var; |
|
| 87 | 87 | } |
| 88 | 88 | $var = \ini_get('max_input_nesting_level'); |
| 89 | 89 | if ($var !== false) { |
| 90 | - $this->maxInputNestingLevel = (int)$var; |
|
| 90 | + $this->maxInputNestingLevel = (int) $var; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | if ($uploadMaxFilesize === null) { |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $this->uploadMaxFilesize = IniUtil::iniSizeToBytes($uploadMaxFilesize); |
| 98 | - $this->maxFileUploads = $maxFileUploads === null ? (\ini_get('file_uploads') === '' ? 0 : (int)\ini_get('max_file_uploads')) : (int)$maxFileUploads; |
|
| 98 | + $this->maxFileUploads = $maxFileUploads === null ? (\ini_get('file_uploads') === '' ? 0 : (int) \ini_get('max_file_uploads')) : (int) $maxFileUploads; |
|
| 99 | 99 | |
| 100 | 100 | $this->maxMultipartBodyParts = $this->maxInputVars + $this->maxFileUploads; |
| 101 | 101 | } |
@@ -103,12 +103,12 @@ discard block |
||
| 103 | 103 | public function parse(ServerRequestInterface $request) |
| 104 | 104 | { |
| 105 | 105 | $contentType = $request->getHeaderLine('content-type'); |
| 106 | - if(!\preg_match('/boundary="?(.*?)"?$/', $contentType, $matches)) { |
|
| 106 | + if (!\preg_match('/boundary="?(.*?)"?$/', $contentType, $matches)) { |
|
| 107 | 107 | return $request; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $this->request = $request; |
| 111 | - $this->parseBody('--' . $matches[1], (string)$request->getBody()); |
|
| 111 | + $this->parseBody('--' . $matches[1], (string) $request->getBody()); |
|
| 112 | 112 | |
| 113 | 113 | $request = $this->request; |
| 114 | 114 | $this->request = null; |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | return; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $headers = $this->parseHeaders((string)substr($chunk, 0, $pos)); |
|
| 159 | - $body = (string)\substr($chunk, $pos + 4); |
|
| 158 | + $headers = $this->parseHeaders((string) substr($chunk, 0, $pos)); |
|
| 159 | + $body = (string) \substr($chunk, $pos + 4); |
|
| 160 | 160 | |
| 161 | 161 | if (!isset($headers['content-disposition'])) { |
| 162 | 162 | return; |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | )); |
| 265 | 265 | |
| 266 | 266 | if (\strtoupper($name) === 'MAX_FILE_SIZE') { |
| 267 | - $this->maxFileSize = (int)$value; |
|
| 267 | + $this->maxFileSize = (int) $value; |
|
| 268 | 268 | |
| 269 | 269 | if ($this->maxFileSize === 0) { |
| 270 | 270 | $this->maxFileSize = null; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | if ($size !== null && $size !== 0) { |
| 88 | 88 | // automatically assign a "Content-Length" request header if the body size is known and non-empty |
| 89 | - $request = $request->withHeader('Content-Length', (string)$size); |
|
| 89 | + $request = $request->withHeader('Content-Length', (string) $size); |
|
| 90 | 90 | } elseif ($size === 0 && \in_array($request->getMethod(), array('POST', 'PUT', 'PATCH'))) { |
| 91 | 91 | // only assign a "Content-Length: 0" request header if the body is expected for certain methods |
| 92 | 92 | $request = $request->withHeader('Content-Length', '0'); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | $requestStream = $this->http->request($request); |
| 107 | 107 | |
| 108 | - $deferred = new Deferred(function ($_, $reject) use ($requestStream) { |
|
| 108 | + $deferred = new Deferred(function($_, $reject) use ($requestStream) { |
|
| 109 | 109 | // close request stream if request is cancelled |
| 110 | 110 | $reject(new \RuntimeException('Request cancelled')); |
| 111 | 111 | $requestStream->close(); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $deferred->reject($error); |
| 116 | 116 | }); |
| 117 | 117 | |
| 118 | - $requestStream->on('response', function (ResponseInterface $response) use ($deferred, $request) { |
|
| 118 | + $requestStream->on('response', function(ResponseInterface $response) use ($deferred, $request) { |
|
| 119 | 119 | $deferred->resolve($response); |
| 120 | 120 | }); |
| 121 | 121 | |
@@ -131,16 +131,16 @@ discard block |
||
| 131 | 131 | $body->pipe($requestStream); |
| 132 | 132 | $requestStream->write(''); |
| 133 | 133 | |
| 134 | - $body->on('close', $close = function () use ($deferred, $requestStream) { |
|
| 134 | + $body->on('close', $close = function() use ($deferred, $requestStream) { |
|
| 135 | 135 | $deferred->reject(new \RuntimeException('Request failed because request body closed unexpectedly')); |
| 136 | 136 | $requestStream->close(); |
| 137 | 137 | }); |
| 138 | - $body->on('error', function ($e) use ($deferred, $requestStream, $close, $body) { |
|
| 138 | + $body->on('error', function($e) use ($deferred, $requestStream, $close, $body) { |
|
| 139 | 139 | $body->removeListener('close', $close); |
| 140 | 140 | $deferred->reject(new \RuntimeException('Request failed because request body reported an error', 0, $e)); |
| 141 | 141 | $requestStream->close(); |
| 142 | 142 | }); |
| 143 | - $body->on('end', function () use ($close, $body) { |
|
| 143 | + $body->on('end', function() use ($close, $body) { |
|
| 144 | 144 | $body->removeListener('close', $close); |
| 145 | 145 | }); |
| 146 | 146 | } else { |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | } else { |
| 151 | 151 | // body is fully buffered => write as one chunk |
| 152 | - $requestStream->end((string)$body); |
|
| 152 | + $requestStream->end((string) $body); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | return $deferred->promise(); |