Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Commit

Permalink
Use short array syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiang committed May 23, 2017
1 parent 39dd322 commit d5fe3ac
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 58 deletions.
4 changes: 2 additions & 2 deletions src/Connection/AbstractConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ abstract class AbstractConnection implements ConnectionInterface
*
* @var EventListenerInterface[]
*/
protected $listeners = array();
protected $listeners = [];

/**
* Connected.
Expand Down Expand Up @@ -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]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Connection/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -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://(?<address>.+)#', $previousAddress, $matches)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Event/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
8 changes: 4 additions & 4 deletions src/Event/EventManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class EventManager implements EventManagerInterface
*
* @var array
*/
protected $events = array(self::WILDCARD => array());
protected $events = [self::WILDCARD => []];

/**
* Event object.
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}
10 changes: 5 additions & 5 deletions src/EventListener/Stream/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ class Authentication extends AbstractEventListener implements BlockingEventListe
*
* @var array
*/
protected $mechanisms = array();
protected $mechanisms = [];

/**
* {@inheritDoc}
*/
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']);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/EventListener/Stream/Authentication/DigestMd5.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/Stream/Bind.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/EventListener/Stream/BlockedUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/Stream/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/EventListener/Stream/Roster.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/Stream/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/Stream/StartTls.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/EventListener/Stream/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/Stream/StreamError.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function attachEvents()
{
$this->getInputEventManager()->attach(
'{http://etherx.jabber.org/streams}error',
array($this, 'error')
[$this, 'error']
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Options
*
* @var array
*/
protected $users = array();
protected $users = [];

/**
* Timeout for connection.
Expand All @@ -129,19 +129,19 @@ 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'
);
];


/**
* Options used to create a stream context
*
* @var array
*/
protected $contextOptions = array();
protected $contextOptions = [];


/**
Expand Down
2 changes: 1 addition & 1 deletion src/Protocol/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class User
*
* @var array
*/
protected $groups = array();
protected $groups = [];

public function getName()
{
Expand Down
File renamed without changes.
28 changes: 14 additions & 14 deletions src/Stream/XMLStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -120,7 +120,7 @@ class XMLStream implements EventManagerAwareInterface
*
* @var array
*/
protected $eventCache = array();
protected $eventCache = [];

/**
* Constructor.
Expand Down Expand Up @@ -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 = [];

// </stream> was not there, so lets close the document
if ($this->depth > 0) {
Expand All @@ -186,7 +186,7 @@ protected function clearDocument($source)
if ('<?xml' === substr($source, 0, 5)) {
$this->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);
Expand Down Expand Up @@ -260,7 +260,7 @@ protected function startXml()
$this->depth++;

$event = '{' . $namespaceElement . '}' . $elementName;
$this->cacheEvent($event, true, array($element));
$this->cacheEvent($event, true, [$element]);
}

/**
Expand All @@ -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)) {
Expand Down Expand Up @@ -316,7 +316,7 @@ protected function endXml()
}

$event = '{' . $namespaceURI . '}' . $localName;
$this->cacheEvent($event, false, array($element));
$this->cacheEvent($event, false, [$element]);
}

/**
Expand Down Expand Up @@ -345,7 +345,7 @@ protected function dataXml()
*/
protected function cacheEvent($event, $startTag, $params)
{
$this->eventCache[] = array($event, $startTag, $params);
$this->eventCache[] = [$event, $startTag, $params];
}

/**
Expand Down Expand Up @@ -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 = [];
}

/**
Expand Down
Loading

0 comments on commit d5fe3ac

Please sign in to comment.