@@ -29,11 +29,11 @@ |
||
| 29 | 29 | { |
| 30 | 30 | parent::setClient($client); |
| 31 | 31 | |
| 32 | - $client->on('features', function (Features $features) { |
|
| 32 | + $client->on('features', function(Features $features) { |
|
| 33 | 33 | return $this->handleFeatures($features); |
| 34 | 34 | }, null, 10); |
| 35 | 35 | |
| 36 | - $client->on('element', function (XmlElement $element) { |
|
| 36 | + $client->on('element', function(XmlElement $element) { |
|
| 37 | 37 | $this->handleTls($element); |
| 38 | 38 | }, with\xmlns(Features\StartTls::XMLNS)); |
| 39 | 39 | } |
@@ -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 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | public function getFrom() |
| 55 | 55 | { |
| 56 | - if($this->_from === false) { |
|
| 56 | + if ($this->_from === false) { |
|
| 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($this->_to === false) { |
|
| 65 | + if ($this->_to === false) { |
|
| 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 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | public static function getXmlCollocations() : array |
| 144 | 144 | { |
| 145 | 145 | return [ |
| 146 | - [ Error::class, 'name' => 'error', 'uri' => 'jabber:client' ], |
|
| 146 | + [Error::class, 'name' => 'error', 'uri' => 'jabber:client'], |
|
| 147 | 147 | ]; |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -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 | } |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | xml_parser_set_option($this->_parser, XML_OPTION_SKIP_WHITE, 1); |
| 72 | 72 | xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, 0); |
| 73 | 73 | |
| 74 | - xml_set_element_handler($this->_parser, function ($parser, $name, $attrs) { |
|
| 74 | + xml_set_element_handler($this->_parser, function($parser, $name, $attrs) { |
|
| 75 | 75 | $this->handleElementStart($name, $attrs); |
| 76 | - }, function () { |
|
| 76 | + }, function() { |
|
| 77 | 77 | $this->handleElementEnd(); |
| 78 | 78 | }); |
| 79 | 79 | |
| 80 | - xml_set_character_data_handler($this->_parser, function ($parser, $data) { |
|
| 80 | + xml_set_character_data_handler($this->_parser, function($parser, $data) { |
|
| 81 | 81 | $this->handleTextData($data); |
| 82 | 82 | }); |
| 83 | 83 | |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | return 'http://www.w3.org/2000/xmlns/'; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if (isset($namespaces[ $prefix ])) { |
|
| 115 | - return $namespaces[ $prefix ]; |
|
| 114 | + if (isset($namespaces[$prefix])) { |
|
| 115 | + return $namespaces[$prefix]; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | return !empty($this->_stack) ? end($this->_stack)->lookupUri($prefix) : null; |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | list($attributes, $namespaces) = $this->_attributes($attrs); |
| 124 | 124 | list($tag, $prefix) = XmlElement::resolve($name); |
| 125 | 125 | |
| 126 | - $uri = $this->_lookup($prefix, $namespaces); |
|
| 126 | + $uri = $this->_lookup($prefix, $namespaces); |
|
| 127 | 127 | |
| 128 | 128 | /** @var XmlElement $element */ |
| 129 | - $element = $this->factory->create($uri, $tag, [ $name, $uri ], $this->_getCollocations()); |
|
| 129 | + $element = $this->factory->create($uri, $tag, [$name, $uri], $this->_getCollocations()); |
|
| 130 | 130 | |
| 131 | 131 | foreach ($namespaces as $prefix => $uri) { |
| 132 | 132 | $element->setNamespace($uri, $prefix); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | private function _getCollocations() |
| 142 | 142 | { |
| 143 | - if(empty($this->_stack)) { |
|
| 143 | + if (empty($this->_stack)) { |
|
| 144 | 144 | return []; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | if (count($this->_stack) > 1) { |
| 160 | 160 | end($this->_stack)->append($element); |
| 161 | 161 | } |
| 162 | - $this->emit('parse.begin', [ $element ]); |
|
| 162 | + $this->emit('parse.begin', [$element]); |
|
| 163 | 163 | |
| 164 | 164 | $this->_stack[] = $element; |
| 165 | 165 | } |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $element = array_pop($this->_stack); |
| 174 | 174 | if (count($this->_stack) == 1) { |
| 175 | - $this->emit('element', [ $element ]); |
|
| 175 | + $this->emit('element', [$element]); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - $this->emit('parse.end', [ $element ]); |
|
| 178 | + $this->emit('parse.end', [$element]); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | private function handleTextData($data) |
@@ -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 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * $bar($element); // false, as element name is foo |
| 68 | 68 | * ``` |
| 69 | 69 | * |
| 70 | - * @param string|\Closure $name Expected element name or predicate. |
|
| 70 | + * @param string $name Expected element name or predicate. |
|
| 71 | 71 | * @return \Closure |
| 72 | 72 | */ |
| 73 | 73 | function name($name) |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * $bar($element); // false, as element name is foo |
| 101 | 101 | * ``` |
| 102 | 102 | * |
| 103 | - * @param string|\Closure $name Expected element name or predicate. |
|
| 103 | + * @param string $name Expected element name or predicate. |
|
| 104 | 104 | * @param $value |
| 105 | 105 | * @return \Closure |
| 106 | 106 | */ |
@@ -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 | } |