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

Commit

Permalink
Merge branch 'master' into feature/math-biginteger
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 37 deletions.
1 change: 1 addition & 0 deletions src/Event.php
Expand Up @@ -109,6 +109,7 @@ public function getTarget()
*
* @param array|ArrayAccess|object $params
* @return Event
* @throws Exception\InvalidArgumentException
*/
public function setParams($params)
{
Expand Down
2 changes: 2 additions & 0 deletions src/EventInterface.php
Expand Up @@ -20,6 +20,8 @@

namespace Zend\EventManager;

use ArrayAccess;

/**
* Representation of an event
*
Expand Down
22 changes: 12 additions & 10 deletions src/EventManager.php
Expand Up @@ -20,12 +20,12 @@

namespace Zend\EventManager;

use Zend\Stdlib\CallbackHandler,
Zend\Stdlib\Exception\InvalidCallbackException,
Zend\Stdlib\PriorityQueue,
ArrayObject,
SplPriorityQueue,
Traversable;
use ArrayAccess;
use ArrayObject;
use SplPriorityQueue;
use Traversable;
use Zend\Stdlib\CallbackHandler;
use Zend\Stdlib\PriorityQueue;

/**
* Event manager: notification system
Expand Down Expand Up @@ -70,7 +70,6 @@ class EventManager implements EventManagerInterface
* SharedEventManagerInterface.
*
* @param null|string|int|array|Traversable $identifiers
* @return void
*/
public function __construct($identifiers = null)
{
Expand Down Expand Up @@ -176,6 +175,7 @@ public function addIdentifiers($identifiers)
* @param array|ArrayAccess $argv Array of arguments; typically, should be associative
* @param null|callback $callback
* @return ResponseCollection All listener return values
* @throws Exception\InvalidCallbackException
*/
public function trigger($event, $target = null, $argv = array(), $callback = null)
{
Expand All @@ -199,7 +199,7 @@ public function trigger($event, $target = null, $argv = array(), $callback = nul
}

if ($callback && !is_callable($callback)) {
throw new InvalidCallbackException('Invalid callback provided');
throw new Exception\InvalidCallbackException('Invalid callback provided');
}

return $this->triggerListeners($event, $e, $callback);
Expand All @@ -216,7 +216,8 @@ public function trigger($event, $target = null, $argv = array(), $callback = nul
* @param string|object $target Object calling emit, or symbol describing target (such as static method name)
* @param array|ArrayAccess $argv Array of arguments; typically, should be associative
* @param Callable $callback
* @throws InvalidCallbackException if invalid callback provided
* @return ResponseCollection
* @throws Exception\InvalidCallbackException if invalid callback provided
*/
public function triggerUntil($event, $target, $argv = null, $callback = null)
{
Expand All @@ -240,7 +241,7 @@ public function triggerUntil($event, $target, $argv = null, $callback = null)
}

if (!is_callable($callback)) {
throw new InvalidCallbackException('Invalid callback provided');
throw new Exception\InvalidCallbackException('Invalid callback provided');
}

return $this->triggerListeners($event, $e, $callback);
Expand All @@ -264,6 +265,7 @@ public function triggerUntil($event, $target, $argv = null, $callback = null)
* @param callback|int $callback If string $event provided, expects PHP callback; for a ListenerAggregateInterface $event, this will be the priority
* @param int $priority If provided, the priority at which to register the callback
* @return CallbackHandler|mixed CallbackHandler if attaching callback (to allow later unsubscribe); mixed if attaching aggregate
* @throws Exception\InvalidArgumentException
*/
public function attach($event, $callback = null, $priority = 1)
{
Expand Down
8 changes: 4 additions & 4 deletions src/EventManagerInterface.php
Expand Up @@ -20,9 +20,9 @@

namespace Zend\EventManager;

use Zend\Stdlib\CallbackHandler,
Traversable,
ArrayObject;
use ArrayObject;
use Traversable;
use Zend\Stdlib\CallbackHandler;

/**
* Interface for messengers
Expand Down Expand Up @@ -84,7 +84,7 @@ public function attach($event, $callback = null, $priority = 1);
* Detach an event listener
*
* @param CallbackHandler|ListenerAggregateInterface $listener
* @return void
* @return bool
*/
public function detach($listener);

Expand Down
2 changes: 1 addition & 1 deletion src/EventsCapableInterface.php
Expand Up @@ -35,7 +35,7 @@ interface EventsCapableInterface
*
* Lazy-loads an EventManager instance if none registered.
*
* @return EventCollection
* @return EventManagerInterface
*/
public function events();
}
7 changes: 7 additions & 0 deletions src/Exception/DomainException.php
@@ -0,0 +1,7 @@
<?php

namespace Zend\EventManager\Exception;

class DomainException extends \DomainException implements ExceptionInterface
{
}
3 changes: 1 addition & 2 deletions src/Exception/InvalidArgumentException.php
Expand Up @@ -28,7 +28,6 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class InvalidArgumentException extends \InvalidArgumentException implements
ExceptionInterface
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}
33 changes: 33 additions & 0 deletions src/Exception/InvalidCallbackException.php
@@ -0,0 +1,33 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Stdlib
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\EventManager\Exception;

/**
* Invalid callback exception
*
* @category Zend
* @package Zend_EventManager
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class InvalidCallbackException extends DomainException implements ExceptionInterface
{
}
1 change: 1 addition & 0 deletions src/Filter/FilterInterface.php
Expand Up @@ -20,6 +20,7 @@

namespace Zend\EventManager\Filter;

use Zend\EventManager\ResponseCollection;
use Zend\Stdlib\CallbackHandler;

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Filter/FilterIterator.php
Expand Up @@ -20,8 +20,8 @@

namespace Zend\EventManager\Filter;

use Zend\Stdlib\CallbackHandler,
Zend\Stdlib\SplPriorityQueue;
use Zend\Stdlib\CallbackHandler;
use Zend\Stdlib\SplPriorityQueue;

/**
* Specialized priority queue implementation for use with an intercepting
Expand Down Expand Up @@ -96,7 +96,7 @@ public function remove($datum)
* @param mixed $context
* @param array $params
* @param FilterIterator $chain
* @return void
* @return mixed
*/
public function next($context = null, array $params = array(), $chain = null)
{
Expand Down
12 changes: 5 additions & 7 deletions src/FilterChain.php
Expand Up @@ -20,8 +20,7 @@

namespace Zend\EventManager;

use Zend\Stdlib\CallbackHandler,
Zend\Stdlib\Exception\InvalidCallbackException;
use Zend\Stdlib\CallbackHandler;

/**
* FilterChain: intercepting filter manager
Expand All @@ -42,8 +41,6 @@ class FilterChain implements Filter\FilterInterface
* Constructor
*
* Initializes Filter\FilterIterator in which filters will be aggregated
*
* @return void
*/
public function __construct()
{
Expand Down Expand Up @@ -81,11 +78,12 @@ public function run($context, array $argv = array())
* @param callback $callback PHP Callback
* @param int $priority Priority in the queue at which to execute; defaults to 1 (higher numbers == higher priority)
* @return CallbackHandler (to allow later unsubscribe)
* @throws Exception\InvalidCallbackException
*/
public function attach($callback, $priority = 1)
{
if (empty($callback)) {
throw new InvalidCallbackException('No callback provided');
throw new Exception\InvalidCallbackException('No callback provided');
}
$filter = new CallbackHandler($callback, array('priority' => $priority));
$this->filters->insert($filter, $priority);
Expand All @@ -106,7 +104,7 @@ public function detach(CallbackHandler $filter)
/**
* Retrieve all filters
*
* @return FilterIterator
* @return Filter\FilterIterator
*/
public function getFilters()
{
Expand All @@ -133,6 +131,6 @@ public function clearFilters()
*/
public function getResponses()
{
return $this->responses;
return null;
}
}
10 changes: 5 additions & 5 deletions src/GlobalEventManager.php
Expand Up @@ -20,9 +20,9 @@

namespace Zend\EventManager;

use Zend\Stdlib\CallbackHandler,
Zend\Stdlib\PriorityQueue,
ArrayObject;
use ArrayObject;
use Zend\Stdlib\CallbackHandler;
use Zend\Stdlib\PriorityQueue;

/**
* Event manager: notification system
Expand Down Expand Up @@ -56,7 +56,7 @@ public static function setEventCollection(EventManagerInterface $events = null)
/**
* Get event collection on which this operates
*
* @return void
* @return EventManagerInterface
*/
public static function getEventCollection()
{
Expand Down Expand Up @@ -147,6 +147,6 @@ public static function getListeners($event)
*/
public static function clearListeners($event)
{
return static::getEventCollection()->clearListeners($event);
static::getEventCollection()->clearListeners($event);
}
}
1 change: 0 additions & 1 deletion src/ListenerAggregateInterface.php
Expand Up @@ -42,7 +42,6 @@ interface ListenerAggregateInterface
* implementation will pass this to the aggregate.
*
* @param EventManagerInterface $events
* @param null|int $priority Optional priority "hint" to use when attaching listeners
*/
public function attach(EventManagerInterface $events);

Expand Down
1 change: 1 addition & 0 deletions src/ResponseCollection.php
Expand Up @@ -86,6 +86,7 @@ public function last()
* Check if any of the responses match the given value.
*
* @param mixed $value The value to look for among responses
* @return bool
*/
public function contains($value)
{
Expand Down
4 changes: 2 additions & 2 deletions src/SharedEventManager.php
Expand Up @@ -20,8 +20,8 @@

namespace Zend\EventManager;

use Zend\Stdlib\CallbackHandler,
Zend\Stdlib\PriorityQueue;
use Zend\Stdlib\CallbackHandler;
use Zend\Stdlib\PriorityQueue;

/**
* Shared/contextual EventManager
Expand Down
4 changes: 2 additions & 2 deletions src/SharedEventManagerInterface.php
Expand Up @@ -20,8 +20,8 @@

namespace Zend\EventManager;

use Zend\Stdlib\CallbackHandler,
Zend\Stdlib\PriorityQueue;
use Zend\Stdlib\CallbackHandler;
use Zend\Stdlib\PriorityQueue;

/**
* Interface for shared event listener collections
Expand Down

0 comments on commit 0c55546

Please sign in to comment.