@@ -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) { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | $promise = $this->connectionManager->connect($this->request->getUri()); |
84 | 84 | $promise->then( |
85 | - function (ConnectionInterface $connection) use ($headers, &$connectionRef, &$stateRef, &$pendingWrites, $that) { |
|
85 | + function(ConnectionInterface $connection) use ($headers, &$connectionRef, &$stateRef, &$pendingWrites, $that) { |
|
86 | 86 | $connectionRef = $connection; |
87 | 87 | assert($connectionRef instanceof ConnectionInterface); |
88 | 88 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $connectionManager = $this->connectionManager; |
195 | 195 | $successfulEndReceived = false; |
196 | 196 | $input = $body = new CloseProtectionStream($connection); |
197 | - $input->on('close', function () use ($connection, $that, $connectionManager, $request, $response, &$successfulEndReceived) { |
|
197 | + $input->on('close', function() use ($connection, $that, $connectionManager, $request, $response, &$successfulEndReceived) { |
|
198 | 198 | // only reuse connection after successful response and both request and response allow keep alive |
199 | 199 | if ($successfulEndReceived && $connection->isReadable() && $that->hasMessageKeepAliveEnabled($response) && $that->hasMessageKeepAliveEnabled($request)) { |
200 | 200 | $connectionManager->keepAlive($request->getUri(), $connection); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $length = (int) $response->getHeaderLine('Content-Length'); |
217 | 217 | } |
218 | 218 | $response = $response->withBody($body = new ReadableBodyStream($body, $length)); |
219 | - $body->on('end', function () use (&$successfulEndReceived) { |
|
219 | + $body->on('end', function() use (&$successfulEndReceived) { |
|
220 | 220 | $successfulEndReceived = true; |
221 | 221 | }); |
222 | 222 |
@@ -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 | }; |