diff --git a/src/Connection/AbstractConnection.php b/src/Connection/AbstractConnection.php index 30f79c4..d6f599e 100644 --- a/src/Connection/AbstractConnection.php +++ b/src/Connection/AbstractConnection.php @@ -84,7 +84,7 @@ abstract class AbstractConnection implements ConnectionInterface * * @var EventListenerInterface[] */ - protected $listeners = array(); + protected $listeners = []; /** * Connected. @@ -259,7 +259,7 @@ public function setOptions(Options $options) */ protected function log($message, $level = LogLevel::DEBUG) { - $this->getEventManager()->trigger('logger', $this, array($message, $level)); + $this->getEventManager()->trigger('logger', $this, [$message, $level]); } /** diff --git a/src/Connection/Socket.php b/src/Connection/Socket.php index 22e9934..a67191e 100644 --- a/src/Connection/Socket.php +++ b/src/Connection/Socket.php @@ -129,7 +129,7 @@ private function reconnectTls(TimeoutException $exception) // check if we didn't receive any data // if not we re-try to connect via TLS if (false === $this->receivedAnyData) { - $matches = array(); + $matches = []; $previousAddress = $this->getOptions()->getAddress(); // only reconnect via tls if we've used tcp before. if (preg_match('#tcp://(?
.+)#', $previousAddress, $matches)) { diff --git a/src/Event/Event.php b/src/Event/Event.php index abce6f4..ee0e498 100644 --- a/src/Event/Event.php +++ b/src/Event/Event.php @@ -66,14 +66,14 @@ class Event implements EventInterface * * @var array */ - protected $parameters = array(); + protected $parameters = []; /** * Event stack. * * @var array */ - protected $eventStack = array(); + protected $eventStack = []; /** * {@inheritDoc} diff --git a/src/Event/EventManager.php b/src/Event/EventManager.php index f8ea266..67b2c55 100644 --- a/src/Event/EventManager.php +++ b/src/Event/EventManager.php @@ -55,7 +55,7 @@ class EventManager implements EventManagerInterface * * @var array */ - protected $events = array(self::WILDCARD => array()); + protected $events = [self::WILDCARD => []]; /** * Event object. @@ -90,7 +90,7 @@ public function attach($event, $callback) } if (!isset($this->events[$event])) { - $this->events[$event] = array(); + $this->events[$event] = []; } if (!in_array($callback, $this->events[$event], true)) { @@ -107,13 +107,13 @@ public function trigger($event, $caller, array $parameters) return; } - $events = array(); + $events = []; if (!empty($this->events[$event])) { $events = $this->events[$event]; } $callbacks = array_merge($events, $this->events[self::WILDCARD]); - $previous = array(); + $previous = []; $eventObject = clone $this->getEventObject(); $eventObject->setName($event); diff --git a/src/EventListener/Logger.php b/src/EventListener/Logger.php index f914698..d68f7b2 100644 --- a/src/EventListener/Logger.php +++ b/src/EventListener/Logger.php @@ -69,6 +69,6 @@ public function event(EventInterface $event) */ public function attachEvents() { - $this->getEventManager()->attach('logger', array($this, 'event')); + $this->getEventManager()->attach('logger', [$this, 'event']); } } diff --git a/src/EventListener/Stream/Authentication.php b/src/EventListener/Stream/Authentication.php index 2934abc..33c2f25 100644 --- a/src/EventListener/Stream/Authentication.php +++ b/src/EventListener/Stream/Authentication.php @@ -63,7 +63,7 @@ class Authentication extends AbstractEventListener implements BlockingEventListe * * @var array */ - protected $mechanisms = array(); + protected $mechanisms = []; /** * {@inheritDoc} @@ -71,10 +71,10 @@ class Authentication extends AbstractEventListener implements BlockingEventListe public function attachEvents() { $input = $this->getConnection()->getInputStream()->getEventManager(); - $input->attach('{urn:ietf:params:xml:ns:xmpp-sasl}mechanisms', array($this, 'authenticate')); - $input->attach('{urn:ietf:params:xml:ns:xmpp-sasl}mechanism', array($this, 'collectMechanisms')); - $input->attach('{urn:ietf:params:xml:ns:xmpp-sasl}failure', array($this, 'failure')); - $input->attach('{urn:ietf:params:xml:ns:xmpp-sasl}success', array($this, 'success')); + $input->attach('{urn:ietf:params:xml:ns:xmpp-sasl}mechanisms', [$this, 'authenticate']); + $input->attach('{urn:ietf:params:xml:ns:xmpp-sasl}mechanism', [$this, 'collectMechanisms']); + $input->attach('{urn:ietf:params:xml:ns:xmpp-sasl}failure', [$this, 'failure']); + $input->attach('{urn:ietf:params:xml:ns:xmpp-sasl}success', [$this, 'success']); } /** diff --git a/src/EventListener/Stream/Authentication/DigestMd5.php b/src/EventListener/Stream/Authentication/DigestMd5.php index 49b43fd..ee35f0f 100644 --- a/src/EventListener/Stream/Authentication/DigestMd5.php +++ b/src/EventListener/Stream/Authentication/DigestMd5.php @@ -74,11 +74,11 @@ class DigestMd5 extends AbstractEventListener implements AuthenticationInterface public function attachEvents() { $input = $this->getInputEventManager(); - $input->attach('{urn:ietf:params:xml:ns:xmpp-sasl}challenge', array($this, 'challenge')); - $input->attach('{urn:ietf:params:xml:ns:xmpp-sasl}success', array($this, 'success')); + $input->attach('{urn:ietf:params:xml:ns:xmpp-sasl}challenge', [$this, 'challenge']); + $input->attach('{urn:ietf:params:xml:ns:xmpp-sasl}success', [$this, 'success']); $output = $this->getOutputEventManager(); - $output->attach('{urn:ietf:params:xml:ns:xmpp-sasl}auth', array($this, 'auth')); + $output->attach('{urn:ietf:params:xml:ns:xmpp-sasl}auth', [$this, 'auth']); } /** @@ -183,10 +183,10 @@ protected function response($values) protected function parseCallenge($challenge) { if (!$challenge) { - return array(); + return []; } - $matches = array(); + $matches = []; preg_match_all('#(\w+)\=(?:"([^"]+)"|([^,]+))#', $challenge, $matches); list(, $variables, $quoted, $unquoted) = $matches; // filter empty strings; preserve keys diff --git a/src/EventListener/Stream/Bind.php b/src/EventListener/Stream/Bind.php index b6499fd..0b8609d 100644 --- a/src/EventListener/Stream/Bind.php +++ b/src/EventListener/Stream/Bind.php @@ -53,8 +53,8 @@ class Bind extends AbstractSessionEvent implements BlockingEventListenerInterfac public function attachEvents() { $input = $this->getInputEventManager(); - $input->attach('{urn:ietf:params:xml:ns:xmpp-bind}bind', array($this, 'bindFeatures')); - $input->attach('{urn:ietf:params:xml:ns:xmpp-bind}jid', array($this, 'jid')); + $input->attach('{urn:ietf:params:xml:ns:xmpp-bind}bind', [$this, 'bindFeatures']); + $input->attach('{urn:ietf:params:xml:ns:xmpp-bind}jid', [$this, 'jid']); } /** diff --git a/src/EventListener/Stream/BlockedUsers.php b/src/EventListener/Stream/BlockedUsers.php index d072dfb..769c19e 100644 --- a/src/EventListener/Stream/BlockedUsers.php +++ b/src/EventListener/Stream/BlockedUsers.php @@ -69,9 +69,9 @@ class BlockedUsers extends AbstractEventListener implements BlockingEventListene public function attachEvents() { $this->getOutputEventManager() - ->attach('{urn:xmpp:blocking}blocklist', array($this, 'query')); + ->attach('{urn:xmpp:blocking}blocklist', [$this, 'query']); $this->getInputEventManager() - ->attach('{urn:xmpp:blocking}blocklist', array($this, 'result')); + ->attach('{urn:xmpp:blocking}blocklist', [$this, 'result']); } /** @@ -93,7 +93,7 @@ public function query() public function result(XMLEvent $event) { if ($event->isEndTag()) { - $users = array(); + $users = []; /* @var $element \DOMElement */ $element = $event->getParameter(0); diff --git a/src/EventListener/Stream/Register.php b/src/EventListener/Stream/Register.php index 96ded71..25a380a 100644 --- a/src/EventListener/Stream/Register.php +++ b/src/EventListener/Stream/Register.php @@ -69,9 +69,9 @@ class Register extends AbstractEventListener implements BlockingEventListenerInt public function attachEvents() { $this->getOutputEventManager() - ->attach('{http://jabber.org/protocol/commands}command', array($this, 'query')); + ->attach('{http://jabber.org/protocol/commands}command', [$this, 'query']); $this->getInputEventManager() - ->attach('{http://jabber.org/protocol/commands}command', array($this, 'result')); + ->attach('{http://jabber.org/protocol/commands}command', [$this, 'result']); } /** diff --git a/src/EventListener/Stream/Roster.php b/src/EventListener/Stream/Roster.php index 223070f..a087c91 100644 --- a/src/EventListener/Stream/Roster.php +++ b/src/EventListener/Stream/Roster.php @@ -69,9 +69,9 @@ class Roster extends AbstractEventListener implements BlockingEventListenerInter public function attachEvents() { $this->getOutputEventManager() - ->attach('{jabber:iq:roster}query', array($this, 'query')); + ->attach('{jabber:iq:roster}query', [$this, 'query']); $this->getInputEventManager() - ->attach('{jabber:iq:roster}query', array($this, 'result')); + ->attach('{jabber:iq:roster}query', [$this, 'result']); } /** @@ -93,7 +93,7 @@ public function query() public function result(XMLEvent $event) { if ($event->isEndTag()) { - $users = array(); + $users = []; /* @var $element \DOMElement */ $element = $event->getParameter(0); diff --git a/src/EventListener/Stream/Session.php b/src/EventListener/Stream/Session.php index 10b8c60..04946ab 100644 --- a/src/EventListener/Stream/Session.php +++ b/src/EventListener/Stream/Session.php @@ -53,8 +53,8 @@ class Session extends AbstractSessionEvent implements BlockingEventListenerInter public function attachEvents() { $input = $this->getInputEventManager(); - $input->attach('{urn:ietf:params:xml:ns:xmpp-session}session', array($this, 'sessionStart')); - $input->attach('{jabber:client}iq', array($this, 'iq')); + $input->attach('{urn:ietf:params:xml:ns:xmpp-session}session', [$this, 'sessionStart']); + $input->attach('{jabber:client}iq', [$this, 'iq']); } /** diff --git a/src/EventListener/Stream/StartTls.php b/src/EventListener/Stream/StartTls.php index 9e001ce..6683246 100644 --- a/src/EventListener/Stream/StartTls.php +++ b/src/EventListener/Stream/StartTls.php @@ -62,8 +62,8 @@ class StartTls extends AbstractEventListener implements BlockingEventListenerInt public function attachEvents() { $input = $this->getInputEventManager(); - $input->attach('{urn:ietf:params:xml:ns:xmpp-tls}starttls', array($this, 'starttlsEvent')); - $input->attach('{urn:ietf:params:xml:ns:xmpp-tls}proceed', array($this, 'proceed')); + $input->attach('{urn:ietf:params:xml:ns:xmpp-tls}starttls', [$this, 'starttlsEvent']); + $input->attach('{urn:ietf:params:xml:ns:xmpp-tls}proceed', [$this, 'proceed']); } /** diff --git a/src/EventListener/Stream/Stream.php b/src/EventListener/Stream/Stream.php index df2a31f..0dcf60d 100644 --- a/src/EventListener/Stream/Stream.php +++ b/src/EventListener/Stream/Stream.php @@ -61,11 +61,11 @@ class Stream extends AbstractEventListener implements BlockingEventListenerInter public function attachEvents() { $this->getOutputEventManager() - ->attach('{http://etherx.jabber.org/streams}stream', array($this, 'streamStart')); + ->attach('{http://etherx.jabber.org/streams}stream', [$this, 'streamStart']); $input = $this->getInputEventManager(); - $input->attach('{http://etherx.jabber.org/streams}stream', array($this, 'streamServer')); - $input->attach('{http://etherx.jabber.org/streams}features', array($this, 'features')); + $input->attach('{http://etherx.jabber.org/streams}stream', [$this, 'streamServer']); + $input->attach('{http://etherx.jabber.org/streams}features', [$this, 'features']); } /** diff --git a/src/EventListener/Stream/StreamError.php b/src/EventListener/Stream/StreamError.php index 1a75748..30e9dd3 100644 --- a/src/EventListener/Stream/StreamError.php +++ b/src/EventListener/Stream/StreamError.php @@ -55,7 +55,7 @@ public function attachEvents() { $this->getInputEventManager()->attach( '{http://etherx.jabber.org/streams}error', - array($this, 'error') + [$this, 'error'] ); } diff --git a/src/Options.php b/src/Options.php index 88639a9..53a54dd 100644 --- a/src/Options.php +++ b/src/Options.php @@ -115,7 +115,7 @@ class Options * * @var array */ - protected $users = array(); + protected $users = []; /** * Timeout for connection. @@ -129,11 +129,11 @@ class Options * * @var array */ - protected $authenticationClasses = array( + protected $authenticationClasses = [ 'digest-md5' => '\\Fabiang\\Xmpp\\EventListener\\Stream\\Authentication\\DigestMd5', 'plain' => '\\Fabiang\\Xmpp\\EventListener\\Stream\\Authentication\\Plain', 'anonymous' => '\\Fabiang\\Xmpp\\EventListener\\Stream\\Authentication\\Anonymous' - ); + ]; /** @@ -141,7 +141,7 @@ class Options * * @var array */ - protected $contextOptions = array(); + protected $contextOptions = []; /** diff --git a/src/Protocol/User/User.php b/src/Protocol/User/User.php index ba78d8c..c7109df 100644 --- a/src/Protocol/User/User.php +++ b/src/Protocol/User/User.php @@ -66,7 +66,7 @@ class User * * @var array */ - protected $groups = array(); + protected $groups = []; public function getName() { diff --git a/src/Protocol/vCard.php b/src/Protocol/VCard.php similarity index 100% rename from src/Protocol/vCard.php rename to src/Protocol/VCard.php diff --git a/src/Stream/XMLStream.php b/src/Stream/XMLStream.php index 72e26e4..5a1752c 100644 --- a/src/Stream/XMLStream.php +++ b/src/Stream/XMLStream.php @@ -85,21 +85,21 @@ class XMLStream implements EventManagerAwareInterface * * @var array */ - protected $namespaces = array(); + protected $namespaces = []; /** * Cache of namespace prefixes. * * @var array */ - protected $namespacePrefixes = array(); + protected $namespacePrefixes = []; /** * Element cache. * * @var array */ - protected $elements = array(); + protected $elements = []; /** * XML parser. @@ -120,7 +120,7 @@ class XMLStream implements EventManagerAwareInterface * * @var array */ - protected $eventCache = array(); + protected $eventCache = []; /** * Constructor. @@ -155,13 +155,13 @@ public function parse($source) { $this->clearDocument($source); - $this->eventCache = array(); + $this->eventCache = []; if (0 === xml_parse($this->parser, $source, false)) { throw XMLParserException::create($this->parser); } // trigger collected events. $this->trigger(); - $this->eventCache = array(); + $this->eventCache = []; // was not there, so lets close the document if ($this->depth > 0) { @@ -186,7 +186,7 @@ protected function clearDocument($source) if ('reset(); - $matches = array(); + $matches = []; if (preg_match('/^<\?xml.*encoding=(\'|")([\w-]+)\1.*?>/i', $source, $matches)) { $this->encoding = $matches[2]; xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->encoding); @@ -260,7 +260,7 @@ protected function startXml() $this->depth++; $event = '{' . $namespaceElement . '}' . $elementName; - $this->cacheEvent($event, true, array($element)); + $this->cacheEvent($event, true, [$element]); } /** @@ -271,7 +271,7 @@ protected function startXml() */ protected function createAttributeNodes(array $attribs) { - $attributesNodes = array(); + $attributesNodes = []; foreach ($attribs as $name => $value) { // collect namespace prefixes if ('xmlns:' === substr($name, 0, 6)) { @@ -316,7 +316,7 @@ protected function endXml() } $event = '{' . $namespaceURI . '}' . $localName; - $this->cacheEvent($event, false, array($element)); + $this->cacheEvent($event, false, [$element]); } /** @@ -345,7 +345,7 @@ protected function dataXml() */ protected function cacheEvent($event, $startTag, $params) { - $this->eventCache[] = array($event, $startTag, $params); + $this->eventCache[] = [$event, $startTag, $params]; } /** @@ -382,9 +382,9 @@ public function reset() $this->parser = $parser; $this->depth = 0; $this->document = new \DOMDocument('1.0', $this->encoding); - $this->namespaces = array(); - $this->namespacePrefixes = array(); - $this->elements = array(); + $this->namespaces = []; + $this->namespacePrefixes = []; + $this->elements = []; } /** diff --git a/src/Util/ErrorHandler.php b/src/Util/ErrorHandler.php index cf63cad..b14f76d 100644 --- a/src/Util/ErrorHandler.php +++ b/src/Util/ErrorHandler.php @@ -59,7 +59,7 @@ class ErrorHandler * * @var array */ - protected $arguments = array(); + protected $arguments = []; public function __construct($method) {