@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @param string $attribute Attribute name, optionally with prefix |
261 | 261 | * @param string|null $uri XML Namespace URI of attribute, prefix will be automatically looked up |
262 | - * @return bool|mixed |
|
262 | + * @return string |
|
263 | 263 | */ |
264 | 264 | public function getAttribute(string $attribute, string $uri = null) |
265 | 265 | { |
@@ -335,6 +335,9 @@ discard block |
||
335 | 335 | return $this->appendChild($element); |
336 | 336 | } |
337 | 337 | |
338 | + /** |
|
339 | + * @param XmlElement $element |
|
340 | + */ |
|
338 | 341 | public function remove($element) |
339 | 342 | { |
340 | 343 | $this->_children = array_filter($this->_children, not(filter\same($element))); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function getInnerXml() |
138 | 138 | { |
139 | - return implode('', array_map(function ($element) { |
|
139 | + return implode('', array_map(function($element) { |
|
140 | 140 | if (is_string($element)) { |
141 | 141 | return htmlspecialchars($element); |
142 | 142 | } elseif ($element instanceof XmlElement) { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $attributes = $this->attributes(); |
182 | 182 | |
183 | 183 | $result = "<{$this->name}"; |
184 | - $result .= ' ' . implode(' ', array_map(function ($key, $value) { |
|
184 | + $result .= ' ' . implode(' ', array_map(function($key, $value) { |
|
185 | 185 | return $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"'; |
186 | 186 | }, array_keys($attributes), array_values($attributes))); |
187 | 187 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function lookupPrefix(string $uri = null) |
204 | 204 | { |
205 | - return $this->getNamespaces()[ $uri ] ?? false; |
|
205 | + return $this->getNamespaces()[$uri] ?? false; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | { |
247 | 247 | $attribute = $this->_prefix($attribute, $uri); |
248 | 248 | if ($value === null) { |
249 | - unset($this->_attributes[ $attribute ]); |
|
249 | + unset($this->_attributes[$attribute]); |
|
250 | 250 | |
251 | 251 | return; |
252 | 252 | } |
253 | 253 | |
254 | - $this->_attributes[ $attribute ] = $value; |
|
254 | + $this->_attributes[$attribute] = $value; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | */ |
264 | 264 | public function getAttribute(string $attribute, string $uri = null) |
265 | 265 | { |
266 | - return $this->_attributes[ $this->_prefix($attribute, $uri) ] ?? false; |
|
266 | + return $this->_attributes[$this->_prefix($attribute, $uri)] ?? false; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function hasAttribute(string $attribute, string $uri = null) |
278 | 278 | { |
279 | - return isset($this->_attributes[ $this->_prefix($attribute, $uri) ]); |
|
279 | + return isset($this->_attributes[$this->_prefix($attribute, $uri)]); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | */ |
286 | 286 | public function getParents() |
287 | 287 | { |
288 | - return $this->_parent ? array_merge([ $this->_parent ], $this->_parent->getParents()) : []; |
|
288 | + return $this->_parent ? array_merge([$this->_parent], $this->_parent->getParents()) : []; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | protected function setParent(XmlElement $parent) |
305 | 305 | { |
306 | 306 | if (!$this->_prefix && ($prefix = $parent->lookupPrefix($this->namespace)) !== false) { |
307 | - $this->_namespaces[ $this->namespace ] = $prefix; |
|
307 | + $this->_namespaces[$this->namespace] = $prefix; |
|
308 | 308 | $this->_prefix = $prefix; |
309 | 309 | } |
310 | 310 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | return false; |
328 | 328 | } |
329 | 329 | |
330 | - if(is_array($element)) { |
|
330 | + if (is_array($element)) { |
|
331 | 331 | array_walk($element, [$this, 'appendChild']); |
332 | 332 | return $element; |
333 | 333 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | public function remove($element) |
339 | 339 | { |
340 | 340 | $this->_children = array_filter($this->_children, not(filter\same($element))); |
341 | - if($element instanceof XmlElement) { |
|
341 | + if ($element instanceof XmlElement) { |
|
342 | 342 | $element->_parent = null; |
343 | 343 | } |
344 | 344 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $prefix = $this->_prefix; |
389 | 389 | } |
390 | 390 | |
391 | - $this->_namespaces[ $uri ] = $prefix; |
|
391 | + $this->_namespaces[$uri] = $prefix; |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | public function getName() |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | */ |
437 | 437 | public function element(string $name, string $uri = null, int $index = 0) |
438 | 438 | { |
439 | - return array_values($this->elements($name, $uri))[ $index ] ?? false; |
|
439 | + return array_values($this->elements($name, $uri))[$index] ?? false; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | private function attributes(): array |
518 | 518 | { |
519 | 519 | $namespaces = $this->getNamespaces(false); |
520 | - $namespaces = array_map(function ($prefix, $uri) { |
|
520 | + $namespaces = array_map(function($prefix, $uri) { |
|
521 | 521 | return [$prefix ? "xmlns:{$prefix}" : 'xmlns', $uri]; |
522 | 522 | }, array_values($namespaces), array_keys($namespaces)); |
523 | 523 |
@@ -200,7 +200,7 @@ |
||
200 | 200 | * Registers module in client's dependency container. |
201 | 201 | * |
202 | 202 | * @param ComponentInterface $module Module to be registered |
203 | - * @param bool|string|array $alias Module alias, class name by default. |
|
203 | + * @param string|boolean $alias Module alias, class name by default. |
|
204 | 204 | * `true` for aliasing interfaces and parents too, |
205 | 205 | * `false` for aliasing as class name only |
206 | 206 | * array for multiple aliases, |
@@ -132,12 +132,12 @@ discard block |
||
132 | 132 | |
133 | 133 | $this->applyOptions($options); |
134 | 134 | |
135 | - $this->on('element', function (Features $element) { |
|
135 | + $this->on('element', function(Features $element) { |
|
136 | 136 | $this->_features = $element; |
137 | 137 | $this->emit('features', [$element]); |
138 | 138 | }, Features::class); |
139 | 139 | |
140 | - $this->on('close', function (Features $element) { |
|
140 | + $this->on('close', function(Features $element) { |
|
141 | 141 | $this->state = 'disconnected'; |
142 | 142 | }, Features::class); |
143 | 143 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $this->state = 'bound'; |
190 | 190 | |
191 | 191 | $queue = new \SplQueue(); |
192 | - $this->emit('init', [ $queue ]); |
|
192 | + $this->emit('init', [$queue]); |
|
193 | 193 | |
194 | 194 | \React\Promise\all(iterator_to_array($queue))->then(function() { |
195 | 195 | $this->state = 'ready'; |
@@ -213,10 +213,10 @@ discard block |
||
213 | 213 | $this->_container->set(get_class($module), $module); |
214 | 214 | |
215 | 215 | $this->_addToContainer($module, array_merge(class_implements($module), array_slice(class_parents($module), 1))); |
216 | - } elseif(is_array($alias)) { |
|
216 | + } elseif (is_array($alias)) { |
|
217 | 217 | $this->_addToContainer($module, $alias); |
218 | 218 | } else { |
219 | - $this->_addToContainer($module, [ $alias === false ? get_class($module) : $alias ]); |
|
219 | + $this->_addToContainer($module, [$alias === false ? get_class($module) : $alias]); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $deferred = new Deferred(); |
240 | 240 | |
241 | 241 | $this->once('element', function(Stanza $stanza) use ($deferred) { |
242 | - if($stanza->type === "error") { |
|
242 | + if ($stanza->type === "error") { |
|
243 | 243 | $deferred->reject($stanza); |
244 | 244 | } else { |
245 | 245 | $deferred->resolve($stanza); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | //region Parser |
276 | 276 | public function setParser(XmlParser $parser) |
277 | 277 | { |
278 | - if($this->state !== "disconnected") { |
|
278 | + if ($this->state !== "disconnected") { |
|
279 | 279 | throw new \BadMethodCallException('Parser can be changed only when client is disconnected.'); |
280 | 280 | } |
281 | 281 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | )); |
304 | 304 | } |
305 | 305 | |
306 | - $this->_connector->on('connect', function ($stream) { |
|
306 | + $this->_connector->on('connect', function($stream) { |
|
307 | 307 | return $this->handleConnect($stream); |
308 | 308 | }); |
309 | 309 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | foreach ($lookup['<predicate>'] as list($class, $predicate)) { |
36 | - if($predicate($tag, $namespace)) { |
|
36 | + if ($predicate($tag, $namespace)) { |
|
37 | 37 | return $class; |
38 | 38 | } |
39 | 39 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | { |
65 | 65 | $result = ['<predicate>' => []]; |
66 | 66 | foreach ($dictionary as $element) { |
67 | - if($element['name'] instanceof \Closure || $element['uri'] instanceof \Closure) { |
|
67 | + if ($element['name'] instanceof \Closure || $element['uri'] instanceof \Closure) { |
|
68 | 68 | $result['<predicate>'][] = [$element[0], \Kadet\Xmpp\Utils\filter\consecutive( |
69 | 69 | \Kadet\Xmpp\Utils\filter\predicate($element['name']), |
70 | 70 | \Kadet\Xmpp\Utils\filter\predicate($element['uri']) |
@@ -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 | return false; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | $condition = with\predicate($condition); |
92 | 92 | |
93 | - return function (...$arguments) use ($listener, $condition) { |
|
93 | + return function(...$arguments) use ($listener, $condition) { |
|
94 | 94 | if ($condition(...$arguments)) { |
95 | 95 | return $listener(...$arguments); |
96 | 96 | } |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | |
102 | 102 | private function getOnceCallable(callable $listener, $event) : callable |
103 | 103 | { |
104 | - return $onceListener = function (...$arguments) use (&$onceListener, $event, $listener) { |
|
105 | - if(($result = $listener(...$arguments)) !== INF) { |
|
104 | + return $onceListener = function(...$arguments) use (&$onceListener, $event, $listener) { |
|
105 | + if (($result = $listener(...$arguments)) !== INF) { |
|
106 | 106 | $this->removeListener($event, $onceListener); |
107 | 107 | return $result; |
108 | 108 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | protected function appendChild($element) |
50 | 50 | { |
51 | - if(count($this->children) > 0) { |
|
51 | + if (count($this->children) > 0) { |
|
52 | 52 | throw new \RuntimeException('Iq stanzas cannot have more than one child.'); |
53 | 53 | } |
54 | 54 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | public static function getXmlCollocations() : array |
78 | 78 | { |
79 | 79 | return array_merge( |
80 | - [[ Query::class, 'name' => pass(), 'uri' => pass() ]], |
|
80 | + [[Query::class, 'name' => pass(), 'uri' => pass()]], |
|
81 | 81 | parent::getXmlCollocations() |
82 | 82 | ); |
83 | 83 | } |