@@ -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) > 0) { |
160 | 160 | end($this->_stack)->append($element); |
161 | 161 | } |
162 | - $this->emit('parse.begin', [ $element, count($this->_stack) ]); |
|
162 | + $this->emit('parse.begin', [$element, count($this->_stack)]); |
|
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, count($this->_stack) ]); |
|
175 | + $this->emit('element', [$element, count($this->_stack)]); |
|
176 | 176 | } |
177 | 177 | |
178 | - $this->emit('parse.end', [ $element, count($this->_stack) ]); |
|
178 | + $this->emit('parse.end', [$element, count($this->_stack)]); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | private function handleTextData($data) |
@@ -91,35 +91,35 @@ discard block |
||
91 | 91 | parent::__construct($transport); |
92 | 92 | $this->setParser($parser); |
93 | 93 | |
94 | - $this->on('close', function () { $this->_isOpened = false; }); |
|
95 | - $this->on('element', function (Error $element) { |
|
94 | + $this->on('close', function() { $this->_isOpened = false; }); |
|
95 | + $this->on('element', function(Error $element) { |
|
96 | 96 | $this->handleError($element); |
97 | 97 | }, with\instance(Error::class)); |
98 | 98 | } |
99 | 99 | |
100 | 100 | public function setParser(XmlParser $parser) |
101 | 101 | { |
102 | - if($this->_parser) { |
|
103 | - $this->removeListener('data', [ $this->_parser, 'parse' ]); |
|
102 | + if ($this->_parser) { |
|
103 | + $this->removeListener('data', [$this->_parser, 'parse']); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | $this->_parser = $parser; |
107 | 107 | |
108 | - $this->_parser->on('parse.begin', function (XmlElement $stream) { |
|
108 | + $this->_parser->on('parse.begin', function(XmlElement $stream) { |
|
109 | 109 | $this->_inbound = $stream; |
110 | - $this->emit('stream.open', [ $stream ]); |
|
110 | + $this->emit('stream.open', [$stream]); |
|
111 | 111 | }, with\argument(1, with\equals(0))); |
112 | 112 | |
113 | - $this->_parser->on('parse.end', function (XmlElement $stream) { |
|
114 | - $this->emit('stream.close', [ $stream ]); |
|
113 | + $this->_parser->on('parse.end', function(XmlElement $stream) { |
|
114 | + $this->emit('stream.close', [$stream]); |
|
115 | 115 | $this->_inbound = null; |
116 | 116 | }, with\argument(1, with\equals(0))); |
117 | 117 | |
118 | - $this->_parser->on('element', function (...$arguments) { |
|
118 | + $this->_parser->on('element', function(...$arguments) { |
|
119 | 119 | $this->emit('element', $arguments); |
120 | 120 | }); |
121 | 121 | |
122 | - $this->on('data', [ $this->_parser, 'parse' ]); |
|
122 | + $this->on('data', [$this->_parser, 'parse']); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function write($data) |
132 | 132 | { |
133 | - if($data instanceof XmlElement) { |
|
133 | + if ($data instanceof XmlElement) { |
|
134 | 134 | $this->_outbound->append($data); |
135 | 135 | } |
136 | 136 | |
137 | - $this->emit('send.'.($data instanceof XmlElement ? 'element' : 'text'), [ $data ]); |
|
137 | + $this->emit('send.' . ($data instanceof XmlElement ? 'element' : 'text'), [$data]); |
|
138 | 138 | |
139 | 139 | return parent::write($data); |
140 | 140 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | |
196 | 196 | private function handleError(Error $element) |
197 | 197 | { |
198 | - if ($this->emit('stream.error', [ $element ])) { |
|
198 | + if ($this->emit('stream.error', [$element])) { |
|
199 | 199 | throw new StreamErrorException($element); |
200 | 200 | } |
201 | 201 |
@@ -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 | } |
@@ -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 |
@@ -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 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | { |
60 | 60 | parent::setClient($client); |
61 | 61 | |
62 | - $client->on('features', function (Features $features) { |
|
62 | + $client->on('features', function(Features $features) { |
|
63 | 63 | return !$this->auth($features); |
64 | 64 | }); |
65 | 65 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | { |
69 | 69 | if (!empty($features->mechanisms)) { |
70 | 70 | foreach ($features->mechanisms as $name) { |
71 | - if($this->tryMechanism($name)) { |
|
71 | + if ($this->tryMechanism($name)) { |
|
72 | 72 | return true; |
73 | 73 | } |
74 | 74 | } |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | $response = '='; |
113 | 113 | } |
114 | 114 | |
115 | - $callback = $this->_client->on('element', function (XmlElement $challenge) use ($mechanism) { |
|
115 | + $callback = $this->_client->on('element', function(XmlElement $challenge) use ($mechanism) { |
|
116 | 116 | $this->handleChallenge($challenge, $mechanism); |
117 | 117 | }, with\all(with\tag('challenge'), with\xmlns(self::XMLNS))); |
118 | 118 | |
119 | - $this->_client->once('element', function (XmlElement $result) use ($callback) { |
|
119 | + $this->_client->once('element', function(XmlElement $result) use ($callback) { |
|
120 | 120 | $this->_client->removeListener('element', $callback); |
121 | 121 | $this->handleAuthResult($result); |
122 | 122 | }, with\all(with\any(with\tag('success'), with\tag('failure')), with\xmlns(self::XMLNS))); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | private function mechanismWithoutChallenge(AuthenticationInterface $mechanism) |
128 | 128 | { |
129 | - $this->_client->once('element', function (XmlElement $result) { |
|
129 | + $this->_client->once('element', function(XmlElement $result) { |
|
130 | 130 | $this->handleAuthResult($result); |
131 | 131 | }, with\all(with\any(with\tag('success'), with\tag('failure')), with\xmlns(self::XMLNS))); |
132 | 132 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | private function handleAuthResult(XmlElement $result) |
145 | 145 | { |
146 | 146 | if ($result->localName === 'failure') { |
147 | - throw new AuthenticationException('Unable to auth. '.trim($result->innerXml)); |
|
147 | + throw new AuthenticationException('Unable to auth. ' . trim($result->innerXml)); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | $this->_client->getLogger()->info('Successfully authorized as {name}.', ['name' => (string)$this->_client->jid]); |
@@ -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 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | private function handleSet(Iq\Query\Roster $query) |
63 | 63 | { |
64 | 64 | foreach ($query->items as $item) { |
65 | - if($item->subscription == 'remove') { |
|
65 | + if ($item->subscription == 'remove') { |
|
66 | 66 | $this->removeItem($item->jid); |
67 | 67 | } else { |
68 | 68 | $this->setItem($item); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | $iq = new Iq('remove', ['query' => new Iq\Query\Roster()]); |
153 | 153 | /** @var Iq\Query\Roster\Item $item */ |
154 | - foreach($remove as $item) { |
|
154 | + foreach ($remove as $item) { |
|
155 | 155 | $iq->query->append(new Iq\Query\Roster\Item($item->jid, ['subscription' => 'remove'])); |
156 | 156 | } |
157 | 157 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | private function setItem(Iq\Query\Roster\Item $item) |
230 | 230 | { |
231 | - $this->emit('item', [ $item ]); |
|
231 | + $this->emit('item', [$item]); |
|
232 | 232 | $this->_items[(string)$item->jid] = $item; |
233 | 233 | } |
234 | 234 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | return; |
242 | 242 | } |
243 | 243 | |
244 | - $this->emit('remove', [ $this->_items[(string)$jid] ]); |
|
244 | + $this->emit('remove', [$this->_items[(string)$jid]]); |
|
245 | 245 | unset($this->_items[(string)$jid]); |
246 | 246 | } |
247 | 247 | } |