@@ -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])) { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | - $callback = function () use ($stream, $listener) { |
|
58 | + $callback = function() use ($stream, $listener) { |
|
59 | 59 | \call_user_func($listener, $stream); |
60 | 60 | }; |
61 | 61 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | return; |
72 | 72 | } |
73 | 73 | |
74 | - $callback = function () use ($stream, $listener) { |
|
74 | + $callback = function() use ($stream, $listener) { |
|
75 | 75 | \call_user_func($listener, $stream); |
76 | 76 | }; |
77 | 77 | |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | |
106 | 106 | public function addTimer($interval, $callback) |
107 | 107 | { |
108 | - $timer = new Timer( $interval, $callback, false); |
|
108 | + $timer = new Timer($interval, $callback, false); |
|
109 | 109 | |
110 | 110 | $that = $this; |
111 | 111 | $timers = $this->timerEvents; |
112 | - $callback = function () use ($timer, $timers, $that) { |
|
112 | + $callback = function() use ($timer, $timers, $that) { |
|
113 | 113 | \call_user_func($timer->getCallback(), $timer); |
114 | 114 | |
115 | 115 | if ($timers->contains($timer)) { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | { |
129 | 129 | $timer = new Timer($interval, $callback, true); |
130 | 130 | |
131 | - $callback = function () use ($timer) { |
|
131 | + $callback = function() use ($timer) { |
|
132 | 132 | \call_user_func($timer->getCallback(), $timer); |
133 | 133 | }; |
134 | 134 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | if (!isset($this->signalEvents[$signal])) { |
160 | 160 | $signals = $this->signals; |
161 | - $this->signalEvents[$signal] = new SignalEvent(function () use ($signals, $signal) { |
|
161 | + $this->signalEvents[$signal] = new SignalEvent(function() use ($signals, $signal) { |
|
162 | 162 | $signals->call($signal); |
163 | 163 | }, $signal); |
164 | 164 | $this->loop->add($this->signalEvents[$signal]); |
@@ -30,33 +30,33 @@ discard block |
||
30 | 30 | $dest->emit('pipe', array($source)); |
31 | 31 | |
32 | 32 | // forward all source data events as $dest->write() |
33 | - $source->on('data', $dataer = function ($data) use ($source, $dest) { |
|
33 | + $source->on('data', $dataer = function($data) use ($source, $dest) { |
|
34 | 34 | $feedMore = $dest->write($data); |
35 | 35 | |
36 | 36 | if (false === $feedMore) { |
37 | 37 | $source->pause(); |
38 | 38 | } |
39 | 39 | }); |
40 | - $dest->on('close', function () use ($source, $dataer) { |
|
40 | + $dest->on('close', function() use ($source, $dataer) { |
|
41 | 41 | $source->removeListener('data', $dataer); |
42 | 42 | $source->pause(); |
43 | 43 | }); |
44 | 44 | |
45 | 45 | // forward destination drain as $source->resume() |
46 | - $dest->on('drain', $drainer = function () use ($source) { |
|
46 | + $dest->on('drain', $drainer = function() use ($source) { |
|
47 | 47 | $source->resume(); |
48 | 48 | }); |
49 | - $source->on('close', function () use ($dest, $drainer) { |
|
49 | + $source->on('close', function() use ($dest, $drainer) { |
|
50 | 50 | $dest->removeListener('drain', $drainer); |
51 | 51 | }); |
52 | 52 | |
53 | 53 | // forward end event from source as $dest->end() |
54 | 54 | $end = isset($options['end']) ? $options['end'] : true; |
55 | 55 | if ($end) { |
56 | - $source->on('end', $ender = function () use ($dest) { |
|
56 | + $source->on('end', $ender = function() use ($dest) { |
|
57 | 57 | $dest->end(); |
58 | 58 | }); |
59 | - $dest->on('close', function () use ($source, $ender) { |
|
59 | + $dest->on('close', function() use ($source, $ender) { |
|
60 | 60 | $source->removeListener('end', $ender); |
61 | 61 | }); |
62 | 62 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public static function forwardEvents($source, $target, array $events) |
68 | 68 | { |
69 | 69 | foreach ($events as $event) { |
70 | - $source->on($event, function () use ($event, $target) { |
|
70 | + $source->on($event, function() use ($event, $target) { |
|
71 | 71 | $target->emit($event, \func_get_args()); |
72 | 72 | }); |
73 | 73 | } |
@@ -48,7 +48,7 @@ |
||
48 | 48 | public function __construct($stream, $loop = null, $readChunkSize = null) |
49 | 49 | { |
50 | 50 | if (!\is_resource($stream) || \get_resource_type($stream) !== "stream") { |
51 | - throw new InvalidArgumentException('First parameter must be a valid stream resource'); |
|
51 | + throw new InvalidArgumentException('First parameter must be a valid stream resource'); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | // ensure resource is opened for reading (fopen mode must contain "r" or "+") |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | $this->stream = $stream; |
83 | 83 | $this->loop = $loop ?: Loop::get(); |
84 | - $this->bufferSize = ($readChunkSize === null) ? 65536 : (int)$readChunkSize; |
|
84 | + $this->bufferSize = ($readChunkSize === null) ? 65536 : (int) $readChunkSize; |
|
85 | 85 | |
86 | 86 | $this->resume(); |
87 | 87 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | public function handleData() |
134 | 134 | { |
135 | 135 | $error = null; |
136 | - \set_error_handler(function ($errno, $errstr, $errfile, $errline) use (&$error) { |
|
136 | + \set_error_handler(function($errno, $errstr, $errfile, $errline) use (&$error) { |
|
137 | 137 | $error = new \ErrorException( |
138 | 138 | $errstr, |
139 | 139 | 0, |