@@ -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($expected) : \Closure |
| 79 | 79 | { |
| 80 | - return function ($object) use ($expected) { |
|
| 80 | + return function($object) use ($expected) { |
|
| 81 | 81 | return $expected instanceof \Closure ? $expected(get_class($object)) : $object instanceof $expected; |
| 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 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @return \Closure |
| 123 | 123 | */ |
| 124 | 124 | function in(...$options) { |
| 125 | - return function ($value) use ($options) { |
|
| 125 | + return function($value) use ($options) { |
|
| 126 | 126 | return in_array($value, $options); |
| 127 | 127 | }; |
| 128 | 128 | } |
@@ -142,10 +142,10 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | function contains($value) |
| 144 | 144 | { |
| 145 | - if($value instanceof \Closure) { |
|
| 146 | - return function (array $array) use ($value) { |
|
| 145 | + if ($value instanceof \Closure) { |
|
| 146 | + return function(array $array) use ($value) { |
|
| 147 | 147 | foreach ($array as $item) { |
| 148 | - if($value($item)) { |
|
| 148 | + if ($value($item)) { |
|
| 149 | 149 | return true; |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | }; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - return function (array $array) use ($value) { |
|
| 157 | + return function(array $array) use ($value) { |
|
| 158 | 158 | return array_search($value, $array) !== false; |
| 159 | 159 | }; |
| 160 | 160 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | function has($key) |
| 176 | 176 | { |
| 177 | - return function (array $array) use ($key) { |
|
| 177 | + return function(array $array) use ($key) { |
|
| 178 | 178 | return (contains($key))(array_keys($array)); |
| 179 | 179 | }; |
| 180 | 180 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | function all(callable ...$functions) : \Closure |
| 250 | 250 | { |
| 251 | - return function (...$args) use ($functions) { |
|
| 251 | + return function(...$args) use ($functions) { |
|
| 252 | 252 | foreach ($functions as $function) { |
| 253 | 253 | if (!$function(...$args)) { |
| 254 | 254 | return false; |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | function any(callable ...$functions) : \Closure |
| 279 | 279 | { |
| 280 | - return function (...$args) use ($functions) { |
|
| 280 | + return function(...$args) use ($functions) { |
|
| 281 | 281 | foreach ($functions as $function) { |
| 282 | 282 | if ($function(...$args)) { |
| 283 | 283 | return true; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | function not($predicate) : \Closure |
| 323 | 323 | { |
| 324 | 324 | $predicate = predicate($predicate); |
| 325 | - return function (...$arguments) use ($predicate) { |
|
| 325 | + return function(...$arguments) use ($predicate) { |
|
| 326 | 326 | return !$predicate(...$arguments); |
| 327 | 327 | }; |
| 328 | 328 | } |
@@ -350,13 +350,13 @@ discard block |
||
| 350 | 350 | */ |
| 351 | 351 | function argument(int $offset, callable $predicate, $length = true) : \Closure |
| 352 | 352 | { |
| 353 | - if($length === true) { |
|
| 353 | + if ($length === true) { |
|
| 354 | 354 | $length = 1; |
| 355 | - } elseif($length === false) { |
|
| 355 | + } elseif ($length === false) { |
|
| 356 | 356 | $length = null; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - return function (...$arguments) use ($predicate, $offset, $length) { |
|
| 359 | + return function(...$arguments) use ($predicate, $offset, $length) { |
|
| 360 | 360 | return $predicate(...array_slice($arguments, $offset, $length, false)); |
| 361 | 361 | }; |
| 362 | 362 | } |
@@ -379,9 +379,9 @@ discard block |
||
| 379 | 379 | */ |
| 380 | 380 | function consecutive(callable ...$predicates) |
| 381 | 381 | { |
| 382 | - return function (...$arguments) use ($predicates) { |
|
| 382 | + return function(...$arguments) use ($predicates) { |
|
| 383 | 383 | foreach ($arguments as $index => $value) { |
| 384 | - if(!$predicates[$index]($value)) { |
|
| 384 | + if (!$predicates[$index]($value)) { |
|
| 385 | 385 | return false; |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | function property($name, $value) { |
| 394 | 394 | $predicate = $value instanceof \Closure ? $value : \Kadet\Xmpp\Utils\filter\equals($value); |
| 395 | 395 | |
| 396 | - return function ($element) use ($name, $predicate) { |
|
| 396 | + return function($element) use ($name, $predicate) { |
|
| 397 | 397 | return $predicate($element->$name); |
| 398 | 398 | }; |
| 399 | 399 | } |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | function typeof($value) : string |
| 27 | 27 | { |
| 28 | 28 | if (is_object($value)) { |
| 29 | - return "object of type ".get_class($value); |
|
| 29 | + return "object of type " . get_class($value); |
|
| 30 | 30 | } elseif (is_resource($value)) { |
| 31 | - return get_resource_type($value).' resource'; |
|
| 31 | + return get_resource_type($value) . ' resource'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | return gettype($value); |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | function partial(callable $callable, $argument, int $position = 0) : callable |
| 38 | 38 | { |
| 39 | - return function (...$arguments) use ($callable, $argument, $position) { |
|
| 39 | + return function(...$arguments) use ($callable, $argument, $position) { |
|
| 40 | 40 | $arguments = array_merge( |
| 41 | 41 | array_slice($arguments, 0, $position), |
| 42 | - [ $argument ], |
|
| 42 | + [$argument], |
|
| 43 | 43 | array_slice($arguments, $position) |
| 44 | 44 | ); |
| 45 | 45 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | function dump($value) |
| 51 | 51 | { |
| 52 | - echo Dumper::get()->dump($value).PHP_EOL.PHP_EOL; |
|
| 52 | + echo Dumper::get()->dump($value) . PHP_EOL . PHP_EOL; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | function dd($value) |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | function format($string, array $arguments = []) |
| 62 | 62 | { |
| 63 | - return str_replace(array_map(function ($e) { return "{{$e}}"; }, array_keys($arguments)), $arguments, $string); |
|
| 63 | + return str_replace(array_map(function($e) { return "{{$e}}"; }, array_keys($arguments)), $arguments, $string); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | function rearrange(array $array, array $keys) : array |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | function copy(array $array) |
| 76 | 76 | { |
| 77 | 77 | return array_map(function($element) { |
| 78 | - if(is_array($element)) { |
|
| 78 | + if (is_array($element)) { |
|
| 79 | 79 | return copy($element); |
| 80 | - } elseif(is_object($element)) { |
|
| 80 | + } elseif (is_object($element)) { |
|
| 81 | 81 | return clone $element; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -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 Iq('set'); |
| 43 | 43 | $bind = $stanza->append(new Iq\Query(self::XMLNS, 'bind')); |
| 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(Iq $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 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function enable() |
| 57 | 57 | { |
| 58 | - if($this->_interval) { |
|
| 58 | + if ($this->_interval) { |
|
| 59 | 59 | $this->_timer = $this->_client->connector->getLoop()->addPeriodicTimer($this->_interval, function() { |
| 60 | 60 | $this->keepAlive(); |
| 61 | 61 | }); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function disable() |
| 69 | 69 | { |
| 70 | - if($this->_timer) { |
|
| 70 | + if ($this->_timer) { |
|
| 71 | 71 | $this->_timer->cancel(); |
| 72 | 72 | } |
| 73 | 73 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | parent::setClient($client); |
| 66 | 66 | |
| 67 | - $client->on('features', function (Features $features) { |
|
| 67 | + $client->on('features', function(Features $features) { |
|
| 68 | 68 | return !$this->auth($features); |
| 69 | 69 | }); |
| 70 | 70 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | { |
| 74 | 74 | if (!empty($features->mechanisms)) { |
| 75 | 75 | foreach ($features->mechanisms as $name) { |
| 76 | - if($this->tryMechanism($name)) { |
|
| 76 | + if ($this->tryMechanism($name)) { |
|
| 77 | 77 | return true; |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | $response = ''; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $callback = $this->_client->on('element', function (XmlElement $challenge) use ($mechanism) { |
|
| 120 | + $callback = $this->_client->on('element', function(XmlElement $challenge) use ($mechanism) { |
|
| 121 | 121 | $this->handleChallenge($challenge, $mechanism); |
| 122 | 122 | }, with\element('challenge', self::XMLNS)); |
| 123 | 123 | |
| 124 | - $this->_client->once('element', function (XmlElement $result) use ($callback) { |
|
| 124 | + $this->_client->once('element', function(XmlElement $result) use ($callback) { |
|
| 125 | 125 | $this->_client->removeListener('element', $callback); |
| 126 | 126 | $this->handleAuthResult($result); |
| 127 | 127 | }, $this->_resultPredicate()); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | private function mechanismWithoutChallenge(AuthenticationInterface $mechanism) |
| 133 | 133 | { |
| 134 | - $this->_client->once('element', function (XmlElement $result) { |
|
| 134 | + $this->_client->once('element', function(XmlElement $result) { |
|
| 135 | 135 | $this->handleAuthResult($result); |
| 136 | 136 | }, $this->_resultPredicate()); |
| 137 | 137 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | { |
| 151 | 151 | // todo: handle different scenarios |
| 152 | 152 | if ($result->localName === 'failure') { |
| 153 | - throw new AuthenticationException('Unable to auth. '.trim($result->innerXml)); |
|
| 153 | + throw new AuthenticationException('Unable to auth. ' . trim($result->innerXml)); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | $this->_client->getLogger()->info('Successfully authorized as {name}.', ['name' => (string)$this->_client->jid]); |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | { |
| 21 | 21 | public static function available() { |
| 22 | 22 | static $reflection = null; |
| 23 | - if(!$reflection) { |
|
| 23 | + if (!$reflection) { |
|
| 24 | 24 | $reflection = new \ReflectionClass(static::class); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function setShow(string $show = 'available') |
| 70 | 70 | { |
| 71 | - if(!Show::valid($show)) { |
|
| 71 | + if (!Show::valid($show)) { |
|
| 72 | 72 | throw new InvalidArgumentException(format('$show must be one of: {possible}. {show} given.', [ |
| 73 | 73 | 'possible' => implode(', ', Show::available()), |
| 74 | 74 | 'show' => $show |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $predicate = filter\element('show', 'jabber:client'); |
| 79 | - if(in_array($show, ['available', 'unavailable'])) { |
|
| 79 | + if (in_array($show, ['available', 'unavailable'])) { |
|
| 80 | 80 | $this->remove($predicate); |
| 81 | 81 | $this->type = $show; |
| 82 | 82 | return; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | public function setStatus(string $status = null) |
| 99 | 99 | { |
| 100 | 100 | $predicate = filter\element('status', 'jabber:client'); |
| 101 | - if($status === null) { |
|
| 101 | + if ($status === null) { |
|
| 102 | 102 | $this->remove($predicate); |
| 103 | 103 | return; |
| 104 | 104 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | public function setPriority(int $priority = null) |
| 115 | 115 | { |
| 116 | 116 | $predicate = filter\element('status', 'jabber:client'); |
| 117 | - if(!$priority) { |
|
| 117 | + if (!$priority) { |
|
| 118 | 118 | $this->remove($predicate); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * |
| 262 | 262 | * @param string $attribute Attribute name, optionally with prefix |
| 263 | 263 | * @param string|null $uri XML Namespace URI of attribute, prefix will be automatically looked up |
| 264 | - * @return bool|mixed |
|
| 264 | + * @return string |
|
| 265 | 265 | */ |
| 266 | 266 | public function getAttribute(string $attribute, string $uri = null) |
| 267 | 267 | { |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | * |
| 484 | 484 | * @param callable|string $predicate Predicate or class name |
| 485 | 485 | * |
| 486 | - * @return XmlElement|false |
|
| 486 | + * @return XmlElement|null |
|
| 487 | 487 | */ |
| 488 | 488 | public function get($predicate) |
| 489 | 489 | { |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function getInnerXml() |
| 140 | 140 | { |
| 141 | - return implode('', array_map(function ($element) { |
|
| 141 | + return implode('', array_map(function($element) { |
|
| 142 | 142 | if (is_string($element)) { |
| 143 | 143 | return htmlspecialchars($element); |
| 144 | 144 | } elseif ($element instanceof XmlElement) { |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $attributes = $this->attributes(); |
| 184 | 184 | |
| 185 | 185 | $result = "<{$this->fullName}"; |
| 186 | - $result .= ' ' . implode(' ', array_map(function ($key, $value) { |
|
| 186 | + $result .= ' ' . implode(' ', array_map(function($key, $value) { |
|
| 187 | 187 | return $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"'; |
| 188 | 188 | }, array_keys($attributes), array_values($attributes))); |
| 189 | 189 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function lookupPrefix(string $uri = null) |
| 206 | 206 | { |
| 207 | - return $this->getNamespaces()[ $uri ] ?? array_search($uri, XmlParser::$predefined) ?: false; |
|
| 207 | + return $this->getNamespaces()[$uri] ?? array_search($uri, XmlParser::$predefined) ?: false; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -248,12 +248,12 @@ discard block |
||
| 248 | 248 | { |
| 249 | 249 | $attribute = $this->_prefix($attribute, $uri); |
| 250 | 250 | if ($value === null) { |
| 251 | - unset($this->_attributes[ $attribute ]); |
|
| 251 | + unset($this->_attributes[$attribute]); |
|
| 252 | 252 | |
| 253 | 253 | return; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - $this->_attributes[ $attribute ] = $value; |
|
| 256 | + $this->_attributes[$attribute] = $value; |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | */ |
| 266 | 266 | public function getAttribute(string $attribute, string $uri = null) |
| 267 | 267 | { |
| 268 | - return $this->_attributes[ $this->_prefix($attribute, $uri) ] ?? false; |
|
| 268 | + return $this->_attributes[$this->_prefix($attribute, $uri)] ?? false; |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | public function hasAttribute(string $attribute, string $uri = null) |
| 280 | 280 | { |
| 281 | - return isset($this->_attributes[ $this->_prefix($attribute, $uri) ]); |
|
| 281 | + return isset($this->_attributes[$this->_prefix($attribute, $uri)]); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | public function getParents() |
| 289 | 289 | { |
| 290 | - return $this->_parent ? array_merge([ $this->_parent ], $this->_parent->getParents()) : []; |
|
| 290 | + return $this->_parent ? array_merge([$this->_parent], $this->_parent->getParents()) : []; |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | protected function setParent(XmlElement $parent) |
| 307 | 307 | { |
| 308 | 308 | if (!$this->_prefix && ($prefix = $parent->lookupPrefix($this->namespace)) !== false) { |
| 309 | - $this->_namespaces[ $this->namespace ] = $prefix; |
|
| 309 | + $this->_namespaces[$this->namespace] = $prefix; |
|
| 310 | 310 | $this->_prefix = $prefix; |
| 311 | 311 | } |
| 312 | 312 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | return false; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if(is_array($element)) { |
|
| 332 | + if (is_array($element)) { |
|
| 333 | 333 | array_walk($element, [$this, 'appendChild']); |
| 334 | 334 | return $element; |
| 335 | 335 | } |
@@ -339,14 +339,14 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | public function remove($element) |
| 341 | 341 | { |
| 342 | - if(!$element instanceof \Closure) { |
|
| 342 | + if (!$element instanceof \Closure) { |
|
| 343 | 343 | $element = is_array($element) ? filter\in($element) : filter\same($element); |
| 344 | 344 | } |
| 345 | 345 | $old = $this->_children; |
| 346 | 346 | $this->_children = array_filter($this->_children, not($element)); |
| 347 | 347 | |
| 348 | 348 | foreach (array_diff($old, $this->_children) as $removed) { |
| 349 | - if($removed instanceof XmlElement) { |
|
| 349 | + if ($removed instanceof XmlElement) { |
|
| 350 | 350 | $removed->_parent = null; |
| 351 | 351 | } |
| 352 | 352 | } |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | $prefix = $this->_prefix; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - $this->_namespaces[ $uri ] = $prefix; |
|
| 400 | + $this->_namespaces[$uri] = $prefix; |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | public function getFullName() |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | */ |
| 446 | 446 | public function element(string $name, string $uri = null, int $index = 0) |
| 447 | 447 | { |
| 448 | - return array_values($this->elements($name, $uri))[ $index ] ?? false; |
|
| 448 | + return array_values($this->elements($name, $uri))[$index] ?? false; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | /** |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | private function attributes(): array |
| 527 | 527 | { |
| 528 | 528 | $namespaces = $this->getNamespaces(false); |
| 529 | - $namespaces = array_map(function ($prefix, $uri) { |
|
| 529 | + $namespaces = array_map(function($prefix, $uri) { |
|
| 530 | 530 | return [$prefix ? "xmlns:{$prefix}" : 'xmlns', $uri]; |
| 531 | 531 | }, array_values($namespaces), array_keys($namespaces)); |
| 532 | 532 | |
@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | xml_parser_set_option($this->_parser, XML_OPTION_SKIP_WHITE, 1); |
| 77 | 77 | xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, 0); |
| 78 | 78 | |
| 79 | - xml_set_element_handler($this->_parser, function ($parser, $name, $attrs) { |
|
| 79 | + xml_set_element_handler($this->_parser, function($parser, $name, $attrs) { |
|
| 80 | 80 | $this->handleElementStart($name, $attrs); |
| 81 | - }, function () { |
|
| 81 | + }, function() { |
|
| 82 | 82 | $this->handleElementEnd(); |
| 83 | 83 | }); |
| 84 | 84 | |
| 85 | - xml_set_character_data_handler($this->_parser, function ($parser, $data) { |
|
| 85 | + xml_set_character_data_handler($this->_parser, function($parser, $data) { |
|
| 86 | 86 | $this->handleTextData($data); |
| 87 | 87 | }); |
| 88 | 88 | |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | private function _lookup($prefix, $namespaces) |
| 114 | 114 | { |
| 115 | - if(isset(static::$predefined[$prefix])) { |
|
| 115 | + if (isset(static::$predefined[$prefix])) { |
|
| 116 | 116 | return static::$predefined[$prefix]; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if (isset($namespaces[ $prefix ])) { |
|
| 120 | - return $namespaces[ $prefix ]; |
|
| 119 | + if (isset($namespaces[$prefix])) { |
|
| 120 | + return $namespaces[$prefix]; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | return !empty($this->_stack) ? end($this->_stack)->lookupUri($prefix) : null; |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | list($attributes, $namespaces) = $this->_attributes($attrs); |
| 129 | 129 | list($tag, $prefix) = XmlElement::resolve($name); |
| 130 | 130 | |
| 131 | - $uri = $this->_lookup($prefix, $namespaces); |
|
| 131 | + $uri = $this->_lookup($prefix, $namespaces); |
|
| 132 | 132 | |
| 133 | 133 | /** @var XmlElement $element */ |
| 134 | - $element = $this->factory->create($uri, $tag, [ $name, $uri ], $this->_getCollocations()); |
|
| 134 | + $element = $this->factory->create($uri, $tag, [$name, $uri], $this->_getCollocations()); |
|
| 135 | 135 | |
| 136 | 136 | foreach ($namespaces as $prefix => $uri) { |
| 137 | 137 | $element->setNamespace($uri, $prefix); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | private function _getCollocations() |
| 147 | 147 | { |
| 148 | - if(empty($this->_stack)) { |
|
| 148 | + if (empty($this->_stack)) { |
|
| 149 | 149 | return []; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | if (count($this->_stack) > 0) { |
| 165 | 165 | end($this->_stack)->append($element); |
| 166 | 166 | } |
| 167 | - $this->emit('parse.begin', [ $element, count($this->_stack) ]); |
|
| 167 | + $this->emit('parse.begin', [$element, count($this->_stack)]); |
|
| 168 | 168 | |
| 169 | 169 | $this->_stack[] = $element; |
| 170 | 170 | } |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | $element = array_pop($this->_stack); |
| 179 | 179 | if (count($this->_stack) == 1) { |
| 180 | - $this->emit('element', [ $element, count($this->_stack) ]); |
|
| 180 | + $this->emit('element', [$element, count($this->_stack)]); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - $this->emit('parse.end', [ $element, count($this->_stack) ]); |
|
| 183 | + $this->emit('parse.end', [$element, count($this->_stack)]); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | private function handleTextData($data) |