@@ -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 | } |
@@ -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, |
@@ -43,7 +43,7 @@ |
||
43 | 43 | public function __construct($stream, LoopInterface $loop = null, $readChunkSize = null) |
44 | 44 | { |
45 | 45 | if (!\is_resource($stream) || \get_resource_type($stream) !== "stream") { |
46 | - throw new InvalidArgumentException('First parameter must be a valid stream resource'); |
|
46 | + throw new InvalidArgumentException('First parameter must be a valid stream resource'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | // ensure resource is opened for reading (fopen mode must contain "r" or "+") |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | |
59 | 59 | $this->stream = $stream; |
60 | 60 | $this->loop = $loop ?: Loop::get(); |
61 | - $this->softLimit = ($writeBufferSoftLimit === null) ? 65536 : (int)$writeBufferSoftLimit; |
|
62 | - $this->writeChunkSize = ($writeChunkSize === null) ? -1 : (int)$writeChunkSize; |
|
61 | + $this->softLimit = ($writeBufferSoftLimit === null) ? 65536 : (int) $writeBufferSoftLimit; |
|
62 | + $this->writeChunkSize = ($writeChunkSize === null) ? -1 : (int) $writeChunkSize; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public function isWritable() |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | public function handleWrite() |
127 | 127 | { |
128 | 128 | $error = null; |
129 | - \set_error_handler(function ($_, $errstr) use (&$error) { |
|
129 | + \set_error_handler(function($_, $errstr) use (&$error) { |
|
130 | 130 | $error = $errstr; |
131 | 131 | }); |
132 | 132 |
@@ -87,18 +87,18 @@ discard block |
||
87 | 87 | |
88 | 88 | $this->stream = $stream; |
89 | 89 | $this->loop = $loop ?: Loop::get(); |
90 | - $this->bufferSize = ($readChunkSize === null) ? 65536 : (int)$readChunkSize; |
|
90 | + $this->bufferSize = ($readChunkSize === null) ? 65536 : (int) $readChunkSize; |
|
91 | 91 | $this->buffer = $buffer; |
92 | 92 | |
93 | 93 | $that = $this; |
94 | 94 | |
95 | - $this->buffer->on('error', function ($error) use ($that) { |
|
95 | + $this->buffer->on('error', function($error) use ($that) { |
|
96 | 96 | $that->emit('error', array($error)); |
97 | 97 | }); |
98 | 98 | |
99 | 99 | $this->buffer->on('close', array($this, 'close')); |
100 | 100 | |
101 | - $this->buffer->on('drain', function () use ($that) { |
|
101 | + $this->buffer->on('drain', function() use ($that) { |
|
102 | 102 | $that->emit('drain'); |
103 | 103 | }); |
104 | 104 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | public function handleData($stream) |
186 | 186 | { |
187 | 187 | $error = null; |
188 | - \set_error_handler(function ($errno, $errstr, $errfile, $errline) use (&$error) { |
|
188 | + \set_error_handler(function($errno, $errstr, $errfile, $errline) use (&$error) { |
|
189 | 189 | $error = new \ErrorException( |
190 | 190 | $errstr, |
191 | 191 | 0, |
@@ -41,7 +41,7 @@ |
||
41 | 41 | public function __construct($stream, LoopInterface $loop = null, $readChunkSize = null, WritableStreamInterface $buffer = null) |
42 | 42 | { |
43 | 43 | if (!\is_resource($stream) || \get_resource_type($stream) !== "stream") { |
44 | - throw new InvalidArgumentException('First parameter must be a valid stream resource'); |
|
44 | + throw new InvalidArgumentException('First parameter must be a valid stream resource'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | // ensure resource is opened for reading and wrting (fopen mode must contain "+") |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | public function resolve($domain) |
23 | 23 | { |
24 | - return $this->resolveAll($domain, Message::TYPE_A)->then(function (array $ips) { |
|
24 | + return $this->resolveAll($domain, Message::TYPE_A)->then(function(array $ips) { |
|
25 | 25 | return $ips[array_rand($ips)]; |
26 | 26 | }); |
27 | 27 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | return $this->executor->query( |
35 | 35 | $query |
36 | - )->then(function (Message $response) use ($query, $that) { |
|
36 | + )->then(function(Message $response) use ($query, $that) { |
|
37 | 37 | return $that->extractValues($query, $response); |
38 | 38 | }); |
39 | 39 | } |
@@ -133,14 +133,14 @@ discard block |
||
133 | 133 | private function filterByField(array $answers, $field, $value) |
134 | 134 | { |
135 | 135 | $value = strtolower($value); |
136 | - return array_filter($answers, function ($answer) use ($field, $value) { |
|
136 | + return array_filter($answers, function($answer) use ($field, $value) { |
|
137 | 137 | return $value === strtolower($answer->$field); |
138 | 138 | }); |
139 | 139 | } |
140 | 140 | |
141 | 141 | private function mapRecordData(array $records) |
142 | 142 | { |
143 | - return array_map(function ($record) { |
|
143 | + return array_map(function($record) { |
|
144 | 144 | return $record->data; |
145 | 145 | }, $records); |
146 | 146 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $rdata = array(); |
175 | 175 | while ($consumed < $expected) { |
176 | 176 | $len = ord($data[$consumed]); |
177 | - $rdata[] = (string)substr($data, $consumed + 1, $len); |
|
177 | + $rdata[] = (string) substr($data, $consumed + 1, $len); |
|
178 | 178 | $consumed += $len + 1; |
179 | 179 | } |
180 | 180 | } elseif (Message::TYPE_MX === $type) { |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | \implode( |
292 | 292 | '.', |
293 | 293 | \array_map( |
294 | - function ($label) { |
|
294 | + function($label) { |
|
295 | 295 | return \addcslashes($label, "\0..\40.\177"); |
296 | 296 | }, |
297 | 297 | $labels |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | $stream = $this->streamExecutor; |
67 | 67 | $pending = $this->datagramExecutor->query($query); |
68 | 68 | |
69 | - return new Promise(function ($resolve, $reject) use (&$pending, $stream, $query) { |
|
69 | + return new Promise(function($resolve, $reject) use (&$pending, $stream, $query) { |
|
70 | 70 | $pending->then( |
71 | 71 | $resolve, |
72 | - function ($e) use (&$pending, $stream, $query, $resolve, $reject) { |
|
72 | + function($e) use (&$pending, $stream, $query, $resolve, $reject) { |
|
73 | 73 | if ($e->getCode() === (\defined('SOCKET_EMSGSIZE') ? \SOCKET_EMSGSIZE : 90)) { |
74 | 74 | $pending = $stream->query($query)->then($resolve, $reject); |
75 | 75 | } else { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | ); |
80 | - }, function () use (&$pending) { |
|
80 | + }, function() use (&$pending) { |
|
81 | 81 | $pending->cancel(); |
82 | 82 | $pending = null; |
83 | 83 | }); |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | $fallback = $this->fallback; |
22 | 22 | $promise = $this->executor->query($query); |
23 | 23 | |
24 | - return new Promise(function ($resolve, $reject) use (&$promise, $fallback, $query, &$cancelled) { |
|
25 | - $promise->then($resolve, function (\Exception $e1) use ($fallback, $query, $resolve, $reject, &$cancelled, &$promise) { |
|
24 | + return new Promise(function($resolve, $reject) use (&$promise, $fallback, $query, &$cancelled) { |
|
25 | + $promise->then($resolve, function(\Exception $e1) use ($fallback, $query, $resolve, $reject, &$cancelled, &$promise) { |
|
26 | 26 | // reject if primary resolution rejected due to cancellation |
27 | 27 | if ($cancelled) { |
28 | 28 | $reject($e1); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | } |
31 | 31 | |
32 | 32 | // start fallback query if primary query rejected |
33 | - $promise = $fallback->query($query)->then($resolve, function (\Exception $e2) use ($e1, $reject) { |
|
33 | + $promise = $fallback->query($query)->then($resolve, function(\Exception $e2) use ($e1, $reject) { |
|
34 | 34 | $append = $e2->getMessage(); |
35 | 35 | if (($pos = strpos($append, ':')) !== false) { |
36 | 36 | $append = substr($append, $pos + 2); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $reject(new \RuntimeException($e1->getMessage() . '. ' . $append)); |
41 | 41 | }); |
42 | 42 | }); |
43 | - }, function () use (&$promise, &$cancelled) { |
|
43 | + }, function() use (&$promise, &$cancelled) { |
|
44 | 44 | // cancel pending query (primary or fallback) |
45 | 45 | $cancelled = true; |
46 | 46 | $promise->cancel(); |