@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | public function find($needle) { |
| 32 | 32 | foreach (array_reverse($this->stack, true) as $id => $name) { |
| 33 | - if($name === $needle) { |
|
| 33 | + if ($name === $needle) { |
|
| 34 | 34 | return $id; |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function __construct(Jid $jid, $password, AbstractConnector $connector = null) |
| 206 | 206 | { |
| 207 | - if(!$connector) |
|
| 207 | + if (!$connector) |
|
| 208 | 208 | $connector = new TcpConnector($jid->server); |
| 209 | 209 | |
| 210 | 210 | $this->connector = $connector; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | 'wrap' => 0 |
| 260 | 260 | ]; |
| 261 | 261 | |
| 262 | - $this->connector->onSend->add(function ($socket, $packet) use ($settings) { |
|
| 262 | + $this->connector->onSend->add(function($socket, $packet) use ($settings) { |
|
| 263 | 263 | $len = strlen($packet); |
| 264 | 264 | |
| 265 | 265 | if (function_exists('tidy_repair_string')) |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | ]); |
| 273 | 273 | }); |
| 274 | 274 | |
| 275 | - $this->connector->onReceive->add(function ($socket, $packet) use ($settings) { |
|
| 275 | + $this->connector->onReceive->add(function($socket, $packet) use ($settings) { |
|
| 276 | 276 | $len = strlen($packet); |
| 277 | 277 | |
| 278 | 278 | if (function_exists('tidy_repair_string')) |
@@ -337,11 +337,11 @@ discard block |
||
| 337 | 337 | $start = time(); |
| 338 | 338 | $packet = null; |
| 339 | 339 | |
| 340 | - $this->wait($type, $id, function ($pckt) use (&$packet) { |
|
| 340 | + $this->wait($type, $id, function($pckt) use (&$packet) { |
|
| 341 | 341 | $packet = $pckt; |
| 342 | 342 | }); |
| 343 | 343 | |
| 344 | - while(!$packet && time() - $start < $timeout) { |
|
| 344 | + while (!$packet && time() - $start < $timeout) { |
|
| 345 | 345 | $this->process(); |
| 346 | 346 | usleep(5000); |
| 347 | 347 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | { |
| 392 | 392 | if ($this->logger) |
| 393 | 393 | $this->logger->notice('SASL Auth, available mechanisms: {mechanisms}', [ |
| 394 | - 'mechanisms' => implode(', ', array_map(function (XmlBranch $item) { |
|
| 394 | + 'mechanisms' => implode(', ', array_map(function(XmlBranch $item) { |
|
| 395 | 395 | return $item->content; |
| 396 | 396 | }, (array)$this->connector->features->mechanisms[0]->mechanism)) |
| 397 | 397 | ]); |
@@ -741,8 +741,7 @@ discard block |
||
| 741 | 741 | if (!$user->fromChannel()) return null; |
| 742 | 742 | |
| 743 | 743 | return isset($this->rooms[$user->bare()]->users[$user->resource]) ? |
| 744 | - $this->rooms[$user->bare()]->users[$user->resource] : |
|
| 745 | - null; |
|
| 744 | + $this->rooms[$user->bare()]->users[$user->resource] : null; |
|
| 746 | 745 | } |
| 747 | 746 | |
| 748 | 747 | /** |
@@ -823,7 +822,7 @@ discard block |
||
| 823 | 822 | |
| 824 | 823 | $xml = new xmlBranch("presence"); |
| 825 | 824 | $xml->addAttribute("from", $this->jid->__toString()) |
| 826 | - ->addAttribute("to", $room->bare() . '/' . $nick) |
|
| 825 | + ->addAttribute("to", $room->bare().'/'.$nick) |
|
| 827 | 826 | ->addAttribute("id", uniqid('mucjoin_')); |
| 828 | 827 | $xml->addChild(new xmlBranch("x"))->addAttribute("xmlns", "http://jabber.org/protocol/muc"); |
| 829 | 828 | $this->write($xml->asXml()); |
@@ -1009,7 +1008,7 @@ discard block |
||
| 1009 | 1008 | } |
| 1010 | 1009 | |
| 1011 | 1010 | public function __destruct() { |
| 1012 | - if($this->connector->connected) |
|
| 1011 | + if ($this->connector->connected) |
|
| 1013 | 1012 | $this->disconnect(); |
| 1014 | 1013 | } |
| 1015 | 1014 | } |
| 1016 | 1015 | \ No newline at end of file |
@@ -204,8 +204,9 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function __construct(Jid $jid, $password, AbstractConnector $connector = null) |
| 206 | 206 | { |
| 207 | - if(!$connector) |
|
| 208 | - $connector = new TcpConnector($jid->server); |
|
| 207 | + if(!$connector) { |
|
| 208 | + $connector = new TcpConnector($jid->server); |
|
| 209 | + } |
|
| 209 | 210 | |
| 210 | 211 | $this->connector = $connector; |
| 211 | 212 | $this->connector->client = $this; |
@@ -262,27 +263,31 @@ discard block |
||
| 262 | 263 | $this->connector->onSend->add(function ($socket, $packet) use ($settings) { |
| 263 | 264 | $len = strlen($packet); |
| 264 | 265 | |
| 265 | - if (function_exists('tidy_repair_string')) |
|
| 266 | - $packet = trim(tidy_repair_string($packet, $settings)); |
|
| 266 | + if (function_exists('tidy_repair_string')) { |
|
| 267 | + $packet = trim(tidy_repair_string($packet, $settings)); |
|
| 268 | + } |
|
| 267 | 269 | |
| 268 | - if (isset($this->logger)) |
|
| 269 | - $this->logger->debug("Sent {length} bytes: \n{packet}", [ |
|
| 270 | + if (isset($this->logger)) { |
|
| 271 | + $this->logger->debug("Sent {length} bytes: \n{packet}", [ |
|
| 270 | 272 | 'length' => $len, |
| 271 | 273 | 'packet' => $packet |
| 272 | 274 | ]); |
| 275 | + } |
|
| 273 | 276 | }); |
| 274 | 277 | |
| 275 | 278 | $this->connector->onReceive->add(function ($socket, $packet) use ($settings) { |
| 276 | 279 | $len = strlen($packet); |
| 277 | 280 | |
| 278 | - if (function_exists('tidy_repair_string')) |
|
| 279 | - $packet = trim(tidy_repair_string($packet, $settings)); |
|
| 281 | + if (function_exists('tidy_repair_string')) { |
|
| 282 | + $packet = trim(tidy_repair_string($packet, $settings)); |
|
| 283 | + } |
|
| 280 | 284 | |
| 281 | - if (isset($this->logger)) |
|
| 282 | - $this->logger->debug("Received {length} bytes: \n{packet}", [ |
|
| 285 | + if (isset($this->logger)) { |
|
| 286 | + $this->logger->debug("Received {length} bytes: \n{packet}", [ |
|
| 283 | 287 | 'length' => $len, |
| 284 | 288 | 'packet' => $packet |
| 285 | 289 | ]); |
| 290 | + } |
|
| 286 | 291 | }); |
| 287 | 292 | |
| 288 | 293 | XmlBranch::$bind['iq'] = 'Kadet\\Xmpp\\Stanza\\Iq'; |
@@ -375,7 +380,9 @@ discard block |
||
| 375 | 380 | |
| 376 | 381 | private function startTls() |
| 377 | 382 | { |
| 378 | - if ($this->logger) $this->logger->notice('Starting TLS negotiation.'); |
|
| 383 | + if ($this->logger) { |
|
| 384 | + $this->logger->notice('Starting TLS negotiation.'); |
|
| 385 | + } |
|
| 379 | 386 | |
| 380 | 387 | $xml = new XmlBranch('starttls'); |
| 381 | 388 | $xml->addAttribute('xmlns', 'urn:ietf:params:xml:ns:xmpp-tls'); |
@@ -389,10 +396,11 @@ discard block |
||
| 389 | 396 | */ |
| 390 | 397 | private function auth() |
| 391 | 398 | { |
| 392 | - if ($this->logger) |
|
| 393 | - $this->logger->notice('SASL Auth, available mechanisms: {mechanisms}', [ |
|
| 399 | + if ($this->logger) { |
|
| 400 | + $this->logger->notice('SASL Auth, available mechanisms: {mechanisms}', [ |
|
| 394 | 401 | 'mechanisms' => implode(', ', array_map(function (XmlBranch $item) { |
| 395 | 402 | return $item->content; |
| 403 | + } |
|
| 396 | 404 | }, (array)$this->connector->features->mechanisms[0]->mechanism)) |
| 397 | 405 | ]); |
| 398 | 406 | |
@@ -402,15 +410,18 @@ discard block |
||
| 402 | 410 | $mechanism = null; |
| 403 | 411 | $this->connector->features->mechanisms[0]->mechanism->getIterator(); |
| 404 | 412 | foreach ($this->connector->features->mechanisms[0]->mechanism as $current) { |
| 405 | - if ($mechanism = SaslFactory::get($current->content, $this->jid, $this->password)) |
|
| 406 | - break; |
|
| 413 | + if ($mechanism = SaslFactory::get($current->content, $this->jid, $this->password)) { |
|
| 414 | + break; |
|
| 415 | + } |
|
| 407 | 416 | } |
| 408 | 417 | |
| 409 | - if (!$mechanism) |
|
| 410 | - throw new \RuntimeException('This client is not supporting any of server auth mechanisms.'); |
|
| 418 | + if (!$mechanism) { |
|
| 419 | + throw new \RuntimeException('This client is not supporting any of server auth mechanisms.'); |
|
| 420 | + } |
|
| 411 | 421 | |
| 412 | - if ($this->logger) |
|
| 413 | - $this->logger->notice('Chosen mechanism: {mechanism}', ['mechanism' => $current->content]); |
|
| 422 | + if ($this->logger) { |
|
| 423 | + $this->logger->notice('Chosen mechanism: {mechanism}', ['mechanism' => $current->content]); |
|
| 424 | + } |
|
| 414 | 425 | |
| 415 | 426 | $this->_mechanism = $mechanism; |
| 416 | 427 | |
@@ -433,13 +444,15 @@ discard block |
||
| 433 | 444 | public function _onAuth(XmppClient $client, Stanza $result) |
| 434 | 445 | { |
| 435 | 446 | if ($result->xml->getName() == 'success') { |
| 436 | - if ($this->logger) |
|
| 437 | - $this->logger->info('SASL Auth successful.'); |
|
| 447 | + if ($this->logger) { |
|
| 448 | + $this->logger->info('SASL Auth successful.'); |
|
| 449 | + } |
|
| 438 | 450 | |
| 439 | 451 | $this->connector->streamRestart($this->jid); |
| 440 | 452 | $this->_bind(); |
| 441 | - } elseif ($this->logger) |
|
| 442 | - $this->logger->error('SASL Auth failed, reason: {reason}', ['reason' => $result->text[0]]); |
|
| 453 | + } elseif ($this->logger) { |
|
| 454 | + $this->logger->error('SASL Auth failed, reason: {reason}', ['reason' => $result->text[0]]); |
|
| 455 | + } |
|
| 443 | 456 | } |
| 444 | 457 | |
| 445 | 458 | /** |
@@ -476,13 +489,15 @@ discard block |
||
| 476 | 489 | public function _onTls(XmppClient $client, Stanza $result) |
| 477 | 490 | { |
| 478 | 491 | if ($result->tag == 'proceed') { |
| 479 | - if ($this->logger) |
|
| 480 | - $this->logger->info('TLS Connection established.'); |
|
| 492 | + if ($this->logger) { |
|
| 493 | + $this->logger->info('TLS Connection established.'); |
|
| 494 | + } |
|
| 481 | 495 | |
| 482 | 496 | $this->connector->startTls(); |
| 483 | 497 | $this->connector->streamRestart($this->jid); |
| 484 | - } else |
|
| 485 | - throw new \RuntimeException('Tls negotiation failed.'); |
|
| 498 | + } else { |
|
| 499 | + throw new \RuntimeException('Tls negotiation failed.'); |
|
| 500 | + } |
|
| 486 | 501 | } |
| 487 | 502 | |
| 488 | 503 | /** |
@@ -504,8 +519,9 @@ discard block |
||
| 504 | 519 | $this->write($iq->asXml()); |
| 505 | 520 | $this->isReady = true; |
| 506 | 521 | $this->onReady->run($this); |
| 507 | - } else |
|
| 508 | - throw new \RuntimeException('Resource binding error.'); |
|
| 522 | + } else { |
|
| 523 | + throw new \RuntimeException('Resource binding error.'); |
|
| 524 | + } |
|
| 509 | 525 | } |
| 510 | 526 | |
| 511 | 527 | /** |
@@ -593,10 +609,11 @@ discard block |
||
| 593 | 609 | case 'success': |
| 594 | 610 | case 'failure': |
| 595 | 611 | case 'proceed': |
| 596 | - if ($stanza['xmlns'] == 'urn:ietf:params:xml:ns:xmpp-sasl') |
|
| 597 | - $this->onAuth->run($this, $stanza); |
|
| 598 | - elseif ($stanza['xmlns'] == 'urn:ietf:params:xml:ns:xmpp-tls') |
|
| 599 | - $this->onTls->run($this, $stanza); |
|
| 612 | + if ($stanza['xmlns'] == 'urn:ietf:params:xml:ns:xmpp-sasl') { |
|
| 613 | + $this->onAuth->run($this, $stanza); |
|
| 614 | + } elseif ($stanza['xmlns'] == 'urn:ietf:params:xml:ns:xmpp-tls') { |
|
| 615 | + $this->onTls->run($this, $stanza); |
|
| 616 | + } |
|
| 600 | 617 | |
| 601 | 618 | break; |
| 602 | 619 | case 'challenge': |
@@ -635,7 +652,9 @@ discard block |
||
| 635 | 652 | $channelJid = $packet->from->bare(); |
| 636 | 653 | $jid = new Jid($channelJid); |
| 637 | 654 | |
| 638 | - if (!$jid->isChannel()) return; |
|
| 655 | + if (!$jid->isChannel()) { |
|
| 656 | + return; |
|
| 657 | + } |
|
| 639 | 658 | |
| 640 | 659 | if ($packet->type != 'unavailable') { |
| 641 | 660 | if (isset($this->rooms[$channelJid]->users[$packet->from->resource])) { |
@@ -645,7 +664,9 @@ discard block |
||
| 645 | 664 | if ( |
| 646 | 665 | (string)$user->jid == (string)$this->jid || |
| 647 | 666 | $this->rooms[$channelJid]->nick == $packet->from->resource |
| 648 | - ) $user->self = true; |
|
| 667 | + ) { |
|
| 668 | + $user->self = true; |
|
| 669 | + } |
|
| 649 | 670 | |
| 650 | 671 | $this->onJoin->run( |
| 651 | 672 | $this, |
@@ -659,7 +680,9 @@ discard block |
||
| 659 | 680 | } elseif (isset($this->rooms[$channelJid])) { |
| 660 | 681 | $item = $packet->xpath('//user:item', ['user' => 'http://jabber.org/protocol/muc#user']); |
| 661 | 682 | |
| 662 | - if (!isset($item[0])) return; |
|
| 683 | + if (!isset($item[0])) { |
|
| 684 | + return; |
|
| 685 | + } |
|
| 663 | 686 | $item = $item[0]; |
| 664 | 687 | |
| 665 | 688 | // Nickname change |
@@ -700,13 +723,18 @@ discard block |
||
| 700 | 723 | */ |
| 701 | 724 | public function _onMessage(XmppClient $client, Message $packet) |
| 702 | 725 | { |
| 703 | - if ($packet->type != 'groupchat' || !isset($this->rooms[$packet->from->bare()])) return; |
|
| 726 | + if ($packet->type != 'groupchat' || !isset($this->rooms[$packet->from->bare()])) { |
|
| 727 | + return; |
|
| 728 | + } |
|
| 704 | 729 | |
| 705 | - if (isset($packet->subject)) |
|
| 706 | - $this->rooms[$packet->from->bare()]->subject = $packet->subject; |
|
| 730 | + if (isset($packet->subject)) { |
|
| 731 | + $this->rooms[$packet->from->bare()]->subject = $packet->subject; |
|
| 732 | + } |
|
| 707 | 733 | |
| 708 | - if (!isset($packet->delay) && $this->rooms[$packet->from->bare()]->subject === false) |
|
| 709 | - $this->rooms[$packet->from->bare()]->subject = ''; // Some strange workaround, servers doesn't meet specification... ;( |
|
| 734 | + if (!isset($packet->delay) && $this->rooms[$packet->from->bare()]->subject === false) { |
|
| 735 | + $this->rooms[$packet->from->bare()]->subject = ''; |
|
| 736 | + } |
|
| 737 | + // Some strange workaround, servers doesn't meet specification... ;( |
|
| 710 | 738 | } |
| 711 | 739 | |
| 712 | 740 | /** |
@@ -714,8 +742,9 @@ discard block |
||
| 714 | 742 | */ |
| 715 | 743 | public function process() |
| 716 | 744 | { |
| 717 | - if ($this->isReady) |
|
| 718 | - $this->onTick->run($this); |
|
| 745 | + if ($this->isReady) { |
|
| 746 | + $this->onTick->run($this); |
|
| 747 | + } |
|
| 719 | 748 | |
| 720 | 749 | Timer::update(); |
| 721 | 750 | $this->connector->read(); |
@@ -738,7 +767,9 @@ discard block |
||
| 738 | 767 | */ |
| 739 | 768 | public function getUserByJid(Jid $user) |
| 740 | 769 | { |
| 741 | - if (!$user->fromChannel()) return null; |
|
| 770 | + if (!$user->fromChannel()) { |
|
| 771 | + return null; |
|
| 772 | + } |
|
| 742 | 773 | |
| 743 | 774 | return isset($this->rooms[$user->bare()]->users[$user->resource]) ? |
| 744 | 775 | $this->rooms[$user->bare()]->users[$user->resource] : |
@@ -819,7 +850,10 @@ discard block |
||
| 819 | 850 | */ |
| 820 | 851 | public function join(Jid $room, $nick) |
| 821 | 852 | { |
| 822 | - if (!$room->isChannel()) throw new \InvalidArgumentException('room'); // YOU SHALL NOT PASS |
|
| 853 | + if (!$room->isChannel()) { |
|
| 854 | + throw new \InvalidArgumentException('room'); |
|
| 855 | + } |
|
| 856 | + // YOU SHALL NOT PASS |
|
| 823 | 857 | |
| 824 | 858 | $xml = new xmlBranch("presence"); |
| 825 | 859 | $xml->addAttribute("from", $this->jid->__toString()) |
@@ -845,7 +879,9 @@ discard block |
||
| 845 | 879 | */ |
| 846 | 880 | public function leave(Jid $room) |
| 847 | 881 | { |
| 848 | - if (!$room->isChannel() || !isset($this->rooms[$room->bare()])) throw new \InvalidArgumentException('room'); |
|
| 882 | + if (!$room->isChannel() || !isset($this->rooms[$room->bare()])) { |
|
| 883 | + throw new \InvalidArgumentException('room'); |
|
| 884 | + } |
|
| 849 | 885 | |
| 850 | 886 | $xml = new xmlBranch("presence"); |
| 851 | 887 | $xml->addAttribute("from", $this->jid->__toString()) |
@@ -875,8 +911,9 @@ discard block |
||
| 875 | 911 | */ |
| 876 | 912 | public function role(Jid $room, $nick, $role, $reason = '') |
| 877 | 913 | { |
| 878 | - if (!in_array($role, array('visitor', 'none', 'participant', 'moderator'))) |
|
| 879 | - throw new \InvalidArgumentException('role'); |
|
| 914 | + if (!in_array($role, array('visitor', 'none', 'participant', 'moderator'))) { |
|
| 915 | + throw new \InvalidArgumentException('role'); |
|
| 916 | + } |
|
| 880 | 917 | |
| 881 | 918 | $xml = new xmlBranch("iq"); |
| 882 | 919 | $xml->addAttribute("type", "set") |
@@ -889,7 +926,9 @@ discard block |
||
| 889 | 926 | $xml->query[0]->item[0]->addAttribute("nick", $nick); |
| 890 | 927 | $xml->query[0]->item[0]->addAttribute("role", $role); |
| 891 | 928 | |
| 892 | - if (!empty($reason)) $xml->query[0]->item[0]->addChild(new xmlBranch("reason"))->setContent($reason); |
|
| 929 | + if (!empty($reason)) { |
|
| 930 | + $xml->query[0]->item[0]->addChild(new xmlBranch("reason"))->setContent($reason); |
|
| 931 | + } |
|
| 893 | 932 | |
| 894 | 933 | $this->write($xml->asXml()); |
| 895 | 934 | } |
@@ -909,8 +948,9 @@ discard block |
||
| 909 | 948 | */ |
| 910 | 949 | public function affiliate(Jid $room, Jid $user, $affiliation, $reason = '') |
| 911 | 950 | { |
| 912 | - if (!in_array($affiliation, array('none', 'outcast', 'member', 'admin', 'owner'))) |
|
| 913 | - throw new \InvalidArgumentException('affiliation'); |
|
| 951 | + if (!in_array($affiliation, array('none', 'outcast', 'member', 'admin', 'owner'))) { |
|
| 952 | + throw new \InvalidArgumentException('affiliation'); |
|
| 953 | + } |
|
| 914 | 954 | |
| 915 | 955 | $xml = new xmlBranch("iq"); |
| 916 | 956 | $xml->addAttribute("type", "set") |
@@ -923,7 +963,9 @@ discard block |
||
| 923 | 963 | $xml->query[0]->item[0]->addAttribute("jid", $user->bare()); |
| 924 | 964 | $xml->query[0]->item[0]->addAttribute("affiliation", $affiliation); |
| 925 | 965 | |
| 926 | - if (!empty($reason)) $xml->query[0]->item[0]->addChild(new xmlBranch("reason"))->setContent($reason); |
|
| 966 | + if (!empty($reason)) { |
|
| 967 | + $xml->query[0]->item[0]->addChild(new xmlBranch("reason"))->setContent($reason); |
|
| 968 | + } |
|
| 927 | 969 | |
| 928 | 970 | $this->write($xml->asXml()); |
| 929 | 971 | } |
@@ -960,8 +1002,9 @@ discard block |
||
| 960 | 1002 | */ |
| 961 | 1003 | public function affiliationList(Jid $room, $affiliation, callable $delegate) |
| 962 | 1004 | { |
| 963 | - if (!in_array($affiliation, array('none', 'outcast', 'member', 'admin', 'owner'))) |
|
| 964 | - throw new \InvalidArgumentException('affiliation'); |
|
| 1005 | + if (!in_array($affiliation, array('none', 'outcast', 'member', 'admin', 'owner'))) { |
|
| 1006 | + throw new \InvalidArgumentException('affiliation'); |
|
| 1007 | + } |
|
| 965 | 1008 | |
| 966 | 1009 | $xml = new xmlBranch("iq"); |
| 967 | 1010 | $id = uniqid('affiliate_'); |
@@ -1009,7 +1052,8 @@ discard block |
||
| 1009 | 1052 | } |
| 1010 | 1053 | |
| 1011 | 1054 | public function __destruct() { |
| 1012 | - if($this->connector->connected) |
|
| 1013 | - $this->disconnect(); |
|
| 1055 | + if($this->connector->connected) { |
|
| 1056 | + $this->disconnect(); |
|
| 1057 | + } |
|
| 1014 | 1058 | } |
| 1015 | 1059 | } |
| 1016 | 1060 | \ No newline at end of file |
@@ -148,17 +148,17 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | $this->applyOptions($options); |
| 150 | 150 | |
| 151 | - $this->on('element', function (Features $element) { |
|
| 151 | + $this->on('element', function(Features $element) { |
|
| 152 | 152 | $this->_features = $element; |
| 153 | 153 | $this->emit('features', [$element]); |
| 154 | 154 | }, Features::class); |
| 155 | 155 | |
| 156 | - $this->on('element', function (Stanza $stanza) { |
|
| 157 | - $this->emit('stanza', [ $stanza ]); |
|
| 158 | - $this->emit($stanza->localName, [ $stanza ]); |
|
| 156 | + $this->on('element', function(Stanza $stanza) { |
|
| 157 | + $this->emit('stanza', [$stanza]); |
|
| 158 | + $this->emit($stanza->localName, [$stanza]); |
|
| 159 | 159 | }, Stanza::class); |
| 160 | 160 | |
| 161 | - $this->on('close', function () { |
|
| 161 | + $this->on('close', function() { |
|
| 162 | 162 | $this->state = 'disconnected'; |
| 163 | 163 | }); |
| 164 | 164 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $this->state = 'bound'; |
| 212 | 212 | |
| 213 | 213 | $queue = new \SplQueue(); |
| 214 | - $this->emit('init', [ $queue ]); |
|
| 214 | + $this->emit('init', [$queue]); |
|
| 215 | 215 | |
| 216 | 216 | \React\Promise\all(iterator_to_array($queue))->then(function() { |
| 217 | 217 | $this->state = 'ready'; |
@@ -235,10 +235,10 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | if ($alias === true) { |
| 237 | 237 | $this->_addToContainer($module, array_merge(class_implements($module), array_slice(class_parents($module), 1))); |
| 238 | - } elseif(is_array($alias)) { |
|
| 238 | + } elseif (is_array($alias)) { |
|
| 239 | 239 | $this->_addToContainer($module, $alias); |
| 240 | 240 | } else { |
| 241 | - $this->_addToContainer($module, [ $alias === false ? get_class($module) : $alias ]); |
|
| 241 | + $this->_addToContainer($module, [$alias === false ? get_class($module) : $alias]); |
|
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | $deferred = new Deferred(); |
| 262 | 262 | |
| 263 | 263 | $this->once('element', function(Stanza $stanza) use ($deferred) { |
| 264 | - if($stanza->type === "error") { |
|
| 264 | + if ($stanza->type === "error") { |
|
| 265 | 265 | $deferred->reject($stanza); |
| 266 | 266 | } else { |
| 267 | 267 | $deferred->resolve($stanza); |
@@ -297,12 +297,12 @@ discard block |
||
| 297 | 297 | //region Parser |
| 298 | 298 | public function setParser(XmlParser $parser) |
| 299 | 299 | { |
| 300 | - if($this->state !== "disconnected") { |
|
| 300 | + if ($this->state !== "disconnected") { |
|
| 301 | 301 | throw new \BadMethodCallException('Parser can be changed only when client is disconnected.'); |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | parent::setParser($parser); |
| 305 | - $this->_parser->factory->load(require __DIR__ . '/XmlElementLookup.php'); |
|
| 305 | + $this->_parser->factory->load(require __DIR__.'/XmlElementLookup.php'); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | public function getParser() |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | )); |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - $this->_connector->on('connect', function ($stream) { |
|
| 328 | + $this->_connector->on('connect', function($stream) { |
|
| 329 | 329 | return $this->handleConnect($stream); |
| 330 | 330 | }); |
| 331 | 331 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | ->disableOriginalConstructor() |
| 51 | 51 | ->getMock(); |
| 52 | 52 | |
| 53 | - $factory = $this |
|
| 53 | + $factory = $this |
|
| 54 | 54 | ->getMockBuilder('Kadet\Highlighter\Parser\TokenFactory') |
| 55 | 55 | ->disableOriginalConstructor() |
| 56 | 56 | ->getMock(); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | public function testAcceptsCallableAsContext() |
| 79 | 79 | { |
| 80 | 80 | $rule = new Rule(null, [ |
| 81 | - 'context' => function () { |
|
| 81 | + 'context' => function() { |
|
| 82 | 82 | return true; |
| 83 | 83 | } |
| 84 | 84 | ]); |
@@ -114,7 +114,7 @@ |
||
| 114 | 114 | |
| 115 | 115 | public function testCallableValidator() |
| 116 | 116 | { |
| 117 | - $validator = new DelegateValidator(function ($context) { |
|
| 117 | + $validator = new DelegateValidator(function($context) { |
|
| 118 | 118 | return in_array('bar', $context->stack) && !in_array('foo', $context->stack); |
| 119 | 119 | }); |
| 120 | 120 | |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function testFileProvider() |
| 21 | 21 | { |
| 22 | - $dir = realpath(__DIR__ . '/Samples'); |
|
| 23 | - $out = realpath(__DIR__ . '/Expected/Test'); |
|
| 22 | + $dir = realpath(__DIR__.'/Samples'); |
|
| 23 | + $out = realpath(__DIR__.'/Expected/Test'); |
|
| 24 | 24 | |
| 25 | 25 | $iterator = new \RecursiveIteratorIterator( |
| 26 | 26 | new \RecursiveDirectoryIterator( |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $pathname = substr($file->getPathname(), strlen($dir) + 1); |
| 36 | 36 | $language = Language::byFilename($pathname); |
| 37 | 37 | |
| 38 | - yield $pathname => [ $language, $file->getPathname(), "$out/$pathname.tkn" ]; |
|
| 38 | + yield $pathname => [$language, $file->getPathname(), "$out/$pathname.tkn"]; |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
@@ -56,8 +56,8 @@ |
||
| 56 | 56 | ]); |
| 57 | 57 | |
| 58 | 58 | $formatter = new CliFormatter(['styles' => [ |
| 59 | - 'token' => ['color' => 'red'], |
|
| 60 | - 'operator' => ['color' => 'blue'], |
|
| 59 | + 'token' => ['color' => 'red'], |
|
| 60 | + 'operator' => ['color' => 'blue'], |
|
| 61 | 61 | ]]); |
| 62 | 62 | $this->assertEquals($expected, $formatter->format($iterator)); |
| 63 | 63 | } |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | public function testRendering() |
| 41 | 41 | { |
| 42 | 42 | $source = 'abc + test'; |
| 43 | - $expected = Console::open(['color' => 'red']) . 'abc' . Console::close() . ' ' . |
|
| 44 | - Console::open(['color' => 'blue']) . '+' . Console::close() . ' ' . |
|
| 45 | - Console::open(['color' => 'red']) . 'test' . Console::close() . Console::reset(); |
|
| 43 | + $expected = Console::open(['color' => 'red']).'abc'.Console::close().' '. |
|
| 44 | + Console::open(['color' => 'blue']).'+'.Console::close().' '. |
|
| 45 | + Console::open(['color' => 'red']).'test'.Console::close().Console::reset(); |
|
| 46 | 46 | |
| 47 | 47 | $first = $this->_factory->create('token', ['pos' => 0, 'length' => 3]); |
| 48 | 48 | $operator = $this->_factory->create('operator', ['pos' => 4, 'length' => 1]); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $this->markTestSkipped('This test requires callback mocks, that are not yet implemented.'); |
| 68 | 68 | |
| 69 | 69 | $source = 'abc'; |
| 70 | - $expected = Console::open(['color' => 'red']) . 'abc' . Console::close() . Console::reset(); |
|
| 70 | + $expected = Console::open(['color' => 'red']).'abc'.Console::close().Console::reset(); |
|
| 71 | 71 | |
| 72 | 72 | $token = $this->_factory->create('token', ['pos' => 0, 'length' => 3]); |
| 73 | 73 | |
@@ -54,11 +54,11 @@ |
||
| 54 | 54 | 'c' => 4 |
| 55 | 55 | ]; |
| 56 | 56 | |
| 57 | - $this->assertEquals('b', ArrayHelper::find($array, function ($k, $v) { |
|
| 57 | + $this->assertEquals('b', ArrayHelper::find($array, function($k, $v) { |
|
| 58 | 58 | return $k == 'b'; |
| 59 | 59 | })); |
| 60 | 60 | |
| 61 | - $this->assertFalse(ArrayHelper::find($array, function ($k, $v) { |
|
| 61 | + $this->assertFalse(ArrayHelper::find($array, function($k, $v) { |
|
| 62 | 62 | return $k == 'b' && $v == 3; |
| 63 | 63 | })); |
| 64 | 64 | } |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | $console = new ConsoleHelper(); |
| 41 | 41 | $this->assertEquals( |
| 42 | 42 | "\e[31mtest\e[32mtest2\e[0m\e[31mtest3\e[0m", |
| 43 | - $console->open(["color" => "red"]) . |
|
| 44 | - "test" . |
|
| 45 | - $console->open(["color" => "green"]) . "test2" . $console->close() . |
|
| 46 | - "test3" . |
|
| 43 | + $console->open(["color" => "red"]). |
|
| 44 | + "test". |
|
| 45 | + $console->open(["color" => "green"])."test2".$console->close(). |
|
| 46 | + "test3". |
|
| 47 | 47 | $console->close() |
| 48 | 48 | ); |
| 49 | 49 | } |
@@ -61,18 +61,18 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | return [ |
| 63 | 63 | 'background red' => ["\033[41m", ["background" => "red"]], |
| 64 | - 'bold' => ["\033[1m", ["bold" => true]], |
|
| 65 | - 'dim' => ["\033[2m", ["dim" => true]], |
|
| 66 | - 'italic' => ["\033[3m", ["italic" => true]], |
|
| 67 | - 'underline' => ["\033[4m", ["underline" => true]], |
|
| 68 | - 'blink' => ["\033[5m", ["blink" => true]], |
|
| 69 | - 'invert' => ["\033[7m", ["invert" => true]], |
|
| 64 | + 'bold' => ["\033[1m", ["bold" => true]], |
|
| 65 | + 'dim' => ["\033[2m", ["dim" => true]], |
|
| 66 | + 'italic' => ["\033[3m", ["italic" => true]], |
|
| 67 | + 'underline' => ["\033[4m", ["underline" => true]], |
|
| 68 | + 'blink' => ["\033[5m", ["blink" => true]], |
|
| 69 | + 'invert' => ["\033[7m", ["invert" => true]], |
|
| 70 | 70 | |
| 71 | - 'wrong' => [null, ["wrong" => true]], |
|
| 71 | + 'wrong' => [null, ["wrong" => true]], |
|
| 72 | 72 | |
| 73 | - 'bg and bold' => ["\033[41;1m", ["background" => "red", 'bold' => true]], |
|
| 73 | + 'bg and bold' => ["\033[41;1m", ["background" => "red", 'bold' => true]], |
|
| 74 | 74 | |
| 75 | - 'color, bg and bold' => ["\033[31;41;1m", ["color" => "red", "background" => "red", 'bold' => true]], |
|
| 75 | + 'color, bg and bold' => ["\033[31;41;1m", ["color" => "red", "background" => "red", 'bold' => true]], |
|
| 76 | 76 | ]; |
| 77 | 77 | } |
| 78 | 78 | } |