@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | // wait for connection |
| 108 | 108 | $loop = $this->loop; |
| 109 | - return new Promise\Promise(function ($resolve, $reject) use ($loop, $stream, $uri) { |
|
| 110 | - $loop->addWriteStream($stream, function ($stream) use ($loop, $resolve, $reject, $uri) { |
|
| 109 | + return new Promise\Promise(function($resolve, $reject) use ($loop, $stream, $uri) { |
|
| 110 | + $loop->addWriteStream($stream, function($stream) use ($loop, $resolve, $reject, $uri) { |
|
| 111 | 111 | $loop->removeWriteStream($stream); |
| 112 | 112 | |
| 113 | 113 | // The following hack looks like the only way to |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | // This is only known to work on Linux, Mac and Windows are known to not support this. |
| 127 | 127 | $errno = 0; |
| 128 | 128 | $errstr = ''; |
| 129 | - \set_error_handler(function ($_, $error) use (&$errno, &$errstr) { |
|
| 129 | + \set_error_handler(function($_, $error) use (&$errno, &$errstr) { |
|
| 130 | 130 | // Match errstr from PHP's warning message. |
| 131 | 131 | // fwrite(): send of 1 bytes failed with errno=111 Connection refused |
| 132 | 132 | \preg_match('/errno=(\d+) (.+)/', $error, $m); |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $resolve(new Connection($stream, $loop)); |
| 154 | 154 | } |
| 155 | 155 | }); |
| 156 | - }, function () use ($loop, $stream, $uri) { |
|
| 156 | + }, function() use ($loop, $stream, $uri) { |
|
| 157 | 157 | $loop->removeWriteStream($stream); |
| 158 | 158 | \fclose($stream); |
| 159 | 159 | |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | $this->server = $server; |
| 73 | 73 | |
| 74 | 74 | $that = $this; |
| 75 | - $server->on('connection', function (ConnectionInterface $conn) use ($that) { |
|
| 75 | + $server->on('connection', function(ConnectionInterface $conn) use ($that) { |
|
| 76 | 76 | $that->emit('connection', array($conn)); |
| 77 | 77 | }); |
| 78 | - $server->on('error', function (\Exception $error) use ($that) { |
|
| 78 | + $server->on('error', function(\Exception $error) use ($that) { |
|
| 79 | 79 | $that->emit('error', array($error)); |
| 80 | 80 | }); |
| 81 | 81 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | { |
| 113 | 113 | $errno = 0; |
| 114 | 114 | $errstr = ''; |
| 115 | - \set_error_handler(function ($_, $error) use (&$errno, &$errstr) { |
|
| 115 | + \set_error_handler(function($_, $error) use (&$errno, &$errstr) { |
|
| 116 | 116 | // Match errstr from PHP's warning message. |
| 117 | 117 | // stream_socket_accept(): accept failed: Connection timed out |
| 118 | 118 | $errstr = \preg_replace('#.*: #', '', $error); |
@@ -164,7 +164,7 @@ |
||
| 164 | 164 | |
| 165 | 165 | $this->connections[] = $connection; |
| 166 | 166 | $that = $this; |
| 167 | - $connection->on('close', function () use ($that, $connection) { |
|
| 167 | + $connection->on('close', function() use ($that, $connection) { |
|
| 168 | 168 | $that->handleDisconnection($connection); |
| 169 | 169 | }); |
| 170 | 170 | |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | // parse string into array structure |
| 40 | 40 | // ignore warnings due to excessive data structures (max_input_vars and max_input_nesting_level) |
| 41 | 41 | $ret = array(); |
| 42 | - @\parse_str((string)$request->getBody(), $ret); |
|
| 42 | + @\parse_str((string) $request->getBody(), $ret); |
|
| 43 | 43 | |
| 44 | 44 | return $request->withParsedBody($ret); |
| 45 | 45 | } |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | /** @var ?\Closure $closer */ |
| 54 | 54 | $closer = null; |
| 55 | 55 | |
| 56 | - return new Promise(function ($resolve, $reject) use ($body, &$closer, $sizeLimit, $request, $next) { |
|
| 56 | + return new Promise(function($resolve, $reject) use ($body, &$closer, $sizeLimit, $request, $next) { |
|
| 57 | 57 | // buffer request body data in memory, discard but keep buffering if limit is reached |
| 58 | 58 | $buffer = ''; |
| 59 | 59 | $bufferer = null; |
| 60 | - $body->on('data', $bufferer = function ($data) use (&$buffer, $sizeLimit, $body, &$bufferer) { |
|
| 60 | + $body->on('data', $bufferer = function($data) use (&$buffer, $sizeLimit, $body, &$bufferer) { |
|
| 61 | 61 | $buffer .= $data; |
| 62 | 62 | |
| 63 | 63 | // On buffer overflow keep the request body stream in, |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | }); |
| 73 | 73 | |
| 74 | 74 | // call $next with current buffer and resolve or reject with its results |
| 75 | - $body->on('close', $closer = function () use (&$buffer, $request, $resolve, $reject, $next) { |
|
| 75 | + $body->on('close', $closer = function() use (&$buffer, $request, $resolve, $reject, $next) { |
|
| 76 | 76 | try { |
| 77 | 77 | // resolve with result of next handler |
| 78 | 78 | $resolve($next($request->withBody(new BufferedBody($buffer)))); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | }); |
| 86 | 86 | |
| 87 | 87 | // reject buffering if body emits error |
| 88 | - $body->on('error', function (\Exception $e) use ($reject, $body, $closer) { |
|
| 88 | + $body->on('error', function(\Exception $e) use ($reject, $body, $closer) { |
|
| 89 | 89 | // remove close handler to avoid resolving, then close and reject |
| 90 | 90 | assert($closer instanceof \Closure); |
| 91 | 91 | $body->removeListener('close', $closer); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $e |
| 98 | 98 | )); |
| 99 | 99 | }); |
| 100 | - }, function () use ($body, &$closer) { |
|
| 100 | + }, function() use ($body, &$closer) { |
|
| 101 | 101 | // cancelled buffering: remove close handler to avoid resolving, then close and reject |
| 102 | 102 | assert($closer instanceof \Closure); |
| 103 | 103 | $body->removeListener('close', $closer); |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // get next queue position |
| 133 | - $queue =& $this->queue; |
|
| 133 | + $queue = & $this->queue; |
|
| 134 | 134 | $queue[] = null; |
| 135 | 135 | \end($queue); |
| 136 | 136 | $id = \key($queue); |
| 137 | 137 | |
| 138 | - $deferred = new Deferred(function ($_, $reject) use (&$queue, $id) { |
|
| 138 | + $deferred = new Deferred(function($_, $reject) use (&$queue, $id) { |
|
| 139 | 139 | // queued promise cancelled before its next handler is invoked |
| 140 | 140 | // remove from queue and reject explicitly |
| 141 | 141 | unset($queue[$id]); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | $pending = &$this->pending; |
| 149 | 149 | $that = $this; |
| 150 | - return $deferred->promise()->then(function () use ($request, $next, $body, &$pending, $that) { |
|
| 150 | + return $deferred->promise()->then(function() use ($request, $next, $body, &$pending, $that) { |
|
| 151 | 151 | // invoke next request handler |
| 152 | 152 | ++$pending; |
| 153 | 153 | |
@@ -182,11 +182,11 @@ discard block |
||
| 182 | 182 | { |
| 183 | 183 | $that = $this; |
| 184 | 184 | |
| 185 | - return $promise->then(function ($response) use ($that) { |
|
| 185 | + return $promise->then(function($response) use ($that) { |
|
| 186 | 186 | $that->processQueue(); |
| 187 | 187 | |
| 188 | 188 | return $response; |
| 189 | - }, function ($error) use ($that) { |
|
| 189 | + }, function($error) use ($that) { |
|
| 190 | 190 | $that->processQueue(); |
| 191 | 191 | |
| 192 | 192 | return Promise\reject($error); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | { |
| 284 | 284 | return \preg_replace_callback( |
| 285 | 285 | '/(?:[^a-z0-9_\-\.~!\$&\'\(\)\*\+,;=' . ($component === \PHP_URL_PATH ? ':@\/' : ($component === \PHP_URL_QUERY || $component === \PHP_URL_FRAGMENT ? ':@\/\?' : '')) . '%]++|%(?![a-f0-9]{2}))/i', |
| 286 | - function (array $match) { |
|
| 286 | + function(array $match) { |
|
| 287 | 287 | return \rawurlencode($match[0]); |
| 288 | 288 | }, |
| 289 | 289 | $part |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | if ($rel->getAuthority() !== '') { |
| 311 | 311 | $reset = true; |
| 312 | 312 | $userInfo = \explode(':', $rel->getUserInfo(), 2); |
| 313 | - $new = $base->withUserInfo($userInfo[0], isset($userInfo[1]) ? $userInfo[1]: null)->withHost($rel->getHost())->withPort($rel->getPort()); |
|
| 313 | + $new = $base->withUserInfo($userInfo[0], isset($userInfo[1]) ? $userInfo[1] : null)->withHost($rel->getHost())->withPort($rel->getPort()); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | if ($reset && $rel->getPath() === '') { |
@@ -320,7 +320,7 @@ |
||
| 320 | 320 | } elseif ($request->hasHeader('Content-Length')) { |
| 321 | 321 | $string = $request->getHeaderLine('Content-Length'); |
| 322 | 322 | |
| 323 | - if ((string)(int)$string !== $string) { |
|
| 323 | + if ((string) (int) $string !== $string) { |
|
| 324 | 324 | // Content-Length value is not an integer or not a single integer |
| 325 | 325 | throw new \InvalidArgumentException('The value of `Content-Length` is not valid', Response::STATUS_BAD_REQUEST); |
| 326 | 326 | } |
@@ -102,12 +102,12 @@ discard block |
||
| 102 | 102 | if ($positionCrlf === false) { |
| 103 | 103 | // Header shouldn't be bigger than 1024 bytes |
| 104 | 104 | if (isset($this->buffer[static::MAX_CHUNK_HEADER_SIZE])) { |
| 105 | - $this->handleError(new Exception('Chunk header size inclusive extension bigger than' . static::MAX_CHUNK_HEADER_SIZE. ' bytes')); |
|
| 105 | + $this->handleError(new Exception('Chunk header size inclusive extension bigger than' . static::MAX_CHUNK_HEADER_SIZE . ' bytes')); |
|
| 106 | 106 | } |
| 107 | 107 | return; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $header = \strtolower((string)\substr($this->buffer, 0, $positionCrlf)); |
|
| 110 | + $header = \strtolower((string) \substr($this->buffer, 0, $positionCrlf)); |
|
| 111 | 111 | $hexValue = $header; |
| 112 | 112 | |
| 113 | 113 | if (\strpos($header, ';') !== false) { |
@@ -128,19 +128,19 @@ discard block |
||
| 128 | 128 | return; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $this->buffer = (string)\substr($this->buffer, $positionCrlf + 2); |
|
| 131 | + $this->buffer = (string) \substr($this->buffer, $positionCrlf + 2); |
|
| 132 | 132 | $this->headerCompleted = true; |
| 133 | 133 | if ($this->buffer === '') { |
| 134 | 134 | return; |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - $chunk = (string)\substr($this->buffer, 0, $this->chunkSize - $this->transferredSize); |
|
| 138 | + $chunk = (string) \substr($this->buffer, 0, $this->chunkSize - $this->transferredSize); |
|
| 139 | 139 | |
| 140 | 140 | if ($chunk !== '') { |
| 141 | 141 | $this->transferredSize += \strlen($chunk); |
| 142 | 142 | $this->emit('data', array($chunk)); |
| 143 | - $this->buffer = (string)\substr($this->buffer, \strlen($chunk)); |
|
| 143 | + $this->buffer = (string) \substr($this->buffer, \strlen($chunk)); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | $positionCrlf = \strpos($this->buffer, static::CRLF); |
@@ -154,10 +154,10 @@ discard block |
||
| 154 | 154 | $this->chunkSize = 0; |
| 155 | 155 | $this->headerCompleted = false; |
| 156 | 156 | $this->transferredSize = 0; |
| 157 | - $this->buffer = (string)\substr($this->buffer, 2); |
|
| 157 | + $this->buffer = (string) \substr($this->buffer, 2); |
|
| 158 | 158 | } elseif ($this->chunkSize === 0) { |
| 159 | 159 | // end chunk received, skip all trailer data |
| 160 | - $this->buffer = (string)\substr($this->buffer, $positionCrlf); |
|
| 160 | + $this->buffer = (string) \substr($this->buffer, $positionCrlf); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | if ($positionCrlf !== 0 && $this->chunkSize !== 0 && $this->chunkSize === $this->transferredSize && \strlen($this->buffer) > 2) { |