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

Commit

Permalink
Removed some violations
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiang committed Feb 5, 2014
1 parent 33514d7 commit 9b183e0
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/Fabiang/Xmpp/Connection/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Test extends AbstractConnection
/**
* Data for next receive().
*
* @var string|null
* @var array
*/
protected $data = array();

Expand Down
10 changes: 3 additions & 7 deletions src/Fabiang/Xmpp/Event/XMLEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* @package Xmpp\Event
*/
class XMLEvent extends Event implements EventInterface
class XMLEvent extends Event implements XMLEventInterface
{

/**
Expand All @@ -52,9 +52,7 @@ class XMLEvent extends Event implements EventInterface
protected $startTag = false;

/**
* Is event triggered by a start tag.
*
* @return boolean
* {@inheritDoc}
*/
public function isStartTag()
{
Expand All @@ -74,9 +72,7 @@ public function setStartTag($startTag)
}

/**
* Was event triggered by end tag of an element?
*
* @return boolean
* {@inheritDoc}
*/
public function isEndTag()
{
Expand Down
60 changes: 60 additions & 0 deletions src/Fabiang/Xmpp/Event/XMLEventInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?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 <[email protected]>
* @copyright 2014 Fabian Grutschus. All rights reserved.
* @license BSD
* @link http://github.com/fabiang/xmpp
*/

namespace Fabiang\Xmpp\Event;

/**
* INterface for xml events.
*
* @package Xmpp\Event
*/
interface XMLEventInterface extends EventInterface
{

/**
* Is event triggered by a start tag.
*
* @return boolean
*/
public function isStartTag();

/**
* Was event triggered by end tag of an element?
*
* @return boolean
*/
public function isEndTag();
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function challenge(XMLEvent $event)
/**
* Generate response data.
*
* @param type $values
* @param array $values
*/
protected function response($values)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Fabiang/Xmpp/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ public function getAddress()
public function setAddress($address)
{
$this->address = (string) $address;
$this->setTo(parse_url($address, PHP_URL_HOST));
if (false !== ($host = parse_url($address, PHP_URL_HOST))) {
$this->setTo($host);
}
return $this;
}

Expand Down
12 changes: 6 additions & 6 deletions src/Fabiang/Xmpp/Protocol/DefaultImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
use Fabiang\Xmpp\EventListener\Stream\Authentication;
use Fabiang\Xmpp\EventListener\Stream\Bind;
use Fabiang\Xmpp\EventListener\Stream\Session;
use Fabiang\Xmpp\EventListener\Stream\Roster;
use Fabiang\Xmpp\EventListener\Stream\Roster as RosterListener;

/**
* Default Protocol implementation.
Expand All @@ -62,7 +62,7 @@ class DefaultImplementation implements ImplementationInterface
* @var Options
*/
protected $options;

/**
* Eventmanager.
*
Expand All @@ -81,16 +81,16 @@ public function register()
$this->registerListener(new Authentication);
$this->registerListener(new Bind);
$this->registerListener(new Session);
$this->registerListener(new Roster);
$this->registerListener(new RosterListener);
}

/**
* {@inheritDoc}
*/
public function registerListener(EventListenerInterface $eventListener)
{
$connection = $this->getOptions()->getConnection();

$eventListener->setEventManager($this->getEventManager())
->setOptions($this->getOptions())
->attachEvents();
Expand All @@ -114,7 +114,7 @@ public function setOptions(Options $options)
$this->options = $options;
return $this;
}

/**
* {@inheritDoc}
*/
Expand Down
19 changes: 10 additions & 9 deletions src/Fabiang/Xmpp/Stream/XMLStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use Fabiang\Xmpp\Event\EventManagerInterface;
use Fabiang\Xmpp\Event\EventManager;
use Fabiang\Xmpp\Event\XMLEvent;
use Fabiang\Xmpp\Event\XMLEventInterface;
use Fabiang\Xmpp\Exception\XMLParserException;

/**
Expand Down Expand Up @@ -207,8 +208,10 @@ protected function clearDocument($source)
* @param attribs $attribs Element attributes
* @return void
*/
protected function startXml($parser, $name, $attribs)
protected function startXml()
{
list (, $name, $attribs) = func_get_args();

$elementData = explode(static::NAMESPACE_SEPARATOR, $name, 2);
$elementName = $elementData[0];
$prefix = null;
Expand All @@ -221,16 +224,13 @@ protected function startXml($parser, $name, $attribs)
$namespaceAttrib = false;

// current namespace
$namespaceURI = null;
// namespace of the element
$namespaceElement = null;

if (array_key_exists('xmlns', $attribs)) {
$namespaceURI = $attribs['xmlns'];
} else {
$namespaceURI = $this->namespaces[$this->depth - 1];
}

// namespace of the element
if (null !== $prefix) {
$namespaceElement = $this->namespacePrefixes[$prefix];
} else {
Expand Down Expand Up @@ -326,8 +326,9 @@ protected function endXml()
* @param string $data Element data
* @return void
*/
protected function dataXml($parser, $data)
protected function dataXml()
{
$data = func_get_arg(1);
if (isset($this->elements[$this->depth - 1])) {
$element = $this->elements[$this->depth - 1];
$element->appendChild($this->document->createTextNode($data));
Expand Down Expand Up @@ -420,7 +421,7 @@ public function setEventManager(EventManagerInterface $events)
/**
* Get event object.
*
* @return XMLEvent
* @return XMLEventInterface
*/
public function getEventObject()
{
Expand All @@ -430,10 +431,10 @@ public function getEventObject()
/**
* Set event object.
*
* @param \Fabiang\Xmpp\Event\XMLEvent $eventObject
* @param XMLEventInterface $eventObject
* @return $this
*/
public function setEventObject(XMLEvent $eventObject)
public function setEventObject(XMLEventInterface $eventObject)
{
$this->eventObject = $eventObject;
return $this;
Expand Down

0 comments on commit 9b183e0

Please sign in to comment.