@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function getInnerXml() |
| 129 | 129 | { |
| 130 | - return implode('', array_map(function ($element) { |
|
| 130 | + return implode('', array_map(function($element) { |
|
| 131 | 131 | if (is_string($element)) { |
| 132 | 132 | return htmlspecialchars($element); |
| 133 | 133 | } elseif ($element instanceof XmlElement) { |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $attributes = $this->attributes(); |
| 155 | 155 | |
| 156 | 156 | $result = "<{$this->name}"; |
| 157 | - $result .= ' ' . implode(' ', array_map(function ($key, $value) { |
|
| 157 | + $result .= ' ' . implode(' ', array_map(function($key, $value) { |
|
| 158 | 158 | return $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"'; |
| 159 | 159 | }, array_keys($attributes), array_values($attributes))); |
| 160 | 160 | |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | private function attributes(): array |
| 415 | 415 | { |
| 416 | 416 | $namespaces = $this->getNamespaces(false); |
| 417 | - $namespaces = array_map(function ($prefix, $uri) { |
|
| 417 | + $namespaces = array_map(function($prefix, $uri) { |
|
| 418 | 418 | return [$prefix ? "xmlns:{$prefix}" : 'xmlns', $uri]; |
| 419 | 419 | }, array_values($namespaces), array_keys($namespaces)); |
| 420 | 420 | |
@@ -42,13 +42,13 @@ |
||
| 42 | 42 | |
| 43 | 43 | if ($stream = @stream_socket_client("tcp://$ip:$port")) { |
| 44 | 44 | $stream = new TcpStream($stream, $this->_loop); |
| 45 | - $this->emit('connect', [ $stream ]); |
|
| 45 | + $this->emit('connect', [$stream]); |
|
| 46 | 46 | |
| 47 | 47 | return $stream; |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - throw new \RuntimeException('Cannot connect to '.$this->_host); |
|
| 51 | + throw new \RuntimeException('Cannot connect to ' . $this->_host); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function __construct(string $host, LoopInterface $loop) |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | $this->register($module); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $this->_connector->on('connect', function (...$arguments) { |
|
| 103 | + $this->_connector->on('connect', function(...$arguments) { |
|
| 104 | 104 | return $this->emit('connect', $arguments); |
| 105 | 105 | }); |
| 106 | 106 | |
| 107 | - $this->on('element', function (Features $element) { |
|
| 107 | + $this->on('element', function(Features $element) { |
|
| 108 | 108 | $this->emit('features', [$element]); |
| 109 | 109 | }, Features::class); |
| 110 | 110 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | )); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - $this->_connector->on('connect', function ($stream) { |
|
| 170 | + $this->_connector->on('connect', function($stream) { |
|
| 171 | 171 | $this->handleConnect($stream); |
| 172 | 172 | }); |
| 173 | 173 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | public function setClient(XmppClient $client) |
| 51 | 51 | { |
| 52 | 52 | parent::setClient($client); |
| 53 | - $client->on('features', function (Features $features) { |
|
| 53 | + $client->on('features', function(Features $features) { |
|
| 54 | 54 | return $this->handleFeatures($features); |
| 55 | 55 | }); |
| 56 | 56 | } |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | $auth->append($response); |
| 83 | 83 | |
| 84 | - $callback = $this->_client->on('element', function (XmlElement $challenge) use ($mechanism) { |
|
| 84 | + $callback = $this->_client->on('element', function(XmlElement $challenge) use ($mechanism) { |
|
| 85 | 85 | $this->handleChallenge($challenge, $mechanism); |
| 86 | 86 | }, with\all(with\tag('challenge'), with\xmlns(self::XMLNS))); |
| 87 | 87 | |
| 88 | - $this->_client->on('element', function (XmlElement $result) use ($callback) { |
|
| 88 | + $this->_client->on('element', function(XmlElement $result) use ($callback) { |
|
| 89 | 89 | $this->handleAuthResult($result, $callback); |
| 90 | 90 | }, with\all(with\any(with\tag('success'), with\tag('failure')), with\xmlns(self::XMLNS))); |
| 91 | 91 | } else { |
@@ -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 | } |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | |
| 41 | 41 | public function getMechanisms() |
| 42 | 42 | { |
| 43 | - return array_map(function (XmlElement $element) { |
|
| 43 | + return array_map(function(XmlElement $element) { |
|
| 44 | 44 | return $element->innerXml; |
| 45 | 45 | }, $this->get(\Kadet\Xmpp\Utils\filter\tag('mechanisms'))->children ?? []); |
| 46 | 46 | } |
@@ -76,25 +76,25 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | $this->_parser = $parser; |
| 78 | 78 | |
| 79 | - $this->on('element', function (Error $element) { |
|
| 79 | + $this->on('element', function(Error $element) { |
|
| 80 | 80 | $this->handleError($element); |
| 81 | 81 | }, with\ofType(Error::class)); |
| 82 | 82 | |
| 83 | - $this->_parser->on('parse.begin', function (XmlElement $stream) { |
|
| 83 | + $this->_parser->on('parse.begin', function(XmlElement $stream) { |
|
| 84 | 84 | $this->_stream = $stream; |
| 85 | - $this->emit('stream.open', [ $stream ]); |
|
| 85 | + $this->emit('stream.open', [$stream]); |
|
| 86 | 86 | }, with\all(with\tag('stream'), with\xmlns(self::NAMESPACE_URI))); |
| 87 | 87 | |
| 88 | - $this->_parser->on('parse.end', function (XmlElement $stream) { |
|
| 89 | - $this->emit('stream.close', [ $stream ]); |
|
| 88 | + $this->_parser->on('parse.end', function(XmlElement $stream) { |
|
| 89 | + $this->emit('stream.close', [$stream]); |
|
| 90 | 90 | $this->_stream = null; |
| 91 | 91 | }, with\all(with\tag('stream'), with\xmlns(self::NAMESPACE_URI))); |
| 92 | 92 | |
| 93 | 93 | $this->on('data', [$this->_parser, 'parse']); |
| 94 | - $this->_parser->on('element', function (...$arguments) { |
|
| 94 | + $this->_parser->on('element', function(...$arguments) { |
|
| 95 | 95 | $this->emit('element', $arguments); |
| 96 | 96 | }); |
| 97 | - $this->on('close', function () { $this->_isOpened = false; }); |
|
| 97 | + $this->on('close', function() { $this->_isOpened = false; }); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function write($data) |
| 108 | 108 | { |
| 109 | - $this->emit('send.'.($data instanceof XmlElement ? 'element' : 'text'), [ $data ]); |
|
| 109 | + $this->emit('send.' . ($data instanceof XmlElement ? 'element' : 'text'), [$data]); |
|
| 110 | 110 | |
| 111 | 111 | return parent::write($data); |
| 112 | 112 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | private function handleError(Error $element) |
| 173 | 173 | { |
| 174 | - if ($this->emit('stream.error', [ $element ])) { |
|
| 174 | + if ($this->emit('stream.error', [$element])) { |
|
| 175 | 175 | throw new StreamErrorException($element); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | { |
| 73 | 73 | $console = Console::get(); |
| 74 | 74 | |
| 75 | - $result = $console->styled(['color' => 'yellow'], 'array').' with '.$console->styled(['color' => 'magenta'], count($array)).' elements:'.PHP_EOL; |
|
| 75 | + $result = $console->styled(['color' => 'yellow'], 'array') . ' with ' . $console->styled(['color' => 'magenta'], count($array)) . ' elements:' . PHP_EOL; |
|
| 76 | 76 | foreach ($array as $key => $value) { |
| 77 | - $result .= "\t".str_replace("\n", "\n\t", '['.$this->dump($key).']: '.$this->dump($value)).PHP_EOL; |
|
| 77 | + $result .= "\t" . str_replace("\n", "\n\t", '[' . $this->dump($key) . ']: ' . $this->dump($value)) . PHP_EOL; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | return $result; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | public function init() |
| 84 | 84 | { |
| 85 | - $this->register('array', [$this, '_dumpArray']); |
|
| 85 | + $this->register('array', [$this, '_dumpArray']); |
|
| 86 | 86 | $this->register('object', [$this, '_dumpObject']); |
| 87 | 87 | } |
| 88 | 88 | } |
@@ -107,7 +107,7 @@ |
||
| 107 | 107 | { |
| 108 | 108 | foreach ($events as $event) { |
| 109 | 109 | if (!isset($this->_redirectors[$event])) { |
| 110 | - $this->_redirectors[$event] = function (...$arguments) use ($event) { |
|
| 110 | + $this->_redirectors[$event] = function(...$arguments) use ($event) { |
|
| 111 | 111 | $this->emit($event, $arguments); |
| 112 | 112 | }; |
| 113 | 113 | } |