From b26220bbb78d32193ce37b9485e5067a2c356828 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Wed, 11 Jul 2012 22:20:59 +0200 Subject: [PATCH 1/2] Add blank lines around the use block --- test/FilterChainTest.php | 1 + test/GlobalEventManagerTest.php | 1 + 2 files changed, 2 insertions(+) diff --git a/test/FilterChainTest.php b/test/FilterChainTest.php index ace0e21..353b02e 100644 --- a/test/FilterChainTest.php +++ b/test/FilterChainTest.php @@ -9,6 +9,7 @@ */ namespace ZendTest\Stdlib; + use Zend\EventManager\FilterChain; use Zend\Stdlib\CallbackHandler; diff --git a/test/GlobalEventManagerTest.php b/test/GlobalEventManagerTest.php index c0a13a8..6f3bacb 100644 --- a/test/GlobalEventManagerTest.php +++ b/test/GlobalEventManagerTest.php @@ -9,6 +9,7 @@ */ namespace ZendTest\EventManager; + use Zend\EventManager\GlobalEventManager; use Zend\EventManager\EventManager; From 33d1c279bd28d6d205a51a78addc2305dde52dcd Mon Sep 17 00:00:00 2001 From: Maks3w Date: Thu, 12 Jul 2012 21:11:36 +0200 Subject: [PATCH 2/2] [PSR-2] fixers=braces,elseif,short_tag,php_closing_tag,trailing_spaces,linefeed Applied php-cs-fixer --fixers=braces,elseif,short_tag,php_closing_tag,trailing_spaces,linefeed --- src/Event.php | 44 +++++++++++----------- src/EventInterface.php | 34 ++++++++--------- src/EventManager.php | 10 ++--- src/EventManagerAwareInterface.php | 2 +- src/EventManagerInterface.php | 38 +++++++++---------- src/Filter/FilterInterface.php | 20 +++++----- src/Filter/FilterIterator.php | 18 ++++----- src/FilterChain.php | 16 ++++---- src/GlobalEventManager.php | 48 ++++++++++++------------ src/ProvidesEvents.php | 6 +-- src/ResponseCollection.php | 6 +-- src/SharedEventManager.php | 26 ++++++------- src/SharedEventManagerAwareInterface.php | 2 +- src/StaticEventManager.php | 6 +-- test/StaticIntegrationTest.php | 24 ++++++------ 15 files changed, 150 insertions(+), 150 deletions(-) diff --git a/src/Event.php b/src/Event.php index 85b405f..35878b5 100644 --- a/src/Event.php +++ b/src/Event.php @@ -15,7 +15,7 @@ /** * Representation of an event * - * Encapsulates the target context and parameters passed, and provides some + * Encapsulates the target context and parameters passed, and provides some * behavior for interacting with the event manager. * * @category Zend @@ -47,10 +47,10 @@ class Event implements EventInterface * Constructor * * Accept a target and its parameters. - * + * * @param string $name Event name - * @param string|object $target - * @param array|ArrayAccess $params + * @param string|object $target + * @param array|ArrayAccess $params * @return void */ public function __construct($name = null, $target = null, $params = null) @@ -70,7 +70,7 @@ public function __construct($name = null, $target = null, $params = null) /** * Get event name - * + * * @return string */ public function getName() @@ -82,7 +82,7 @@ public function getName() * Get the event target * * This may be either an object, or the name of a static method. - * + * * @return string|object */ public function getTarget() @@ -94,8 +94,8 @@ public function getTarget() * Set parameters * * Overwrites parameters - * - * @param array|ArrayAccess|object $params + * + * @param array|ArrayAccess|object $params * @return Event * @throws Exception\InvalidArgumentException */ @@ -113,7 +113,7 @@ public function setParams($params) /** * Get all parameters - * + * * @return array|object|ArrayAccess */ public function getParams() @@ -125,9 +125,9 @@ public function getParams() * Get an individual parameter * * If the parameter does not exist, the $default value will be returned. - * - * @param string|int $name - * @param mixed $default + * + * @param string|int $name + * @param mixed $default * @return mixed */ public function getParam($name, $default = null) @@ -150,8 +150,8 @@ public function getParam($name, $default = null) /** * Set the event name - * - * @param string $name + * + * @param string $name * @return Event */ public function setName($name) @@ -162,8 +162,8 @@ public function setName($name) /** * Set the event target/context - * - * @param null|string|object $target + * + * @param null|string|object $target * @return Event */ public function setTarget($target) @@ -174,9 +174,9 @@ public function setTarget($target) /** * Set an individual parameter to a value - * - * @param string|int $name - * @param mixed $value + * + * @param string|int $name + * @param mixed $value * @return Event */ public function setParam($name, $value) @@ -193,8 +193,8 @@ public function setParam($name, $value) /** * Stop further event propagation - * - * @param bool $flag + * + * @param bool $flag * @return void */ public function stopPropagation($flag = true) @@ -204,7 +204,7 @@ public function stopPropagation($flag = true) /** * Is propagation stopped? - * + * * @return bool */ public function propagationIsStopped() diff --git a/src/EventInterface.php b/src/EventInterface.php index 3b7cf84..7b1e780 100644 --- a/src/EventInterface.php +++ b/src/EventInterface.php @@ -22,29 +22,29 @@ interface EventInterface { /** * Get event name - * + * * @return string */ public function getName(); /** * Get target/context from which event was triggered - * + * * @return null|string|object */ public function getTarget(); /** * Get parameters passed to the event - * + * * @return array|ArrayAccess */ public function getParams(); /** * Get a single parameter by name - * - * @param string $name + * + * @param string $name * @param mixed $default Default value to return if parameter does not exist * @return mixed */ @@ -52,48 +52,48 @@ public function getParam($name, $default = null); /** * Set the event name - * - * @param string $name + * + * @param string $name * @return void */ public function setName($name); /** * Set the event target/context - * - * @param null|string|object $target + * + * @param null|string|object $target * @return void */ public function setTarget($target); /** * Set event parameters - * - * @param string $params + * + * @param string $params * @return void */ public function setParams($params); /** * Set a single parameter by key - * - * @param string $name - * @param mixed $value + * + * @param string $name + * @param mixed $value * @return void */ public function setParam($name, $value); /** * Indicate whether or not the parent EventManagerInterface should stop propagating events - * - * @param bool $flag + * + * @param bool $flag * @return void */ public function stopPropagation($flag = true); /** * Has this event indicated event propagation should stop? - * + * * @return bool */ public function propagationIsStopped(); diff --git a/src/EventManager.php b/src/EventManager.php index 95506fb..fc2eb38 100644 --- a/src/EventManager.php +++ b/src/EventManager.php @@ -90,7 +90,7 @@ public function setSharedManager(SharedEventManagerInterface $sharedEventManager /** * Remove any shared event manager currently attached - * + * * @return void */ public function unsetSharedManager() @@ -246,7 +246,7 @@ public function triggerUntil($event, $target, $argv = null, $callback = null) * executed. By default, this value is 1; however, you may set it for any * integer value. Higher values have higher priority (i.e., execute first). * - * You can specify "*" for the event name. In such cases, the listener will + * You can specify "*" for the event name. In such cases, the listener will * be triggered for every event. * * @param string|array|ListenerAggregateInterface $event An event or array of event names. If a ListenerAggregateInterface, proxies to {@link attachAggregate()}. @@ -509,9 +509,9 @@ protected function getSharedListeners($event) * Add listeners to the master queue of listeners * * Used to inject shared listeners and wildcard listeners. - * - * @param PriorityQueue $masterListeners - * @param PriorityQueue $listeners + * + * @param PriorityQueue $masterListeners + * @param PriorityQueue $listeners * @return void */ protected function insertListeners($masterListeners, $listeners) diff --git a/src/EventManagerAwareInterface.php b/src/EventManagerAwareInterface.php index a672692..c01c79b 100644 --- a/src/EventManagerAwareInterface.php +++ b/src/EventManagerAwareInterface.php @@ -21,7 +21,7 @@ interface EventManagerAwareInterface extends EventsCapableInterface { /** * Inject an EventManager instance - * + * * @param EventManagerInterface $eventManager * @return void */ diff --git a/src/EventManagerInterface.php b/src/EventManagerInterface.php index 6d44026..ce8cdf2 100644 --- a/src/EventManagerInterface.php +++ b/src/EventManagerInterface.php @@ -32,11 +32,11 @@ interface EventManagerInterface extends SharedEventManagerAwareInterface * - Passing event name, target, and array|ArrayAccess of arguments * * Can emulate triggerUntil() if the last argument provided is a callback. - * - * @param string $event - * @param object|string $target - * @param array|object $argv - * @param null|callback $callback + * + * @param string $event + * @param object|string $target + * @param array|object $argv + * @param null|callback $callback * @return ResponseCollection */ public function trigger($event, $target = null, $argv = array(), $callback = null); @@ -49,19 +49,19 @@ public function trigger($event, $target = null, $argv = array(), $callback = nul * - Passing event name, Event object, and callback only * - Passing event name, target, Event object, and callback * - Passing event name, target, array|ArrayAccess of arguments, and callback - * - * @param string $event - * @param object|string $target - * @param array|object $argv - * @param callback $callback + * + * @param string $event + * @param object|string $target + * @param array|object $argv + * @param callback $callback * @return ResponseCollection */ public function triggerUntil($event, $target, $argv = null, $callback = null); /** * Attach a listener to an event - * - * @param string $event + * + * @param string $event * @param callback $callback * @param int $priority Priority at which to register listener * @return CallbackHandler @@ -70,31 +70,31 @@ public function attach($event, $callback = null, $priority = 1); /** * Detach an event listener - * - * @param CallbackHandler|ListenerAggregateInterface $listener + * + * @param CallbackHandler|ListenerAggregateInterface $listener * @return bool */ public function detach($listener); /** * Get a list of events for which this collection has listeners - * + * * @return array */ public function getEvents(); /** * Retrieve a list of listeners registered to a given event - * - * @param string $event + * + * @param string $event * @return array|object */ public function getListeners($event); /** * Clear all listeners for a given event - * - * @param string $event + * + * @param string $event * @return void */ public function clearListeners($event); diff --git a/src/Filter/FilterInterface.php b/src/Filter/FilterInterface.php index 2fbd70e..2622612 100644 --- a/src/Filter/FilterInterface.php +++ b/src/Filter/FilterInterface.php @@ -23,46 +23,46 @@ interface FilterInterface { /** * Execute the filter chain - * - * @param string|object $context - * @param array $params + * + * @param string|object $context + * @param array $params * @return mixed */ public function run($context, array $params = array()); /** * Attach an intercepting filter - * - * @param callback $callback + * + * @param callback $callback * @return CallbackHandler */ public function attach($callback); /** * Detach an intercepting filter - * - * @param CallbackHandler $filter + * + * @param CallbackHandler $filter * @return bool */ public function detach(CallbackHandler $filter); /** * Get all intercepting filters - * + * * @return array */ public function getFilters(); /** * Clear all filters - * + * * @return void */ public function clearFilters(); /** * Get all filter responses - * + * * @return ResponseCollection */ public function getResponses(); diff --git a/src/Filter/FilterIterator.php b/src/Filter/FilterIterator.php index 4704f0b..5fb30c8 100644 --- a/src/Filter/FilterIterator.php +++ b/src/Filter/FilterIterator.php @@ -14,7 +14,7 @@ use Zend\Stdlib\SplPriorityQueue; /** - * Specialized priority queue implementation for use with an intercepting + * Specialized priority queue implementation for use with an intercepting * filter chain. * * Allows removal @@ -26,8 +26,8 @@ class FilterIterator extends SplPriorityQueue { /** * Does the queue contain a given value? - * - * @param mixed $datum + * + * @param mixed $datum * @return bool */ public function contains($datum) @@ -46,8 +46,8 @@ public function contains($datum) * * This is an expensive operation. It must first iterate through all values, * and then re-populate itself. Use only if absolutely necessary. - * - * @param mixed $datum + * + * @param mixed $datum * @return bool */ public function remove($datum) @@ -80,10 +80,10 @@ public function remove($datum) * Iterate the next filter in the chain * * Iterates and calls the next filter in the chain. - * - * @param mixed $context - * @param array $params - * @param FilterIterator $chain + * + * @param mixed $context + * @param array $params + * @param FilterIterator $chain * @return mixed */ public function next($context = null, array $params = array(), $chain = null) diff --git a/src/FilterChain.php b/src/FilterChain.php index 4f68216..8cab413 100644 --- a/src/FilterChain.php +++ b/src/FilterChain.php @@ -39,7 +39,7 @@ public function __construct() * Apply the filters * * Begins iteration of the filters. - * + * * @param mixed $context Object under observation * @param mixed $argv Associative array of arguments * @return mixed @@ -62,7 +62,7 @@ public function run($context, array $argv = array()) /** * Connect a filter to the chain - * + * * @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) @@ -80,8 +80,8 @@ public function attach($callback, $priority = 1) /** * Detach a filter from the chain - * - * @param CallbackHandler $filter + * + * @param CallbackHandler $filter * @return bool Returns true if filter found and unsubscribed; returns false otherwise */ public function detach(CallbackHandler $filter) @@ -91,7 +91,7 @@ public function detach(CallbackHandler $filter) /** * Retrieve all filters - * + * * @return Filter\FilterIterator */ public function getFilters() @@ -101,7 +101,7 @@ public function getFilters() /** * Clear all filters - * + * * @return void */ public function clearFilters() @@ -112,9 +112,9 @@ public function clearFilters() /** * Return current responses * - * Only available while the chain is still being iterated. Returns the + * Only available while the chain is still being iterated. Returns the * current ResponseCollection. - * + * * @return null|ResponseCollection */ public function getResponses() diff --git a/src/GlobalEventManager.php b/src/GlobalEventManager.php index 0654eaa..50d2951 100644 --- a/src/GlobalEventManager.php +++ b/src/GlobalEventManager.php @@ -17,7 +17,7 @@ /** * Event manager: notification system * - * Use the EventManager when you want to create a per-instance notification + * Use the EventManager when you want to create a per-instance notification * system for your objects. * * @category Zend @@ -32,7 +32,7 @@ class GlobalEventManager /** * Set the event collection on which this will operate - * + * * @param null|EventManagerInterface $events * @return void */ @@ -43,7 +43,7 @@ public static function setEventCollection(EventManagerInterface $events = null) /** * Get event collection on which this operates - * + * * @return EventManagerInterface */ public static function getEventCollection() @@ -56,10 +56,10 @@ public static function getEventCollection() /** * Trigger an event - * - * @param string $event - * @param object|string $context - * @param array|object $argv + * + * @param string $event + * @param object|string $context + * @param array|object $argv * @return ResponseCollection */ public static function trigger($event, $context, $argv = array()) @@ -68,13 +68,13 @@ public static function trigger($event, $context, $argv = array()) } /** - * Trigger listeners until return value of one causes a callback to evaluate + * Trigger listeners until return value of one causes a callback to evaluate * to true. - * - * @param string $event - * @param string|object $context - * @param array|object $argv - * @param callback $callback + * + * @param string $event + * @param string|object $context + * @param array|object $argv + * @param callback $callback * @return ResponseCollection */ public static function triggerUntil($event, $context, $argv, $callback) @@ -84,10 +84,10 @@ public static function triggerUntil($event, $context, $argv, $callback) /** * Attach a listener to an event - * - * @param string $event - * @param callback $callback - * @param int $priority + * + * @param string $event + * @param callback $callback + * @param int $priority * @return CallbackHandler */ public static function attach($event, $callback, $priority = 1) @@ -97,8 +97,8 @@ public static function attach($event, $callback, $priority = 1) /** * Detach a callback from a listener - * - * @param CallbackHandler $listener + * + * @param CallbackHandler $listener * @return bool */ public static function detach(CallbackHandler $listener) @@ -108,7 +108,7 @@ public static function detach(CallbackHandler $listener) /** * Retrieve list of events this object manages - * + * * @return array */ public static function getEvents() @@ -118,8 +118,8 @@ public static function getEvents() /** * Retrieve all listeners for a given event - * - * @param string $event + * + * @param string $event * @return PriorityQueue|array */ public static function getListeners($event) @@ -129,8 +129,8 @@ public static function getListeners($event) /** * Clear all listeners for a given event - * - * @param string $event + * + * @param string $event * @return void */ public static function clearListeners($event) diff --git a/src/ProvidesEvents.php b/src/ProvidesEvents.php index 88dce42..a6fec25 100644 --- a/src/ProvidesEvents.php +++ b/src/ProvidesEvents.php @@ -18,7 +18,7 @@ * @category Zend * @package Zend_EventManager */ -trait ProvidesEvents +trait ProvidesEvents { /** * @var EventManagerInterface @@ -27,7 +27,7 @@ trait ProvidesEvents /** * Set the event manager instance used by this context - * + * * @param EventManagerInterface $events * @return mixed */ @@ -54,7 +54,7 @@ public function setEventManager(EventManagerInterface $events) * Retrieve the event manager * * Lazy-loads an EventManager instance if none registered. - * + * * @return EventManagerInterface */ public function getEventManager() diff --git a/src/ResponseCollection.php b/src/ResponseCollection.php index e0a46ba..546b18a 100644 --- a/src/ResponseCollection.php +++ b/src/ResponseCollection.php @@ -24,7 +24,7 @@ class ResponseCollection extends SplStack /** * Did the last response provided trigger a short circuit of the stack? - * + * * @return bool */ public function stopped() @@ -34,8 +34,8 @@ public function stopped() /** * Mark the collection as stopped (or its opposite) - * - * @param bool $flag + * + * @param bool $flag * @return ResponseCollection */ public function setStopped($flag) diff --git a/src/SharedEventManager.php b/src/SharedEventManager.php index db02a6f..1b96d0c 100644 --- a/src/SharedEventManager.php +++ b/src/SharedEventManager.php @@ -17,7 +17,7 @@ * Shared/contextual EventManager * * Allows attaching to EMs composed by other classes without having an instance first. - * The assumption is that the SharedEventManager will be injected into EventManager + * The assumption is that the SharedEventManager will be injected into EventManager * instances, and then queried for additional listeners when triggering an event. * * @category Zend @@ -34,8 +34,8 @@ class SharedEventManager implements SharedEventManagerInterface /** * Attach a listener to an event * - * Allows attaching a callback to an event offerred by one or more - * identifying components. As an example, the following connects to the + * Allows attaching a callback to an event offerred by one or more + * identifying components. As an example, the following connects to the * "getAll" event of both an AbstractResource and EntityResource: * * @@ -54,9 +54,9 @@ class SharedEventManager implements SharedEventManagerInterface * } * ); * - * + * * @param string|array $id Identifier(s) for event emitting component(s) - * @param string $event + * @param string $event * @param callback $callback PHP Callback * @param int $priority Priority at which listener should execute * @return void @@ -74,9 +74,9 @@ public function attach($id, $event, $callback, $priority = 1) /** * Detach a listener from an event offered by a given resource - * + * * @param string|int $id - * @param CallbackHandler $listener + * @param CallbackHandler $listener * @return bool Returns true if event and listener found, and unsubscribed; returns false if either event or listener not found */ public function detach($id, CallbackHandler $listener) @@ -89,7 +89,7 @@ public function detach($id, CallbackHandler $listener) /** * Retrieve all registered events for a given resource - * + * * @param string|int $id * @return array */ @@ -103,9 +103,9 @@ public function getEvents($id) /** * Retrieve all listeners for a given identifier and event - * + * * @param string|int $id - * @param string|int $event + * @param string|int $event * @return false|PriorityQueue */ public function getListeners($id, $event) @@ -118,9 +118,9 @@ public function getListeners($id, $event) /** * Clear all listeners for a given identifier, optionally for a specific event - * - * @param string|int $id - * @param null|string $event + * + * @param string|int $id + * @param null|string $event * @return bool */ public function clearListeners($id, $event = null) diff --git a/src/SharedEventManagerAwareInterface.php b/src/SharedEventManagerAwareInterface.php index c69adc3..bdc7cef 100644 --- a/src/SharedEventManagerAwareInterface.php +++ b/src/SharedEventManagerAwareInterface.php @@ -21,7 +21,7 @@ interface SharedEventManagerAwareInterface { /** * Inject a SharedEventManager instance - * + * * @param SharedEventManagerInterface $sharedEventManager * @return SharedEventManagerAwareInterface */ diff --git a/src/StaticEventManager.php b/src/StaticEventManager.php index 19e33bf..3406a3d 100644 --- a/src/StaticEventManager.php +++ b/src/StaticEventManager.php @@ -27,7 +27,7 @@ class StaticEventManager extends SharedEventManager /** * Singleton - * + * * @return void */ protected function __construct() @@ -45,7 +45,7 @@ private function __clone() /** * Retrieve instance - * + * * @return StaticEventManager */ public static function getInstance() @@ -58,7 +58,7 @@ public static function getInstance() /** * Reset the singleton instance - * + * * @return void */ public static function resetInstance() diff --git a/test/StaticIntegrationTest.php b/test/StaticIntegrationTest.php index 20b067f..41e52f7 100644 --- a/test/StaticIntegrationTest.php +++ b/test/StaticIntegrationTest.php @@ -32,8 +32,8 @@ public function testCanConnectStaticallyToClassWithEvents() $counter = (object) array('count' => 0); $events = StaticEventManager::getInstance(); $events->attach( - 'ZendTest\EventManager\TestAsset\ClassWithEvents', - 'foo', + 'ZendTest\EventManager\TestAsset\ClassWithEvents', + 'foo', function ($e) use ($counter) { $counter->count++; } @@ -49,8 +49,8 @@ public function testLocalHandlersAreExecutedPriorToStaticHandlersWhenSetWithSame $test = (object) array('results' => array()); $events = StaticEventManager::getInstance(); $events->attach( - 'ZendTest\EventManager\TestAsset\ClassWithEvents', - 'foo', + 'ZendTest\EventManager\TestAsset\ClassWithEvents', + 'foo', function ($e) use ($test) { $test->results[] = 'static'; } @@ -69,8 +69,8 @@ public function testLocalHandlersAreExecutedInPriorityOrderRegardlessOfStaticOrL $test = (object) array('results' => array()); $events = StaticEventManager::getInstance(); $events->attach( - 'ZendTest\EventManager\TestAsset\ClassWithEvents', - 'foo', + 'ZendTest\EventManager\TestAsset\ClassWithEvents', + 'foo', function ($e) use ($test) { $test->results[] = 'static'; }, @@ -95,8 +95,8 @@ public function testCallingUnsetSharedManagerDisablesStaticManager() { $counter = (object) array('count' => 0); StaticEventManager::getInstance()->attach( - 'ZendTest\EventManager\TestAsset\ClassWithEvents', - 'foo', + 'ZendTest\EventManager\TestAsset\ClassWithEvents', + 'foo', function ($e) use ($counter) { $counter->count++; } @@ -111,8 +111,8 @@ public function testCanPassAlternateStaticConnectionsHolder() { $counter = (object) array('count' => 0); StaticEventManager::getInstance()->attach( - 'ZendTest\EventManager\TestAsset\ClassWithEvents', - 'foo', + 'ZendTest\EventManager\TestAsset\ClassWithEvents', + 'foo', function ($e) use ($counter) { $counter->count++; } @@ -130,8 +130,8 @@ public function testTriggerMergesPrioritiesOfStaticAndInstanceListeners() $test = (object) array('results' => array()); $events = StaticEventManager::getInstance(); $events->attach( - 'ZendTest\EventManager\TestAsset\ClassWithEvents', - 'foo', + 'ZendTest\EventManager\TestAsset\ClassWithEvents', + 'foo', function ($e) use ($test) { $test->results[] = 'static'; },