@@ -74,7 +74,7 @@ |
||
| 74 | 74 | { |
| 75 | 75 | if (($this->transferredLength + \strlen($data)) > $this->maxLength) { |
| 76 | 76 | // Only emit data until the value of 'Content-Length' is reached, the rest will be ignored |
| 77 | - $data = (string)\substr($data, 0, $this->maxLength - $this->transferredLength); |
|
| 77 | + $data = (string) \substr($data, 0, $this->maxLength - $this->transferredLength); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | if ($data !== '') { |
@@ -251,14 +251,14 @@ |
||
| 251 | 251 | * Filter out any configuration middleware, no need to run requests through something that isn't |
| 252 | 252 | * doing anything with the request. |
| 253 | 253 | */ |
| 254 | - $middleware = \array_filter($middleware, function ($handler) { |
|
| 254 | + $middleware = \array_filter($middleware, function($handler) { |
|
| 255 | 255 | return !($handler instanceof StreamingRequestMiddleware); |
| 256 | 256 | }); |
| 257 | 257 | |
| 258 | 258 | $this->streamingServer = new StreamingServer($loop, new MiddlewareRunner($middleware)); |
| 259 | 259 | |
| 260 | 260 | $that = $this; |
| 261 | - $this->streamingServer->on('error', function ($error) use ($that) { |
|
| 261 | + $this->streamingServer->on('error', function($error) use ($that) { |
|
| 262 | 262 | $that->emit('error', array($error)); |
| 263 | 263 | }); |
| 264 | 264 | } |
@@ -235,7 +235,7 @@ |
||
| 235 | 235 | */ |
| 236 | 236 | public function patch($url, array $headers = array(), $body = '') |
| 237 | 237 | { |
| 238 | - return $this->requestMayBeStreaming('PATCH', $url , $headers, $body); |
|
| 238 | + return $this->requestMayBeStreaming('PATCH', $url, $headers, $body); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | private function createTimerCallback() |
| 241 | 241 | { |
| 242 | 242 | $timers = $this->timerEvents; |
| 243 | - $this->timerCallback = function ($_, $__, $timer) use ($timers) { |
|
| 243 | + $this->timerCallback = function($_, $__, $timer) use ($timers) { |
|
| 244 | 244 | \call_user_func($timer->getCallback(), $timer); |
| 245 | 245 | |
| 246 | 246 | if (!$timer->isPeriodic() && $timers->contains($timer)) { |
@@ -258,9 +258,9 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | private function createStreamCallback() |
| 260 | 260 | { |
| 261 | - $read =& $this->readListeners; |
|
| 262 | - $write =& $this->writeListeners; |
|
| 263 | - $this->streamCallback = function ($stream, $flags) use (&$read, &$write) { |
|
| 261 | + $read = & $this->readListeners; |
|
| 262 | + $write = & $this->writeListeners; |
|
| 263 | + $this->streamCallback = function($stream, $flags) use (&$read, &$write) { |
|
| 264 | 264 | $key = (int) $stream; |
| 265 | 265 | |
| 266 | 266 | if (Event::READ === (Event::READ & $flags) && isset($read[$key])) { |
@@ -39,12 +39,12 @@ |
||
| 39 | 39 | // This is tested using child processes, so coverage is actually 100%, see BinTest. |
| 40 | 40 | // @codeCoverageIgnoreStart |
| 41 | 41 | $hasRun = false; |
| 42 | - $loop->futureTick(function () use (&$hasRun) { |
|
| 42 | + $loop->futureTick(function() use (&$hasRun) { |
|
| 43 | 43 | $hasRun = true; |
| 44 | 44 | }); |
| 45 | 45 | |
| 46 | - $stopped =& self::$stopped; |
|
| 47 | - register_shutdown_function(function () use ($loop, &$hasRun, &$stopped) { |
|
| 46 | + $stopped = & self::$stopped; |
|
| 47 | + register_shutdown_function(function() use ($loop, &$hasRun, &$stopped) { |
|
| 48 | 48 | // Don't run if we're coming from a fatal error (uncaught exception). |
| 49 | 49 | $error = error_get_last(); |
| 50 | 50 | if ((isset($error['type']) ? $error['type'] : 0) & (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR)) { |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $that = $this; |
| 118 | 118 | $timers = $this->timers; |
| 119 | - $callback = function () use ($timer, $timers, $that) { |
|
| 119 | + $callback = function() use ($timer, $timers, $that) { |
|
| 120 | 120 | \call_user_func($timer->getCallback(), $timer); |
| 121 | 121 | |
| 122 | 122 | if ($timers->contains($timer)) { |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | { |
| 144 | 144 | $timer = new Timer($interval, $callback, true); |
| 145 | 145 | |
| 146 | - $callback = function () use ($timer) { |
|
| 146 | + $callback = function() use ($timer) { |
|
| 147 | 147 | \call_user_func($timer->getCallback(), $timer); |
| 148 | 148 | }; |
| 149 | 149 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | if (!isset($this->signalEvents[$signal])) { |
| 187 | 187 | $signals = $this->signals; |
| 188 | 188 | $this->signalEvents[$signal] = \uv_signal_init($this->uv); |
| 189 | - \uv_signal_start($this->signalEvents[$signal], function () use ($signals, $signal) { |
|
| 189 | + \uv_signal_start($this->signalEvents[$signal], function() use ($signals, $signal) { |
|
| 190 | 190 | $signals->call($signal); |
| 191 | 191 | }, $signal); |
| 192 | 192 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | private function addStream($stream) |
| 245 | 245 | { |
| 246 | 246 | if (!isset($this->streamEvents[(int) $stream])) { |
| 247 | - $this->streamEvents[(int)$stream] = \uv_poll_init_socket($this->uv, $stream); |
|
| 247 | + $this->streamEvents[(int) $stream] = \uv_poll_init_socket($this->uv, $stream); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | if ($this->streamEvents[(int) $stream] !== false) { |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | */ |
| 295 | 295 | private function createStreamListener() |
| 296 | 296 | { |
| 297 | - $callback = function ($event, $status, $events, $stream) { |
|
| 297 | + $callback = function($event, $status, $events, $stream) { |
|
| 298 | 298 | // libuv automatically stops polling on error, re-enable polling to match other loop implementations |
| 299 | 299 | if ($status !== 0) { |
| 300 | 300 | $this->pollStream($stream); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | public function addReadStream($stream, $listener) |
| 75 | 75 | { |
| 76 | - $key = (int)$stream; |
|
| 76 | + $key = (int) $stream; |
|
| 77 | 77 | |
| 78 | 78 | if (isset($this->readStreams[$key])) { |
| 79 | 79 | return; |
@@ -92,14 +92,14 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | private function getStreamListenerClosure($stream, $listener) |
| 94 | 94 | { |
| 95 | - return function () use ($stream, $listener) { |
|
| 95 | + return function() use ($stream, $listener) { |
|
| 96 | 96 | \call_user_func($listener, $stream); |
| 97 | 97 | }; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | public function addWriteStream($stream, $listener) |
| 101 | 101 | { |
| 102 | - $key = (int)$stream; |
|
| 102 | + $key = (int) $stream; |
|
| 103 | 103 | |
| 104 | 104 | if (isset($this->writeStreams[$key])) { |
| 105 | 105 | return; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | public function removeReadStream($stream) |
| 114 | 114 | { |
| 115 | - $key = (int)$stream; |
|
| 115 | + $key = (int) $stream; |
|
| 116 | 116 | |
| 117 | 117 | if (!isset($this->readStreams[$key])) { |
| 118 | 118 | return; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | public function removeWriteStream($stream) |
| 126 | 126 | { |
| 127 | - $key = (int)$stream; |
|
| 127 | + $key = (int) $stream; |
|
| 128 | 128 | |
| 129 | 129 | if (!isset($this->writeStreams[$key])) { |
| 130 | 130 | return; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | $that = $this; |
| 142 | 142 | $timers = $this->timers; |
| 143 | - $callback = function () use ($timer, $timers, $that) { |
|
| 143 | + $callback = function() use ($timer, $timers, $that) { |
|
| 144 | 144 | \call_user_func($timer->getCallback(), $timer); |
| 145 | 145 | |
| 146 | 146 | if ($timers->contains($timer)) { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | { |
| 159 | 159 | $timer = new Timer($interval, $callback, true); |
| 160 | 160 | |
| 161 | - $callback = function () use ($timer) { |
|
| 161 | + $callback = function() use ($timer) { |
|
| 162 | 162 | \call_user_func($timer->getCallback(), $timer); |
| 163 | 163 | }; |
| 164 | 164 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | // Ensure we do not exceed maximum integer size, which may |
| 199 | 199 | // cause the loop to tick once every ~35min on 32bit systems. |
| 200 | 200 | $timeout *= self::MICROSECONDS_PER_SECOND; |
| 201 | - $timeout = $timeout > \PHP_INT_MAX ? \PHP_INT_MAX : (int)$timeout; |
|
| 201 | + $timeout = $timeout > \PHP_INT_MAX ? \PHP_INT_MAX : (int) $timeout; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // The only possible event is stream or signal activity, so wait forever ... |
@@ -288,11 +288,11 @@ discard block |
||
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** @var ?callable $previous */ |
| 291 | - $previous = \set_error_handler(function ($errno, $errstr) use (&$previous) { |
|
| 291 | + $previous = \set_error_handler(function($errno, $errstr) use (&$previous) { |
|
| 292 | 292 | // suppress warnings that occur when `stream_select()` is interrupted by a signal |
| 293 | 293 | // PHP defines `EINTR` through `ext-sockets` or `ext-pcntl`, otherwise use common default (Linux & Mac) |
| 294 | 294 | $eintr = \defined('SOCKET_EINTR') ? \SOCKET_EINTR : (\defined('PCNTL_EINTR') ? \PCNTL_EINTR : 4); |
| 295 | - if ($errno === \E_WARNING && \strpos($errstr, '[' . $eintr .']: ') !== false) { |
|
| 295 | + if ($errno === \E_WARNING && \strpos($errstr, '[' . $eintr . ']: ') !== false) { |
|
| 296 | 296 | return; |
| 297 | 297 | } |
| 298 | 298 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | { |
| 238 | 238 | $that = $this; |
| 239 | 239 | $timers = $this->timerEvents; |
| 240 | - $this->timerCallback = function ($_, $__, $timer) use ($timers, $that) { |
|
| 240 | + $this->timerCallback = function($_, $__, $timer) use ($timers, $that) { |
|
| 241 | 241 | \call_user_func($timer->getCallback(), $timer); |
| 242 | 242 | |
| 243 | 243 | // Timer already cancelled ... |
@@ -268,9 +268,9 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | private function createStreamCallback() |
| 270 | 270 | { |
| 271 | - $read =& $this->readListeners; |
|
| 272 | - $write =& $this->writeListeners; |
|
| 273 | - $this->streamCallback = function ($stream, $flags) use (&$read, &$write) { |
|
| 271 | + $read = & $this->readListeners; |
|
| 272 | + $write = & $this->writeListeners; |
|
| 273 | + $this->streamCallback = function($stream, $flags) use (&$read, &$write) { |
|
| 274 | 274 | $key = (int) $stream; |
| 275 | 275 | |
| 276 | 276 | if (\EV_READ === (\EV_READ & $flags) && isset($read[$key])) { |