@@ -40,6 +40,6 @@ |
||
| 40 | 40 | |
| 41 | 41 | private function generateMessage(Error $error) : string |
| 42 | 42 | { |
| 43 | - return 'Stream error: '.str_replace('-', ' ', $error->kind).($error->text ? " ({$error->text})" : null); |
|
| 43 | + return 'Stream error: ' . str_replace('-', ' ', $error->kind) . ($error->text ? " ({$error->text})" : null); |
|
| 44 | 44 | } |
| 45 | 45 | } |
@@ -19,28 +19,28 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | function xmlns($uri) |
| 21 | 21 | { |
| 22 | - return function (XmlElement $element) use ($uri) { |
|
| 22 | + return function(XmlElement $element) use ($uri) { |
|
| 23 | 23 | return $element->namespaceURI === $uri; |
| 24 | 24 | }; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | function tag($name) |
| 28 | 28 | { |
| 29 | - return function (XmlElement $element) use ($name) { |
|
| 29 | + return function(XmlElement $element) use ($name) { |
|
| 30 | 30 | return $element->localName === $name; |
| 31 | 31 | }; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function ofType($class) |
| 35 | 35 | { |
| 36 | - return function ($object) use ($class) { |
|
| 36 | + return function($object) use ($class) { |
|
| 37 | 37 | return $object instanceof $class; |
| 38 | 38 | }; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | function all(callable ...$functions) |
| 42 | 42 | { |
| 43 | - return function (...$args) use ($functions) { |
|
| 43 | + return function(...$args) use ($functions) { |
|
| 44 | 44 | foreach ($functions as $function) { |
| 45 | 45 | if (!$function(...$args)) { |
| 46 | 46 | return false; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | function any(callable ...$functions) |
| 55 | 55 | { |
| 56 | - return function (...$args) use ($functions) { |
|
| 56 | + return function(...$args) use ($functions) { |
|
| 57 | 57 | foreach ($functions as $function) { |
| 58 | 58 | if ($function(...$args)) { |
| 59 | 59 | return true; |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | continue; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $this->_results = array_merge($this->_results, array_map(function ($record) { |
|
| 57 | + $this->_results = array_merge($this->_results, array_map(function($record) { |
|
| 58 | 58 | return [$record['target'], $record['port']]; |
| 59 | 59 | }, $result)); |
| 60 | 60 | } |
@@ -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 | |
@@ -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 | |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | list($attributes, $namespaces) = $this->_attributes($attrs); |
| 120 | 120 | list($tag, $prefix) = XmlElement::resolve($name); |
| 121 | 121 | |
| 122 | - $uri = $this->_lookup($prefix, $namespaces); |
|
| 122 | + $uri = $this->_lookup($prefix, $namespaces); |
|
| 123 | 123 | |
| 124 | 124 | /** @var XmlElement $element */ |
| 125 | - $element = $this->factory->create($uri, $tag, [ $name, $uri ]); |
|
| 125 | + $element = $this->factory->create($uri, $tag, [$name, $uri]); |
|
| 126 | 126 | foreach ($attributes as $name => $value) { |
| 127 | 127 | $element->setAttribute($name, $value); |
| 128 | 128 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | if (count($this->_stack) > 1) { |
| 138 | 138 | end($this->_stack)->append($element); |
| 139 | 139 | } |
| 140 | - $this->emit('parse.begin', [ $element ]); |
|
| 140 | + $this->emit('parse.begin', [$element]); |
|
| 141 | 141 | |
| 142 | 142 | $this->_stack[] = $element; |
| 143 | 143 | } |
@@ -150,10 +150,10 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | $element = array_pop($this->_stack); |
| 152 | 152 | if (count($this->_stack) == 1) { |
| 153 | - $this->emit('element', [ $element ]); |
|
| 153 | + $this->emit('element', [$element]); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - $this->emit('parse.end', [ $element ]); |
|
| 156 | + $this->emit('parse.end', [$element]); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | private function handleTextData($data) |
@@ -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 | } |