@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | |
132 | 132 | $this->applyOptions($options); |
133 | 133 | |
134 | - $this->on('element', function (Features $element) { |
|
134 | + $this->on('element', function(Features $element) { |
|
135 | 135 | $this->_features = $element; |
136 | 136 | $this->emit('features', [$element]); |
137 | 137 | }, Features::class); |
138 | 138 | |
139 | - $this->on('close', function (Features $element) { |
|
139 | + $this->on('close', function(Features $element) { |
|
140 | 140 | $this->state = 'disconnected'; |
141 | 141 | }, Features::class); |
142 | 142 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $this->state = 'bound'; |
197 | 197 | |
198 | 198 | $queue = new ObservableCollection(); |
199 | - $queue->on('empty', function () { |
|
199 | + $queue->on('empty', function() { |
|
200 | 200 | $this->state = 'ready'; |
201 | 201 | }); |
202 | 202 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | //region Parser |
245 | 245 | public function setParser(XmlParser $parser) |
246 | 246 | { |
247 | - if($this->state !== "disconnected") { |
|
247 | + if ($this->state !== "disconnected") { |
|
248 | 248 | throw new \BadMethodCallException('Parser can be changed only when client is disconnected.'); |
249 | 249 | } |
250 | 250 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | )); |
273 | 273 | } |
274 | 274 | |
275 | - $this->_connector->on('connect', function ($stream) { |
|
275 | + $this->_connector->on('connect', function($stream) { |
|
276 | 276 | return $this->handleConnect($stream); |
277 | 277 | }); |
278 | 278 | } |
@@ -91,28 +91,28 @@ discard block |
||
91 | 91 | parent::__construct($transport); |
92 | 92 | $this->setParser($parser); |
93 | 93 | |
94 | - $this->on('close', function () { $this->_isOpened = false; }); |
|
94 | + $this->on('close', function() { $this->_isOpened = false; }); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | public function setParser(XmlParser $parser) |
98 | 98 | { |
99 | 99 | $this->_parser = $parser; |
100 | 100 | |
101 | - $this->on('element', function (Error $element) { |
|
101 | + $this->on('element', function(Error $element) { |
|
102 | 102 | $this->handleError($element); |
103 | 103 | }, with\instance(Error::class)); |
104 | 104 | |
105 | - $this->_parser->on('parse.begin', function (XmlElement $stream) { |
|
105 | + $this->_parser->on('parse.begin', function(XmlElement $stream) { |
|
106 | 106 | $this->_inbound = $stream; |
107 | - $this->emit('stream.open', [ $stream ]); |
|
107 | + $this->emit('stream.open', [$stream]); |
|
108 | 108 | }, with\argument(1, with\equals(0))); |
109 | 109 | |
110 | - $this->_parser->on('parse.end', function (XmlElement $stream) { |
|
111 | - $this->emit('stream.close', [ $stream ]); |
|
110 | + $this->_parser->on('parse.end', function(XmlElement $stream) { |
|
111 | + $this->emit('stream.close', [$stream]); |
|
112 | 112 | $this->_inbound = null; |
113 | 113 | }, with\argument(1, with\equals(0))); |
114 | 114 | |
115 | - $this->_parser->on('element', function (...$arguments) { |
|
115 | + $this->_parser->on('element', function(...$arguments) { |
|
116 | 116 | $this->emit('element', $arguments); |
117 | 117 | }); |
118 | 118 | |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function write($data) |
129 | 129 | { |
130 | - if($data instanceof XmlElement) { |
|
130 | + if ($data instanceof XmlElement) { |
|
131 | 131 | $this->_outbound->append($data); |
132 | 132 | } |
133 | 133 | |
134 | - $this->emit('send.'.($data instanceof XmlElement ? 'element' : 'text'), [ $data ]); |
|
134 | + $this->emit('send.' . ($data instanceof XmlElement ? 'element' : 'text'), [$data]); |
|
135 | 135 | |
136 | 136 | return parent::write($data); |
137 | 137 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | private function handleError(Error $element) |
194 | 194 | { |
195 | - if ($this->emit('stream.error', [ $element ])) { |
|
195 | + if ($this->emit('stream.error', [$element])) { |
|
196 | 196 | throw new StreamErrorException($element); |
197 | 197 | } |
198 | 198 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function equals($value) : \Closure |
36 | 36 | { |
37 | - return function ($argument) use ($value) { |
|
37 | + return function($argument) use ($value) { |
|
38 | 38 | return $argument == $value; |
39 | 39 | }; |
40 | 40 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | function same($value) : \Closure |
57 | 57 | { |
58 | - return function ($argument) use ($value) { |
|
58 | + return function($argument) use ($value) { |
|
59 | 59 | return $argument === $value; |
60 | 60 | }; |
61 | 61 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | function instance($expected) : \Closure |
79 | 79 | { |
80 | - return function ($object) use ($expected) { |
|
80 | + return function($object) use ($expected) { |
|
81 | 81 | return $expected instanceof \Closure ? $expected(get_class($object)) : $object instanceof $expected; |
82 | 82 | }; |
83 | 83 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | function matches($regex, ...$options) : \Closure |
105 | 105 | { |
106 | - return function ($value) use ($regex, $options) { |
|
106 | + return function($value) use ($regex, $options) { |
|
107 | 107 | return preg_match($regex, $value, $null, ...$options) > 0; |
108 | 108 | }; |
109 | 109 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @return \Closure |
123 | 123 | */ |
124 | 124 | function in(...$options) { |
125 | - return function ($value) use ($options) { |
|
125 | + return function($value) use ($options) { |
|
126 | 126 | return in_array($value, $options); |
127 | 127 | }; |
128 | 128 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | */ |
197 | 197 | function all(callable ...$functions) : \Closure |
198 | 198 | { |
199 | - return function (...$args) use ($functions) { |
|
199 | + return function(...$args) use ($functions) { |
|
200 | 200 | foreach ($functions as $function) { |
201 | 201 | if (!$function(...$args)) { |
202 | 202 | return false; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | function any(callable ...$functions) : \Closure |
227 | 227 | { |
228 | - return function (...$args) use ($functions) { |
|
228 | + return function(...$args) use ($functions) { |
|
229 | 229 | foreach ($functions as $function) { |
230 | 230 | if ($function(...$args)) { |
231 | 231 | return true; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | */ |
270 | 270 | function not(callable $predicate) : \Closure |
271 | 271 | { |
272 | - return function (...$arguments) use ($predicate) { |
|
272 | + return function(...$arguments) use ($predicate) { |
|
273 | 273 | return !$predicate(...$arguments); |
274 | 274 | }; |
275 | 275 | } |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | */ |
298 | 298 | function argument(int $offset, callable $predicate, $length = true) : \Closure |
299 | 299 | { |
300 | - if($length === true) { |
|
300 | + if ($length === true) { |
|
301 | 301 | $length = 1; |
302 | - } elseif($length === false) { |
|
302 | + } elseif ($length === false) { |
|
303 | 303 | $length = null; |
304 | 304 | } |
305 | 305 | |
306 | - return function (...$arguments) use ($predicate, $offset, $length) { |
|
306 | + return function(...$arguments) use ($predicate, $offset, $length) { |
|
307 | 307 | return $predicate(...array_slice($arguments, $offset, $length, false)); |
308 | 308 | }; |
309 | 309 | } |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | */ |
327 | 327 | function consecutive(callable ...$predicates) |
328 | 328 | { |
329 | - return function (...$arguments) use ($predicates) { |
|
329 | + return function(...$arguments) use ($predicates) { |
|
330 | 330 | foreach ($arguments as $index => $value) { |
331 | - if(!$predicates[$index]($value)) { |
|
331 | + if (!$predicates[$index]($value)) { |
|
332 | 332 | return false; |
333 | 333 | } |
334 | 334 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | return false; |
57 | 57 | } |
58 | 58 | } catch (\Throwable $exception) { |
59 | - if($this->emit('exception', [ $exception, $event ])) { |
|
59 | + if ($this->emit('exception', [$exception, $event])) { |
|
60 | 60 | throw $exception; |
61 | 61 | } |
62 | 62 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $condition = with\predicate($condition); |
91 | 91 | |
92 | - return function (...$arguments) use ($listener, $condition) { |
|
92 | + return function(...$arguments) use ($listener, $condition) { |
|
93 | 93 | if ($condition(...$arguments)) { |
94 | 94 | return (bool)$listener(...$arguments); |
95 | 95 | } |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | |
101 | 101 | private function getOnceCallable(callable $listener, $event) : callable |
102 | 102 | { |
103 | - return $onceListener = function (...$arguments) use (&$onceListener, $event, $listener) { |
|
104 | - if(($result = $listener(...$arguments)) !== null) { |
|
103 | + return $onceListener = function(...$arguments) use (&$onceListener, $event, $listener) { |
|
104 | + if (($result = $listener(...$arguments)) !== null) { |
|
105 | 105 | $this->removeListener($event, $onceListener); |
106 | 106 | return $result; |
107 | 107 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public function offsetSet($index, $value) |
72 | 72 | { |
73 | 73 | parent::offsetSet($index, $value); |
74 | - $this->emit('set', [ $value, $index ]); |
|
74 | + $this->emit('set', [$value, $index]); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function offsetUnset($index) |
87 | 87 | { |
88 | - $this->emit('remove', [ $this[$index], $index ]); |
|
88 | + $this->emit('remove', [$this[$index], $index]); |
|
89 | 89 | |
90 | 90 | parent::offsetUnset($index); |
91 | 91 | |
92 | - if(!count($this)) { |
|
92 | + if (!count($this)) { |
|
93 | 93 | $this->emit('empty'); |
94 | 94 | } |
95 | 95 | } |