@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | |
111 | 111 | $this->applyOptions($options); |
112 | 112 | |
113 | - $this->_connector->on('connect', function (...$arguments) { |
|
113 | + $this->_connector->on('connect', function(...$arguments) { |
|
114 | 114 | return $this->emit('connect', $arguments); |
115 | 115 | }); |
116 | 116 | |
117 | - $this->on('element', function (Features $element) { |
|
117 | + $this->on('element', function(Features $element) { |
|
118 | 118 | $this->_features = $element; |
119 | 119 | $this->emit('features', [$element]); |
120 | 120 | }, Features::class); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | 'password' => -1 |
134 | 134 | ]); |
135 | 135 | |
136 | - if($options['default-modules']) { |
|
136 | + if ($options['default-modules']) { |
|
137 | 137 | $options['modules'] = array_merge([ |
138 | 138 | TlsEnabler::class => new TlsEnabler(), |
139 | 139 | Binding::class => new Binding(), |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | )); |
219 | 219 | } |
220 | 220 | |
221 | - $this->_connector->on('connect', function ($stream) { |
|
221 | + $this->_connector->on('connect', function($stream) { |
|
222 | 222 | $this->handleConnect($stream); |
223 | 223 | }); |
224 | 224 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function setType(string $type) |
68 | 68 | { |
69 | - if(!in_array($type, ['auth', 'cancel', 'continue', 'modify', 'wait'])) { |
|
69 | + if (!in_array($type, ['auth', 'cancel', 'continue', 'modify', 'wait'])) { |
|
70 | 70 | throw new InvalidArgumentException( |
71 | 71 | format("Error type must be 'auth', 'cancel', 'continue', 'modify' or 'wait', '{type}' given.", [ |
72 | 72 | 'type' => $type |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function setText(string $text) |
114 | 114 | { |
115 | - if(!$this->text) { |
|
115 | + if (!$this->text) { |
|
116 | 116 | $this->append(new XmlElement('text', self::XMLNS)); |
117 | 117 | } |
118 | 118 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | !$condition instanceof XmlElement ? $this->_definedCondition($condition) : $condition |
135 | 135 | ]; |
136 | 136 | |
137 | - if($description !== null) { |
|
137 | + if ($description !== null) { |
|
138 | 138 | $content[] = new XmlElement('text', self::XMLNS, ['content' => $description]); |
139 | 139 | } |
140 | 140 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | private function _definedCondition(string $condition) : XmlElement |
147 | 147 | { |
148 | - if(!in_array($condition, [ |
|
148 | + if (!in_array($condition, [ |
|
149 | 149 | 'bad-request', 'conflict', 'feature-not-implemented', 'forbidden', |
150 | 150 | 'gone', 'internal-server-error', 'item-not-found', 'jid-malformed', |
151 | 151 | 'not-acceptable', 'not-allowed', 'not-authorized', 'policy-violation', |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function __construct(array $features = []) |
40 | 40 | { |
41 | - parent::__construct('stream:features', XmlStream::NAMESPACE_URI, [ 'content' => $features ]); |
|
41 | + parent::__construct('stream:features', XmlStream::NAMESPACE_URI, ['content' => $features]); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | public function getMechanisms() |
53 | 53 | { |
54 | - return array_map(function (XmlElement $element) { |
|
54 | + return array_map(function(XmlElement $element) { |
|
55 | 55 | return $element->innerXml; |
56 | 56 | }, $this->get(\Kadet\Xmpp\Utils\filter\tag('mechanisms'))->children ?? []); |
57 | 57 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function getInnerXml() |
137 | 137 | { |
138 | - return implode('', array_map(function ($element) { |
|
138 | + return implode('', array_map(function($element) { |
|
139 | 139 | if (is_string($element)) { |
140 | 140 | return htmlspecialchars($element); |
141 | 141 | } elseif ($element instanceof XmlElement) { |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $attributes = $this->attributes(); |
181 | 181 | |
182 | 182 | $result = "<{$this->name}"; |
183 | - $result .= ' ' . implode(' ', array_map(function ($key, $value) { |
|
183 | + $result .= ' ' . implode(' ', array_map(function($key, $value) { |
|
184 | 184 | return $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"'; |
185 | 185 | }, array_keys($attributes), array_values($attributes))); |
186 | 186 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function lookupPrefix(string $uri = null) |
203 | 203 | { |
204 | - return $this->getNamespaces()[ $uri ] ?? false; |
|
204 | + return $this->getNamespaces()[$uri] ?? false; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -245,12 +245,12 @@ discard block |
||
245 | 245 | { |
246 | 246 | $attribute = $this->_prefix($attribute, $uri); |
247 | 247 | if ($value === null) { |
248 | - unset($this->_attributes[ $attribute ]); |
|
248 | + unset($this->_attributes[$attribute]); |
|
249 | 249 | |
250 | 250 | return; |
251 | 251 | } |
252 | 252 | |
253 | - $this->_attributes[ $attribute ] = $value; |
|
253 | + $this->_attributes[$attribute] = $value; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public function getAttribute(string $attribute, string $uri = null) |
264 | 264 | { |
265 | - return $this->_attributes[ $this->_prefix($attribute, $uri) ] ?? false; |
|
265 | + return $this->_attributes[$this->_prefix($attribute, $uri)] ?? false; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | */ |
276 | 276 | public function hasAttribute(string $attribute, string $uri = null) |
277 | 277 | { |
278 | - return isset($this->_attributes[ $this->_prefix($attribute, $uri) ]); |
|
278 | + return isset($this->_attributes[$this->_prefix($attribute, $uri)]); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | */ |
285 | 285 | public function getParents() |
286 | 286 | { |
287 | - return $this->_parent ? array_merge([ $this->_parent ], $this->_parent->getParents()) : []; |
|
287 | + return $this->_parent ? array_merge([$this->_parent], $this->_parent->getParents()) : []; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | protected function setParent(XmlElement $parent) |
304 | 304 | { |
305 | 305 | if (!$this->_prefix && ($prefix = $parent->lookupPrefix($this->namespace)) !== false) { |
306 | - $this->_namespaces[ $this->namespace ] = $prefix; |
|
306 | + $this->_namespaces[$this->namespace] = $prefix; |
|
307 | 307 | $this->_prefix = $prefix; |
308 | 308 | } |
309 | 309 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | return false; |
327 | 327 | } |
328 | 328 | |
329 | - if(is_array($element)) { |
|
329 | + if (is_array($element)) { |
|
330 | 330 | array_walk($element, [$this, 'append']); |
331 | 331 | return $element; |
332 | 332 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $prefix = $this->_prefix; |
371 | 371 | } |
372 | 372 | |
373 | - $this->_namespaces[ $uri ] = $prefix; |
|
373 | + $this->_namespaces[$uri] = $prefix; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | public function getName() |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public function element(string $name, string $uri = null, int $index = 0) |
420 | 420 | { |
421 | - return array_values($this->elements($name, $uri))[ $index ] ?? false; |
|
421 | + return array_values($this->elements($name, $uri))[$index] ?? false; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | private function attributes(): array |
493 | 493 | { |
494 | 494 | $namespaces = $this->getNamespaces(false); |
495 | - $namespaces = array_map(function ($prefix, $uri) { |
|
495 | + $namespaces = array_map(function($prefix, $uri) { |
|
496 | 496 | return [$prefix ? "xmlns:{$prefix}" : 'xmlns', $uri]; |
497 | 497 | }, array_values($namespaces), array_keys($namespaces)); |
498 | 498 |
@@ -42,13 +42,13 @@ |
||
42 | 42 | |
43 | 43 | private static function _conditionDescription(Error $error) |
44 | 44 | { |
45 | - if(!empty($error->text)) { |
|
45 | + if (!empty($error->text)) { |
|
46 | 46 | return $error->text; |
47 | 47 | } |
48 | 48 | |
49 | 49 | return [ |
50 | 50 | 'bad-request' => 'Bad Request: "{resource}" is not valid XMPP resource identifier.', |
51 | 51 | 'conflict' => 'Conflict: {bare}/{resource} is already in use.' |
52 | - ][$error->condition] ?? 'Unknown reason: '.$error->condition; |
|
52 | + ][$error->condition] ?? 'Unknown reason: ' . $error->condition; |
|
53 | 53 | } |
54 | 54 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | $predicate = $uri instanceof \Closure ? $uri : \Kadet\Xmpp\Utils\filter\same($uri); |
43 | 43 | |
44 | - return function ($element) use ($predicate) { |
|
44 | + return function($element) use ($predicate) { |
|
45 | 45 | if (!$element instanceof XmlElement) { |
46 | 46 | return false; |
47 | 47 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | { |
75 | 75 | $predicate = $name instanceof \Closure ? $name : \Kadet\Xmpp\Utils\filter\same($name); |
76 | 76 | |
77 | - return function ($element) use ($predicate) { |
|
77 | + return function($element) use ($predicate) { |
|
78 | 78 | if (!$element instanceof XmlElement) { |
79 | 79 | return false; |
80 | 80 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | { |
109 | 109 | $predicate = $value instanceof \Closure ? $value : \Kadet\Xmpp\Utils\filter\equals($value); |
110 | 110 | |
111 | - return function ($element) use ($name, $predicate) { |
|
111 | + return function($element) use ($name, $predicate) { |
|
112 | 112 | if (!$element instanceof XmlElement) { |
113 | 113 | return false; |
114 | 114 | } |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | { |
32 | 32 | parent::setClient($client); |
33 | 33 | |
34 | - $client->on('features', function (Features $features) { |
|
34 | + $client->on('features', function(Features $features) { |
|
35 | 35 | return !$this->bind($features); |
36 | 36 | }); |
37 | 37 | } |
38 | 38 | |
39 | 39 | public function bind(Features $features) |
40 | 40 | { |
41 | - if($features->has(with\element('bind', self::XMLNS))) { |
|
41 | + if ($features->has(with\element('bind', self::XMLNS))) { |
|
42 | 42 | $stanza = new Stanza('iq', ['attributes' => ['type' => 'set']]); |
43 | 43 | $bind = $stanza->append(new XmlElement('bind', self::XMLNS)); |
44 | 44 | |
45 | - if(!$this->_client->jid->isBare()) { |
|
45 | + if (!$this->_client->jid->isBare()) { |
|
46 | 46 | $bind->append(new XmlElement('resource', null, ['content' => $this->_client->jid->resource])); |
47 | 47 | } |
48 | 48 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | public function handleResult(Stanza $stanza) |
61 | 61 | { |
62 | - if($stanza->type === 'error') { |
|
62 | + if ($stanza->type === 'error') { |
|
63 | 63 | throw BindingException::fromError($this->_client->jid, $stanza->error); |
64 | 64 | } |
65 | 65 |
@@ -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($class) : \Closure |
79 | 79 | { |
80 | - return function ($object) use ($class) { |
|
80 | + return function($object) use ($class) { |
|
81 | 81 | return $object instanceof $class; |
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 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | function all(callable ...$functions) : \Closure |
179 | 179 | { |
180 | - return function (...$args) use ($functions) { |
|
180 | + return function(...$args) use ($functions) { |
|
181 | 181 | foreach ($functions as $function) { |
182 | 182 | if (!$function(...$args)) { |
183 | 183 | return false; |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | function any(callable ...$functions) : \Closure |
208 | 208 | { |
209 | - return function (...$args) use ($functions) { |
|
209 | + return function(...$args) use ($functions) { |
|
210 | 210 | foreach ($functions as $function) { |
211 | 211 | if ($function(...$args)) { |
212 | 212 | return true; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | function not(callable $predicate) : \Closure |
252 | 252 | { |
253 | - return function (...$arguments) use ($predicate) { |
|
253 | + return function(...$arguments) use ($predicate) { |
|
254 | 254 | return !$predicate(...$arguments); |
255 | 255 | }; |
256 | 256 | } |
@@ -278,13 +278,13 @@ discard block |
||
278 | 278 | */ |
279 | 279 | function argument(int $offset, callable $predicate, $length = true) : \Closure |
280 | 280 | { |
281 | - if($length === true) { |
|
281 | + if ($length === true) { |
|
282 | 282 | $length = 1; |
283 | - } elseif($length === false) { |
|
283 | + } elseif ($length === false) { |
|
284 | 284 | $length = null; |
285 | 285 | } |
286 | 286 | |
287 | - return function (...$arguments) use ($predicate, $offset, $length) { |
|
287 | + return function(...$arguments) use ($predicate, $offset, $length) { |
|
288 | 288 | return $predicate(...array_slice($arguments, $offset, $length, false)); |
289 | 289 | }; |
290 | 290 | } |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | */ |
308 | 308 | function consecutive(callable ...$predicates) |
309 | 309 | { |
310 | - return function (...$arguments) use ($predicates) { |
|
310 | + return function(...$arguments) use ($predicates) { |
|
311 | 311 | foreach ($arguments as $index => $value) { |
312 | - if(!$predicates[$index]($value)) { |
|
312 | + if (!$predicates[$index]($value)) { |
|
313 | 313 | return false; |
314 | 314 | } |
315 | 315 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | public function getFrom() |
55 | 55 | { |
56 | - if((string)$this->_from !== $this->hasAttribute('from')) { |
|
56 | + if ((string)$this->_from !== $this->hasAttribute('from')) { |
|
57 | 57 | $this->_from = $this->hasAttribute('from') ? new Jid($this->_from) : null; |
58 | 58 | } |
59 | 59 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | public function getTo() |
64 | 64 | { |
65 | - if((string)$this->_to !== $this->hasAttribute('to')) { |
|
65 | + if ((string)$this->_to !== $this->hasAttribute('to')) { |
|
66 | 66 | $this->_to = $this->hasAttribute('to') ? new Jid($this->_to) : null; |
67 | 67 | } |
68 | 68 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | public function setFrom($from) |
88 | 88 | { |
89 | - if($from instanceof Jid) { |
|
89 | + if ($from instanceof Jid) { |
|
90 | 90 | $this->_from = $from instanceof Jid ? $from : new Jid($from); |
91 | 91 | } |
92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | public function setTo($to) |
97 | 97 | { |
98 | - if($to instanceof Jid) { |
|
98 | + if ($to instanceof Jid) { |
|
99 | 99 | $this->_to = $to instanceof Jid ? $to : new Jid($to); |
100 | 100 | } |
101 | 101 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | public static function getXmlCollocations() : array |
132 | 132 | { |
133 | 133 | return [ |
134 | - [ Error::class, 'name' => 'error', 'uri' => 'jabber:client' ], |
|
134 | + [Error::class, 'name' => 'error', 'uri' => 'jabber:client'], |
|
135 | 135 | ]; |
136 | 136 | } |
137 | 137 | } |