Commit version 24.12.13800

This commit is contained in:
2025-01-06 17:35:06 -05:00
parent b7f6a79c2c
commit 55d9218816
6133 changed files with 4239740 additions and 1374287 deletions

View File

@ -1,5 +1,15 @@
# CHANGELOG
## 0.7.0 (2017-05-23)
- [MAJOR]: [PR #46](https://github.com/fabiang/xmpp/pull/46) Added support for password-protected chatrooms
- [MAJOR]: [PR #44](https://github.com/fabiang/xmpp/pull/44) Added anonymous authentication method
- [MAJOR]: [PR #34](https://github.com/fabiang/xmpp/pull/34) Added support for registereing user
- [MAJOR]: [PR #34](https://github.com/fabiang/xmpp/pull/34) Added vCard support
- [MAJOR]: [PR #34](https://github.com/fabiang/xmpp/pull/34) Added support for blocking and unblocking an user
- [MAJOR]: Drop support for PHP lower than 5.6
- [MAJOR]: [PR #31](https://github.com/fabiang/xmpp/pull/31): Possibility to set context for SocketClient
## 0.6.1 (2014-11-20)
- [PATCH] [Issue #4](https://github.com/fabiang/xmpp/issues/4): Incomplete buffer response

View File

@ -84,7 +84,7 @@ abstract class AbstractConnection implements ConnectionInterface
*
* @var EventListenerInterface[]
*/
protected $listeners = array();
protected $listeners = [];
/**
* Connected.
@ -259,7 +259,7 @@ abstract class AbstractConnection implements ConnectionInterface
*/
protected function log($message, $level = LogLevel::DEBUG)
{
$this->getEventManager()->trigger('logger', $this, array($message, $level));
$this->getEventManager()->trigger('logger', $this, [$message, $level]);
}
/**

View File

@ -89,7 +89,7 @@ XML;
*/
public static function factory(Options $options)
{
$socket = new SocketClient($options->getAddress());
$socket = new SocketClient($options->getAddress(), $options->getContextOptions());
$object = new static($socket);
$object->setOptions($options);
return $object;
@ -129,7 +129,7 @@ XML;
// 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)) {

View File

@ -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}

View File

@ -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 @@ class EventManager implements EventManagerInterface
}
if (!isset($this->events[$event])) {
$this->events[$event] = array();
$this->events[$event] = [];
}
if (!in_array($callback, $this->events[$event], true)) {
@ -107,13 +107,13 @@ class EventManager implements EventManagerInterface
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);

View File

@ -69,6 +69,6 @@ class Logger extends AbstractEventListener
*/
public function attachEvents()
{
$this->getEventManager()->attach('logger', array($this, 'event'));
$this->getEventManager()->attach('logger', [$this, 'event']);
}
}

View File

@ -79,7 +79,8 @@ abstract class AbstractSessionEvent extends AbstractEventListener
$this->blocking = true;
$this->getConnection()->send(sprintf(
$data,
$this->getId()
$this->getId(),
$this->getOptions()->getResource()
));
}
}

View File

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

View File

@ -0,0 +1,66 @@
<?php
/**
* Copyright 2016 Fabian Grutschus. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the copyright holders.
*
* @author Fabian Grutschus <f.grutschus@lubyte.de>
* @copyright 2016 Fabian Grutschus. All rights reserved.
* @license BSD
* @link http://github.com/fabiang/xmpp
*/
namespace Fabiang\Xmpp\EventListener\Stream\Authentication;
use Fabiang\Xmpp\EventListener\AbstractEventListener;
/**
* Handler for "anonymous" authentication mechanism.
*
* @package Xmpp\EventListener\Authentication
*/
class Anonymous extends AbstractEventListener implements AuthenticationInterface
{
/**
* {@inheritDoc}
*/
public function attachEvents()
{
}
/**
* {@inheritDoc}
*/
public function authenticate($username, $password)
{
$this->getConnection()->send(
'<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="ANONYMOUS"/>'
);
}
}

View File

@ -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 @@ class DigestMd5 extends AbstractEventListener implements AuthenticationInterface
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

View File

@ -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']);
}
/**
@ -67,7 +67,7 @@ class Bind extends AbstractSessionEvent implements BlockingEventListenerInterfac
{
$this->respondeToFeatures(
$event,
'<iq type="set" id="%s"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/></iq>'
'<iq type="set" id="%s"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>%s</resource></bind></iq>'
);
}

View File

@ -0,0 +1,144 @@
<?php
/**
* Copyright 2014 Fabian Grutschus. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the copyright holders.
*
* @author Fabian Grutschus <f.grutschus@lubyte.de>
* @copyright 2014 Fabian Grutschus. All rights reserved.
* @license BSD
* @link http://github.com/fabiang/xmpp
*/
namespace Fabiang\Xmpp\EventListener\Stream;
use Fabiang\Xmpp\Event\XMLEvent;
use Fabiang\Xmpp\EventListener\AbstractEventListener;
use Fabiang\Xmpp\EventListener\BlockingEventListenerInterface;
use Fabiang\Xmpp\Protocol\User\User;
/**
* Listener
*
* @package Xmpp\EventListener
*/
class BlockedUsers extends AbstractEventListener implements BlockingEventListenerInterface
{
/**
* Blocking.
*
* @var boolean
*/
protected $blocking = false;
/**
* user object.
*
* @var User
*/
protected $userObject;
/**
* {@inheritDoc}
*/
public function attachEvents()
{
$this->getOutputEventManager()
->attach('{urn:xmpp:blocking}blocklist', [$this, 'query']);
$this->getInputEventManager()
->attach('{urn:xmpp:blocking}blocklist', [$this, 'result']);
}
/**
* Sending a query request for roster sets listener to blocking mode.
*
* @return void
*/
public function query()
{
$this->blocking = true;
}
/**
* Result received.
*
* @param \Fabiang\Xmpp\Event\XMLEvent $event
* @return void
*/
public function result(XMLEvent $event)
{
if ($event->isEndTag()) {
$users = [];
/* @var $element \DOMElement */
$element = $event->getParameter(0);
$items = $element->getElementsByTagName('item');
/* @var $item \DOMElement */
foreach ($items as $item) {
$users[] = $item->getAttribute('jid');
}
dd($users);
//$this->getOptions()->setUsers($users);
$this->blocking = false;
}
}
/**
* Get user object.
*
* @return User
*/
public function getUserObject()
{
if (null === $this->userObject) {
$this->setUserObject(new User);
}
return $this->userObject;
}
/**
* Set user object.
*
* @param User $userObject
* @return $this
*/
public function setUserObject(User $userObject)
{
$this->userObject = $userObject;
return $this;
}
/**
* {@inheritDoc}
*/
public function isBlocking()
{
return $this->blocking;
}
}

View File

@ -0,0 +1,111 @@
<?php
/**
* Copyright 2014 Fabian Grutschus. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the copyright holders.
*
* @author Fabian Grutschus <f.grutschus@lubyte.de>
* @copyright 2014 Fabian Grutschus. All rights reserved.
* @license BSD
* @link http://github.com/fabiang/xmpp
*/
namespace Fabiang\Xmpp\EventListener\Stream;
use Fabiang\Xmpp\Event\XMLEvent;
use Fabiang\Xmpp\EventListener\AbstractEventListener;
use Fabiang\Xmpp\EventListener\BlockingEventListenerInterface;
use Fabiang\Xmpp\Protocol\User\User;
/**
* Listener
*
* @package Xmpp\EventListener
*/
class Register extends AbstractEventListener implements BlockingEventListenerInterface
{
/**
* Blocking.
*
* @var boolean
*/
protected $blocking = false;
/**
* user object.
*
* @var User
*/
protected $userObject;
/**
* {@inheritDoc}
*/
public function attachEvents()
{
$this->getOutputEventManager()
->attach('{http://jabber.org/protocol/commands}command', [$this, 'query']);
$this->getInputEventManager()
->attach('{http://jabber.org/protocol/commands}command', [$this, 'result']);
}
/**
* Sending a query request for roster sets listener to blocking mode.
*
* @return void
*/
public function query()
{
$this->blocking = true;
}
/**
* Result received.
*
* @param \Fabiang\Xmpp\Event\XMLEvent $event
* @return void
*/
public function result(XMLEvent $event)
{
if ($event->isEndTag()) {
/* @var $element \DOMElement */
$sid = $event->getParameter(0)->getAttribute('sessionid');
$this->getOptions()->setSid($sid);
$this->blocking = false;
}
}
/**
* {@inheritDoc}
*/
public function isBlocking()
{
return $this->blocking;
}
}

View File

@ -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 @@ class Roster extends AbstractEventListener implements BlockingEventListenerInter
public function result(XMLEvent $event)
{
if ($event->isEndTag()) {
$users = array();
$users = [];
/* @var $element \DOMElement */
$element = $event->getParameter(0);

View File

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

View File

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

View File

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

View File

@ -55,7 +55,7 @@ class StreamError extends AbstractEventListener
{
$this->getInputEventManager()->attach(
'{http://etherx.jabber.org/streams}error',
array($this, 'error')
[$this, 'error']
);
}

View File

@ -1,7 +1,7 @@
Simplified BSD License
======================
Copyright 2014 Fabian Grutschus.
Copyright 2014-2017 Fabian Grutschus.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,

View File

@ -99,6 +99,12 @@ class Options
*/
protected $jid;
/**
*
* @var string
*/
protected $sid;
/**
*
* @var boolean
@ -109,7 +115,7 @@ class Options
*
* @var array
*/
protected $users = array();
protected $users = [];
/**
* Timeout for connection.
@ -123,10 +129,20 @@ class Options
*
* @var array
*/
protected $authenticationClasses = array(
protected $authenticationClasses = [
'digest-md5' => '\\Fabiang\\Xmpp\\EventListener\\Stream\\Authentication\\DigestMd5',
'plain' => '\\Fabiang\\Xmpp\\EventListener\\Stream\\Authentication\\Plain'
);
'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 = [];
/**
* Constructor.
@ -283,6 +299,18 @@ class Options
return $this;
}
/**
* Get resource.
*
* @return string
*/
public function getResource()
{
$username = $this->getUsername();
$username = explode('/', $username);
return isset($username[1]) ? $username[1] : '';
}
/**
* Get password.
*
@ -327,6 +355,28 @@ class Options
return $this;
}
/**
* Get users jid.
*
* @return string
*/
public function getSid()
{
return $this->sid;
}
/**
* Set users jid.
*
* @param string $jid
* @return $this
*/
public function setSid($sid)
{
$this->sid = (string) $sid;
return $this;
}
/**
* Is user authenticated.
*
@ -413,4 +463,26 @@ class Options
$this->timeout = (int) $timeout;
return $this;
}
/**
* Get context options for connection
*
* @return array
*/
public function getContextOptions()
{
return $this->contextOptions;
}
/**
* Set context options for connection
*
* @param array $contextOptions
* @return \Fabiang\Xmpp\Options
*/
public function setContextOptions($contextOptions)
{
$this->contextOptions = (array) $contextOptions;
return $this;
}
}

View File

@ -0,0 +1,113 @@
<?php
/**
* Copyright 2014 Fabian Grutschus. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the copyright holders.
*
* @author Fabian Grutschus <f.grutschus@lubyte.de>
* @copyright 2014 Fabian Grutschus. All rights reserved.
* @license BSD
* @link http://github.com/fabiang/xmpp
*/
namespace Fabiang\Xmpp\Protocol;
use Fabiang\Xmpp\Util\XML;
/**
* Protocol setting for Xmpp.
*
* @package Xmpp\Protocol
*/
class BlockUser implements ProtocolImplementationInterface
{
protected $from;
// the jid of the user to block
protected $accountjid;
/**
* {@inheritDoc}
*/
public function toString()
{
return XML::quoteMessage(
'<iq from="%s" type="set" id="%s">
<block xmlns="urn:xmpp:blocking">
<item jid="%s"/>
</block>
</iq>',
$this->getFrom(),
XML::generateId(),
$this->getJabberID()
);
}
/**
* Get JabberID.
*
* @return string
*/
public function getJabberID()
{
return $this->accountjid;
}
/**
* Set abberID.
*
* @param string $accountjid
* @return $this
*/
public function setJabberID($accountjid)
{
$this->accountjid = (string) $accountjid;
return $this;
}
/**
* Get JabberID.
*
* @return string
*/
public function getFrom()
{
return $this->from;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setFrom($from)
{
$this->from = (string) $from;
return $this;
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* Copyright 2014 Fabian Grutschus. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the copyright holders.
*
* @author Fabian Grutschus <f.grutschus@lubyte.de>
* @copyright 2014 Fabian Grutschus. All rights reserved.
* @license BSD
* @link http://github.com/fabiang/xmpp
*/
namespace Fabiang\Xmpp\Protocol;
use Fabiang\Xmpp\Util\XML;
/**
* Protocol setting for Xmpp.
*
* @package Xmpp\Protocol
*/
class BlockedUsers implements ProtocolImplementationInterface
{
/**
* {@inheritDoc}
*/
public function toString()
{
return '<iq type="get" id="' . XML::generateId() . '">'
. '<blocklist xmlns="urn:xmpp:blocking"/></iq>';
}
}

View File

@ -47,6 +47,8 @@ use Fabiang\Xmpp\EventListener\Stream\Authentication;
use Fabiang\Xmpp\EventListener\Stream\Bind;
use Fabiang\Xmpp\EventListener\Stream\Session;
use Fabiang\Xmpp\EventListener\Stream\Roster as RosterListener;
use Fabiang\Xmpp\EventListener\Stream\Register as RegisterListener;
use Fabiang\Xmpp\EventListener\Stream\BlockedUsers as BlockedUsersListener;
/**
* Default Protocol implementation.
@ -82,6 +84,8 @@ class DefaultImplementation implements ImplementationInterface
$this->registerListener(new Bind);
$this->registerListener(new Session);
$this->registerListener(new RosterListener);
$this->registerListener(new RegisterListener);
$this->registerListener(new BlockedUsersListener);
}
/**

View File

@ -132,6 +132,13 @@ class Presence implements ProtocolImplementationInterface
*/
protected $nickname;
/**
* Channel password.
*
* @var string
*/
protected $password;
/**
* Constructor.
*
@ -155,7 +162,14 @@ class Presence implements ProtocolImplementationInterface
$presence .= ' to="' . XML::quote($this->getTo()) . '/' . XML::quote($this->getNickname()) . '"';
}
return $presence . '><priority>' . $this->getPriority() . '</priority></presence>';
$presence .= '><priority>' . $this->getPriority() . '</priority>';
if (null !== $this->getPassword()) {
$presence .= "<x xmlns='http://jabber.org/protocol/muc'><password>" . $this->getPassword() . "</password></x>";
}
$presence .= '</presence>';
return $presence;
}
/**
@ -223,4 +237,26 @@ class Presence implements ProtocolImplementationInterface
$this->priority = (int) $priority;
return $this;
}
/**
* Get channel password.
*
* @return string¦null
*/
public function getPassword()
{
return $this->password;
}
/**
* Set channel password.
*
* @param string|null $to
* @return $this
*/
public function setPassword($password = null)
{
$this->password = $password;
return $this;
}
}

View File

@ -0,0 +1,196 @@
<?php
namespace Fabiang\Xmpp\Protocol;
use Fabiang\Xmpp\Util\XML;
/**
* Protocol setting for Xmpp.
*
* @package Xmpp\Protocol
*/
class Register implements ProtocolImplementationInterface
{
protected $to;
protected $from;
protected $step;
protected $accountjid;
protected $password;
protected $sid;
/**
* Constructor.
*
* @param integer $priority
* @param string $to
* @param string $nickname
*/
public function __construct($to = null, $from = null, $step = 'one')
{
$this->setTo($to);
$this->setFrom($from);
$this->setStep($step);
}
/**
* {@inheritDoc}
*/
public function toString()
{
$req ='';
if($this->step == 'one')
{
$req = XML::quoteMessage(
"<iq from='%s' id='%s' to='%s' type='set' xml:lang='en'>
<command xmlns='http://jabber.org/protocol/commands' action='execute' node='http://jabber.org/protocol/admin#add-user'/>
</iq>",
$this->getFrom(),
XML::generateId(),
$this->getTo()
);
}
else
{
$req = XML::quoteMessage(
"<iq from='%s' id='%s' to='%s' type='set' xml:lang='en'>
<command xmlns='http://jabber.org/protocol/commands' node='http://jabber.org/protocol/admin#add-user' sessionid='%s'>
<x xmlns='jabber:x:data' type='submit'>
<field type='hidden' var='FORM_TYPE'>
<value>http://jabber.org/protocol/admin</value>
</field>
<field var='accountjid'>
<value>%s</value>
</field>
<field var='password'>
<value>%s</value>
</field>
<field var='password-verify'>
<value>%s</value>
</field>
</x>
</command>
</iq>",
$this->getFrom(),
XML::generateId(),
$this->getTo(),
$this->getSID(),
$this->getJabberID(),
$this->getPassword(),
$this->getPassword()
);
}
return $req;
}
/**
* Get JabberID.
*
* @return string
*/
public function getJabberID()
{
return $this->accountjid;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setJabberID($accountjid)
{
$this->accountjid = (string) $accountjid;
return $this;
}
/**
* Get JabberID.
*
* @return string
*/
public function getTo()
{
return $this->to;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setTo($to)
{
$this->to = (string) $to;
return $this;
}
/**
* Get JabberID.
*
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setPassword($password)
{
$this->password = (string) $password;
return $this;
}
/**
* Get JabberID.
*
* @return string
*/
public function getFrom()
{
return $this->from;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setFrom($from)
{
$this->from = (string) $from;
return $this;
}
public function setStep($step)
{
$this->step = (string) $step;
return $this;
}
public function setSID($sid)
{
$this->sid = (string) $sid;
return $this;
}
public function getSID()
{
return $this->sid;
}
}

View File

@ -0,0 +1,88 @@
<?php
/**
* Copyright 2014 Fabian Grutschus. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the copyright holders.
*
* @author Fabian Grutschus <f.grutschus@lubyte.de>
* @copyright 2014 Fabian Grutschus. All rights reserved.
* @license BSD
* @link http://github.com/fabiang/xmpp
*/
namespace Fabiang\Xmpp\Protocol;
use Fabiang\Xmpp\Util\XML;
/**
* Protocol setting for Xmpp.
*
* @package Xmpp\Protocol
*/
class UnblockUser implements ProtocolImplementationInterface
{
// the jid of the user to block
protected $accountjid;
/**
* {@inheritDoc}
*/
public function toString()
{
return XML::quoteMessage(
'<iq type="set" id="%s">
<unblock xmlns="urn:xmpp:blocking">
<item jid="%s"/>
</unblock>
</iq>',
XML::generateId(),
$this->getJabberID()
);
}
/**
* Get JabberID.
*
* @return string
*/
public function getJabberID()
{
return $this->accountjid;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setJabberID($accountjid)
{
$this->accountjid = (string) $accountjid;
return $this;
}
}

View File

@ -66,7 +66,7 @@ class User
*
* @var array
*/
protected $groups = array();
protected $groups = [];
public function getName()
{

View File

@ -0,0 +1,228 @@
<?php
namespace Fabiang\Xmpp\Protocol;
use Fabiang\Xmpp\Util\XML;
/**
* Protocol setting for Xmpp.
*
* @package Xmpp\Protocol
*/
class VCard implements ProtocolImplementationInterface
{
/**
* vCard to.
*
* @var string|null
*/
protected $to;
/**
* user firstname.
*
* @var string
*/
protected $firstname;
/**
* user lastname.
*
* @var string
*/
protected $lastname;
protected $jabberid;
protected $mime;
protected $image;
protected $ulr;
/**
* Constructor.
*
* @param integer $priority
* @param string $to
* @param string $nickname
*/
public function __construct($firstname = null, $lastname = null, $jabberid = null)
{
$this->setFirstname($firstname);
$this->setLastname($lastname);
$this->setJabberID($jabberid);
}
/**
* {@inheritDoc}
*/
public function toString()
{
return XML::quoteMessage(
'<iq id="' . XML::generateId() . '" type="set">
<vCard xmlns="vcard-temp">
<FN>%s</FN>
<N>
<FAMILY>%s</FAMILY>
<GIVEN>%s</GIVEN>
<MIDDLE/>
</N>
<NICKNAME>%s</NICKNAME>
<URL>%s</URL>
<PHOTO>
<TYPE>%s</TYPE>
<BINVAL>
%s
</BINVAL>
</PHOTO>
<JABBERID>%s</JABBERID>
<DESC/>
</vCard>
</iq>',
$this->getFirstname().' '.$this->getLastname(),
$this->getLastname(),
$this->getFirstname(),
$this->getFirstname().' '.$this->getLastname(),
$this->getUrl(),
$this->getMime(),
$this->getImage(),
$this->getJabberID()
);
}
/**
* Get nickname.
*
* @return string
*/
public function getFirstname()
{
return $this->firstname;
}
/**
* Set nickname.
*
* @param string $nickname
* @return $this
*/
public function setFirstname($firstname)
{
$this->firstname = (string) $firstname;
return $this;
}
/**
* Get nickname.
*
* @return string
*/
public function getLastname()
{
return $this->lastname;
}
/**
* Set nickname.
*
* @param string $nickname
* @return $this
*/
public function setLastname($lastname)
{
$this->lastname = (string) $lastname;
return $this;
}
/**
* Get JabberID.
*
* @return string
*/
public function getJabberID()
{
return $this->jabberid;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setJabberID($jabberid)
{
$this->jabberid = (string) $jabberid;
return $this;
}
/**
* Get mime.
*
* @return string
*/
public function getMime()
{
return $this->mime;
}
/**
* Set mime.
*
* @param string $mime
* @return $this
*/
public function setMime($mime)
{
$this->mime = (string) $mime;
return $this;
}
/**
* Get image.
*
* @return string
*/
public function getImage()
{
return $this->image;
}
/**
* Set image.
*
* @param string $image base64
* @return $this
*/
public function setImage($image)
{
$this->image = (string) $image;
return $this;
}
/**
* Get url.
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set url.
*
* @param string $image base64
* @return $this
*/
public function setUrl($url)
{
$this->url = (string) $url;
return $this;
}
}

View File

@ -1,26 +1,28 @@
# fabiang/xmpp
[![Latest Stable Version](https://poser.pugx.org/fabiang/xmpp/v/stable.svg)](https://packagist.org/packages/fabiang/xmpp) [![Total Downloads](https://poser.pugx.org/fabiang/xmpp/downloads.svg)](https://packagist.org/packages/fabiang/xmpp) [![Latest Unstable Version](https://poser.pugx.org/fabiang/xmpp/v/unstable.svg)](https://packagist.org/packages/fabiang/xmpp) [![License](https://poser.pugx.org/fabiang/xmpp/license.svg)](https://packagist.org/packages/fabiang/xmpp)
[![Build Status](https://travis-ci.org/fabiang/xmpp.png?branch=master)](https://travis-ci.org/fabiang/xmpp) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/fabiang/xmpp/badges/quality-score.png?s=2605ad2bc987ff8501b8f749addff43ec1ac7098)](https://scrutinizer-ci.com/g/fabiang/xmpp/) [![Coverage Status](https://img.shields.io/coveralls/fabiang/xmpp.svg)](https://coveralls.io/r/fabiang/xmpp?branch=master) [![Dependency Status](https://gemnasium.com/fabiang/xmpp.png)](https://gemnasium.com/fabiang/xmpp) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/a535cd82-788d-4506-803e-02ede44a9e74/mini.png)](https://insight.sensiolabs.com/projects/a535cd82-788d-4506-803e-02ede44a9e74)
Library for XMPP protocol connections (Jabber) for PHP.
[![License](https://poser.pugx.org/fabiang/xmpp/license.svg)](https://packagist.org/packages/fabiang/xmpp)
[![Latest Stable Version](https://poser.pugx.org/fabiang/xmpp/v/stable.svg)](https://packagist.org/packages/fabiang/xmpp)
[![Total Downloads](https://poser.pugx.org/fabiang/xmpp/downloads.svg)](https://packagist.org/packages/fabiang/xmpp)
[![Dependency Status](https://gemnasium.com/fabiang/xmpp.svg)](https://gemnasium.com/fabiang/xmpp)
[![Build Status](https://travis-ci.org/fabiang/xmpp.png?branch=master)](https://travis-ci.org/fabiang/xmpp)
[![Coverage Status](https://img.shields.io/coveralls/fabiang/xmpp.svg)](https://coveralls.io/r/fabiang/xmpp?branch=master)
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/fabiang/xmpp/badges/quality-score.png?s=2605ad2bc987ff8501b8f749addff43ec1ac7098)](https://scrutinizer-ci.com/g/fabiang/xmpp/)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/a535cd82-788d-4506-803e-02ede44a9e74/mini.png)](https://insight.sensiolabs.com/projects/a535cd82-788d-4506-803e-02ede44a9e74)
## SYSTEM REQUIREMENTS
- PHP >= 5.3.3
- PHP minimum 5.6 or minimum 7.0
- psr/log
- psr/log-implementation - like monolog/monolog for logging (optional)
- (optional) psr/log-implementation - like monolog/monolog for logging
## INSTALLATION
New to Composer? Read the [introduction](https://getcomposer.org/doc/00-intro.md#introduction). Add the following to your composer file:
```json
{
"require": {
"fabiang/xmpp": "*"
}
}
```bash
composer require fabiang/xmpp
```
## DOCUMENTATION
@ -73,6 +75,7 @@ $client->send($message);
// join a channel
$channel = new Presence;
$channel->setTo('channelname@conference.myjabber.com')
->setPassword('channelpassword')
->setNickName('mynick');
$client->send($channel);
@ -95,14 +98,14 @@ $client->disconnect();
If you like this library and you want to contribute, make sure the unit-tests and integration tests are running.
Composer will help you to install the right version of PHPUnit and [Behat](http://behat.org/).
composer install --dev
composer install
After that:
./vendor/bin/phpunit -c tests
./vendor/bin/behat --config=tests/behat.yml --strict
./vendor/bin/phpunit
./vendor/bin/behat
New features should allways tested with Behat.
New features should always tested with Behat.
## LICENSE
@ -112,5 +115,4 @@ BSD-2-Clause. See the [LICENSE](LICENSE.md).
- Better integration of channels
- Factory method for server addresses
- Add support von vCard
- improve documentation

View File

@ -63,46 +63,57 @@ class SocketClient
*/
protected $address;
/**
* Options used to create a stream context
* @see http://php.net/manual/en/function.stream-context-create.php
*
* @var array
*/
protected $options;
/**
* Constructor takes address as argument.
*
* @param string $address
*/
public function __construct($address)
public function __construct($address, $options = null)
{
$this->address = $address;
$this->options = $options;
}
/**
* Connect.
*
* @param integer $timeout Timeout for connection
* @param integer $timeout Timeout for connection
* @param boolean $persistent Persitent connection
* @return void
*/
public function connect($timeout = 30, $persistent = false)
{
$flags = STREAM_CLIENT_CONNECT;
if (true === $persistent) {
$flags = STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT;
} else {
$flags = STREAM_CLIENT_CONNECT;
$flags |= STREAM_CLIENT_PERSISTENT;
}
// call stream_socket_client with custom error handler enabled
$handler = new ErrorHandler(
function ($address, $timeout, $flags) {
$options = [
'ssl' => [
'allow_self_signed' => true,
'verify_peer_name' => false,
],
];
$context = stream_context_create($options);
return stream_socket_client($address, $errno, $errstr, $timeout, $flags, $context);
function ($address, $timeout, $flags, array $options = null) {
$errno = null;
$errstr = null;
if (!empty($options)) {
$context = stream_context_create($options);
return stream_socket_client($address, $errno, $errstr, $timeout, $flags, $context);
}
return stream_socket_client($address, $errno, $errstr, $timeout, $flags);
},
$this->address,
$timeout,
$flags
$flags,
$this->options
);
$resource = $handler->execute(__FILE__, __LINE__);
@ -113,9 +124,9 @@ class SocketClient
/**
* Reconnect and optionally use different address.
*
* @param string $address
* @param string $address
* @param integer $timeout
* @param bool $persistent
* @param bool $persistent
*/
public function reconnect($address = null, $timeout = 30, $persistent = false)
{
@ -146,7 +157,7 @@ class SocketClient
*/
public function setBlocking($flag = true)
{
stream_set_blocking($this->resource, (int) $flag);
stream_set_blocking($this->resource, (int)$flag);
return $this;
}
@ -164,7 +175,7 @@ class SocketClient
/**
* Write to stream.
*
* @param string $string String
* @param string $string String
* @param integer $length Limit
* @return void
*/
@ -180,7 +191,7 @@ class SocketClient
/**
* Enable/disable cryptography on stream.
*
* @param boolean $enable Flag
* @param boolean $enable Flag
* @param integer $cryptoType One of the STREAM_CRYPTO_METHOD_* constants.
* @return void
* @throws InvalidArgumentException

View File

@ -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 @@ class XMLStream implements EventManagerAwareInterface
{
$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) {
@ -186,7 +186,7 @@ class XMLStream implements EventManagerAwareInterface
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);
@ -260,7 +260,7 @@ class XMLStream implements EventManagerAwareInterface
$this->depth++;
$event = '{' . $namespaceElement . '}' . $elementName;
$this->cacheEvent($event, true, array($element));
$this->cacheEvent($event, true, [$element]);
}
/**
@ -271,7 +271,7 @@ class XMLStream implements EventManagerAwareInterface
*/
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 @@ class XMLStream implements EventManagerAwareInterface
}
$event = '{' . $namespaceURI . '}' . $localName;
$this->cacheEvent($event, false, array($element));
$this->cacheEvent($event, false, [$element]);
}
/**
@ -345,7 +345,7 @@ class XMLStream implements EventManagerAwareInterface
*/
protected function cacheEvent($event, $startTag, $params)
{
$this->eventCache[] = array($event, $startTag, $params);
$this->eventCache[] = [$event, $startTag, $params];
}
/**
@ -382,9 +382,9 @@ class XMLStream implements EventManagerAwareInterface
$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 = [];
}
/**

View File

@ -59,7 +59,7 @@ class ErrorHandler
*
* @var array
*/
protected $arguments = array();
protected $arguments = [];
public function __construct($method)
{