From 7214eb6aec6b0199bd2877a39f0aff32ec57dd1c Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 8 Feb 2010 16:36:56 -0700 Subject: [PATCH] phpdoc; coding standards --- framework/Notification/lib/Horde/Notification.php | 7 ++-- .../Notification/lib/Horde/Notification/Event.php | 3 +- .../lib/Horde/Notification/Handler/Base.php | 42 ++++++++++------------ .../Horde/Notification/Handler/Decorator/Alarm.php | 13 ++++--- .../Notification/Handler/Decorator/Hordelog.php | 5 ++- .../Horde/Notification/Handler/Decorator/Log.php | 36 +++++++++---------- .../lib/Horde/Notification/Handler/Interface.php | 1 + .../lib/Horde/Notification/Listener/Audio.php | 6 ++-- .../lib/Horde/Notification/Listener/Mobile.php | 6 ++-- .../lib/Horde/Notification/Storage/Interface.php | 18 ++++------ .../lib/Horde/Notification/Storage/Session.php | 20 ++++------- .../test/Horde/Notification/AllTests.php | 2 -- .../test/Horde/Notification/Autoload.php | 4 +-- .../Notification/Class/Notification/EventTest.php | 2 -- .../Class/Notification/Handler/BaseTest.php | 4 +-- .../Notification/Handler/Decorator/AlarmTest.php | 4 +-- .../Handler/Decorator/HordelogTest.php | 4 +-- .../Notification/Handler/Decorator/LogTest.php | 4 +-- .../Class/Notification/Listener/AudioTest.php | 2 -- .../Class/Notification/Listener/JavascriptTest.php | 2 -- .../Class/Notification/Listener/MobileTest.php | 2 -- .../Class/Notification/Listener/StatusTest.php | 2 -- .../Class/Notification/ListenerTest.php | 2 -- .../Horde/Notification/Class/NotificationTest.php | 8 ++--- 24 files changed, 78 insertions(+), 121 deletions(-) diff --git a/framework/Notification/lib/Horde/Notification.php b/framework/Notification/lib/Horde/Notification.php index 49b9608a2..6b0b1bbfb 100644 --- a/framework/Notification/lib/Horde/Notification.php +++ b/framework/Notification/lib/Horde/Notification.php @@ -22,15 +22,15 @@ class Horde_Notification static protected $_instances = array(); /** - * Returns a reference to the global Notification handler, only + * Returns a reference to the global notification handler, only * creating it if it doesn't already exist. * * This method must be invoked as: - * $notification = Horde_Notification::singleton() + * $notification = Horde_Notification::singleton([$stack]); * * @param string $stack The name of the message stack to use. * - * return Horde_Notification_Handler The Horde Notification handler. + * return Horde_Notification_Handler The Horde Notification handler. */ static public function singleton($stack = 'horde_notification_stacks') { @@ -49,4 +49,5 @@ class Horde_Notification return self::$_instances[$stack]; } + } diff --git a/framework/Notification/lib/Horde/Notification/Event.php b/framework/Notification/lib/Horde/Notification/Event.php index bc7cda22c..03bc615b9 100644 --- a/framework/Notification/lib/Horde/Notification/Event.php +++ b/framework/Notification/lib/Horde/Notification/Event.php @@ -1,7 +1,6 @@ _storage = $storage; } @@ -105,9 +104,9 @@ implements Horde_Notification_Handler_Interface throw new Horde_Exception(sprintf('Notification listener %s not found.', $listener)); } - $listener_instance = $this->_listeners[$listener]; + $instance = $this->_listeners[$listener]; unset($this->_listeners[$listener]); - $this->_storage->clear($listener_instance->getName()); + $this->_storage->clear($instance->getName()); } /** @@ -182,6 +181,9 @@ implements Horde_Notification_Handler_Interface * * @param array $options An array containing display options for the * listeners. + *
+     * 'listeners' - The list of listeners to notify.
+     * 
*/ public function notify(array $options = array()) { @@ -195,21 +197,24 @@ implements Horde_Notification_Handler_Interface * * @param array $options An array containing display options for the * listeners. + * + * @return array The list of listeners to notify. */ public function setNotificationListeners(array $options) { if (!isset($options['listeners'])) { - $options['listeners'] = $this->getListeners(); + $options['listeners'] = array_keys($this->_listeners); } elseif (!is_array($options['listeners'])) { $options['listeners'] = array($options['listeners']); } $options['listeners'] = array_map(array('Horde_String', 'lower'), $options['listeners']); + return $options; } /** - * Passes the message stack to all listeners and asks them to - * handle their messages. + * Passes the message stack to all listeners and asks them to handle + * their messages. * * @param array $options An array containing display options for the * listeners. This array is required to contain the @@ -220,12 +225,7 @@ implements Horde_Notification_Handler_Interface { foreach ($options['listeners'] as $listener) { if (isset($this->_listeners[$listener])) { - $this->_listeners[$listener]->notify( - $this->_storage->get( - $this->_listeners[$listener]->getName() - ), - $options - ); + $this->_listeners[$listener]->notify($this->_storage->get($this->_listeners[$listener]->getName()), $options); } } } @@ -249,13 +249,9 @@ implements Horde_Notification_Handler_Interface } } return $count; - } else { - return @count($this->_storage->get($this->_listeners[Horde_String::lower($my_listener)]->getName())); } - } - protected function getListeners() - { - return array_keys($this->_listeners); + return @count($this->_storage->get($this->_listeners[Horde_String::lower($my_listener)]->getName())); } + } diff --git a/framework/Notification/lib/Horde/Notification/Handler/Decorator/Alarm.php b/framework/Notification/lib/Horde/Notification/Handler/Decorator/Alarm.php index 92a5e109c..efab2c2ee 100644 --- a/framework/Notification/lib/Horde/Notification/Handler/Decorator/Alarm.php +++ b/framework/Notification/lib/Horde/Notification/Handler/Decorator/Alarm.php @@ -31,14 +31,13 @@ implements Horde_Notification_Handler_Interface * Initialize the notification system, set up any needed session * variables, etc. * - * @param Horde_Notification_Handler $handler The handler this instance - * provides with logging. - * @param Horde_Alarm $alarm The alarm system to notify. + * @param Horde_Notification_Handler $handler The handler this instance + * provides with logging. + * @param Horde_Alarm $alarm The alarm system to notify. */ - public function __construct( - Horde_Notification_Handler_Interface $handler, - Horde_Alarm $alarm - ) { + public function __construct(Horde_Notification_Handler_Interface $handler, + Horde_Alarm $alarm) + { $this->_handler = $handler; $this->_alarm = $alarm; } diff --git a/framework/Notification/lib/Horde/Notification/Handler/Decorator/Hordelog.php b/framework/Notification/lib/Horde/Notification/Handler/Decorator/Hordelog.php index ccdacbba6..506017c87 100644 --- a/framework/Notification/lib/Horde/Notification/Handler/Decorator/Hordelog.php +++ b/framework/Notification/lib/Horde/Notification/Handler/Decorator/Hordelog.php @@ -28,9 +28,8 @@ implements Horde_Notification_Handler_Interface * @param Horde_Notification_Handler $handler The handler this instance * provides with logging. */ - public function __construct( - Horde_Notification_Handler_Interface $handler - ) { + public function __construct(Horde_Notification_Handler_Interface $handler) + { $this->_handler = $handler; } diff --git a/framework/Notification/lib/Horde/Notification/Handler/Decorator/Log.php b/framework/Notification/lib/Horde/Notification/Handler/Decorator/Log.php index 0bad3daf6..bd0c395fd 100644 --- a/framework/Notification/lib/Horde/Notification/Handler/Decorator/Log.php +++ b/framework/Notification/lib/Horde/Notification/Handler/Decorator/Log.php @@ -32,20 +32,21 @@ implements Horde_Notification_Handler_Interface * Initialize the notification system, set up any needed session * variables, etc. * - * @param Horde_Notification_Handler $handler The handler this instance - * provides with logging. - * - * @param mixed $logger The log handler. The provided - * instance is required to - * implement the debug() function. - * You should be able to use a - * common Logger here (PEAR Log, - * Horde_Log_Logger, or Zend_Log). + * @param Horde_Notification_Handler $handler The handler this instance + * provides with logging. + * + * @param mixed $logger The log handler. The + * provided instance is + * required to implement the + * debug() function. You + * should be able to use a + * common Logger here (PEAR + * Log, Horde_Log_Logger, or + * Zend_Log). */ - public function __construct( - Horde_Notification_Handler_Interface $handler, - $logger - ) { + public function __construct(Horde_Notification_Handler_Interface $handler, + $logger) + { $this->_handler = $handler; $this->_logger = $logger; } @@ -122,11 +123,9 @@ implements Horde_Notification_Handler_Interface public function push($event, $type = null, array $flags = array()) { if ($event instanceof PEAR_Error || $event instanceof Exception) { - /** - * Some loggers only accept string messages. As both PEAR_Error and - * Exception accept being casted into a string we can ensure that - * the logger receives a string here. - */ + /* Some loggers only accept string messages. As both PEAR_Error + * and Exception accept being casted into a string we can ensure + * that the logger receives a string here. */ $this->_logger->debug((string) $event); } $this->_handler->push($event, $type, $flags); @@ -183,4 +182,5 @@ implements Horde_Notification_Handler_Interface { return $this->_handler->count($my_listener); } + } diff --git a/framework/Notification/lib/Horde/Notification/Handler/Interface.php b/framework/Notification/lib/Horde/Notification/Handler/Interface.php index d2fc04940..b3bb26d29 100644 --- a/framework/Notification/lib/Horde/Notification/Handler/Interface.php +++ b/framework/Notification/lib/Horde/Notification/Handler/Interface.php @@ -114,4 +114,5 @@ interface Horde_Notification_Handler_Interface * @return integer The number of messages in the stack. */ public function count($my_listener = null); + } diff --git a/framework/Notification/lib/Horde/Notification/Listener/Audio.php b/framework/Notification/lib/Horde/Notification/Listener/Audio.php index 5ad5af1aa..364e1000a 100644 --- a/framework/Notification/lib/Horde/Notification/Listener/Audio.php +++ b/framework/Notification/lib/Horde/Notification/Listener/Audio.php @@ -18,7 +18,9 @@ class Horde_Notification_Listener_Audio extends Horde_Notification_Listener */ public function __construct() { - $this->_handles = array('audio' => ''); + $this->_handles = array( + 'audio' => '' + ); $this->_name = 'audio'; } @@ -27,7 +29,7 @@ class Horde_Notification_Listener_Audio extends Horde_Notification_Listener * 'audio' message stack. * * @param array &$messageStack The stack of messages. - * @param array $options An array of options. + * @param array $options An array of options (not used). */ public function notify(&$messageStack, $options = array()) { diff --git a/framework/Notification/lib/Horde/Notification/Listener/Mobile.php b/framework/Notification/lib/Horde/Notification/Listener/Mobile.php index c9de80768..fbb2a2569 100644 --- a/framework/Notification/lib/Horde/Notification/Listener/Mobile.php +++ b/framework/Notification/lib/Horde/Notification/Listener/Mobile.php @@ -39,9 +39,9 @@ class Horde_Notification_Listener_Mobile extends Horde_Notification_Listener_Sta * * @param Horde_Mobile The Horde_Mobile:: object to send status lines to. */ - public function setMobileObject(&$mobile) + public function setMobileObject($mobile) { - $this->_mobile = &$mobile; + $this->_mobile = $mobile; } /** @@ -49,7 +49,7 @@ class Horde_Notification_Listener_Mobile extends Horde_Notification_Listener_Sta * message stack. * * @param array &$messageStack The stack of messages. - * @param array $options An array of options. Options: 'nospace' + * @param array $options An array of options. */ public function notify(&$messageStack, $options = array()) { diff --git a/framework/Notification/lib/Horde/Notification/Storage/Interface.php b/framework/Notification/lib/Horde/Notification/Storage/Interface.php index 7680bde82..30ef1b235 100644 --- a/framework/Notification/lib/Horde/Notification/Storage/Interface.php +++ b/framework/Notification/lib/Horde/Notification/Storage/Interface.php @@ -2,8 +2,6 @@ /** * An interface describing a storage location for notification messages. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel @@ -30,9 +28,9 @@ interface Horde_Notification_Storage_Interface /** * Return the given stack by reference from the notification store. * - * @param string $key The key for the data. + * @param string $key The key for the data. * - * @return mixed The notification data stored for the given key. + * @return mixed The notification data stored for the given key. */ public function &get($key); @@ -40,27 +38,23 @@ interface Horde_Notification_Storage_Interface * Set the given stack in the notification store. * * @param string $key The key for the data. - * @param mixed $value The data. - * - * @return NULL + * @param mixed $value The data. */ public function set($key, $value); /** * Is the given stack present in the notification store? * - * @param string $key The key of the data. + * @param string $key The key of the data. * - * @return boolean True if the element is set, false otherwise. + * @return boolean True if the element is set, false otherwise. */ public function exists($key); /** * Unset the given stack in the notification store. * - * @param string $key The key of the data. - * - * @return NULL + * @param string $key The key of the data. */ public function clear($key); diff --git a/framework/Notification/lib/Horde/Notification/Storage/Session.php b/framework/Notification/lib/Horde/Notification/Storage/Session.php index f58da07de..fc10d24a7 100644 --- a/framework/Notification/lib/Horde/Notification/Storage/Session.php +++ b/framework/Notification/lib/Horde/Notification/Storage/Session.php @@ -2,8 +2,6 @@ /** * A class that stores notifications in the session. * - * PHP version 5 - * * @category Horde * @package Horde_Notification * @author Gunnar Wrobel @@ -38,7 +36,7 @@ implements Horde_Notification_Storage_Interface /** * Constructor. * - * @param string $stack The name of the notification stack. + * @param string $stack The name of the notification stack. */ public function __construct($stack) { @@ -53,9 +51,9 @@ implements Horde_Notification_Storage_Interface /** * Return the given stack by reference from the notification store. * - * @param string $key The key for the data. + * @param string $key The key for the data. * - * @return mixed The notification data stored for the given key. + * @return mixed The notification data stored for the given key. */ public function &get($key) { @@ -66,9 +64,7 @@ implements Horde_Notification_Storage_Interface * Set the given stack in the notification store. * * @param string $key The key for the data. - * @param mixed $value The data. - * - * @return NULL + * @param mixed $value The data. */ public function set($key, $value) { @@ -78,9 +74,9 @@ implements Horde_Notification_Storage_Interface /** * Is the given stack present in the notification store? * - * @param string $key The key of the data. + * @param string $key The key of the data. * - * @return boolean True if the element is set, false otherwise. + * @return boolean True if the element is set, false otherwise. */ public function exists($key) { @@ -90,9 +86,7 @@ implements Horde_Notification_Storage_Interface /** * Unset the given stack in the notification store. * - * @param string $key The key of the data. - * - * @return NULL + * @param string $key The key of the data. */ public function clear($key) { diff --git a/framework/Notification/test/Horde/Notification/AllTests.php b/framework/Notification/test/Horde/Notification/AllTests.php index e7045cfd2..61245374e 100644 --- a/framework/Notification/test/Horde/Notification/AllTests.php +++ b/framework/Notification/test/Horde/Notification/AllTests.php @@ -2,8 +2,6 @@ /** * All tests for the Horde_Notification package. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel diff --git a/framework/Notification/test/Horde/Notification/Autoload.php b/framework/Notification/test/Horde/Notification/Autoload.php index 491bbee4b..f7390dba9 100644 --- a/framework/Notification/test/Horde/Notification/Autoload.php +++ b/framework/Notification/test/Horde/Notification/Autoload.php @@ -2,8 +2,6 @@ /** * Setup autoloading for the tests. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel @@ -14,7 +12,7 @@ if (!spl_autoload_functions()) { spl_autoload_register( create_function( - '$class', + '$class', '$filename = str_replace(array(\'::\', \'_\'), \'/\', $class);' . '$err_mask = E_ALL ^ E_WARNING;' . '$oldErrorReporting = error_reporting($err_mask);' diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/EventTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/EventTest.php index 031403002..43c87419f 100644 --- a/framework/Notification/test/Horde/Notification/Class/Notification/EventTest.php +++ b/framework/Notification/test/Horde/Notification/Class/Notification/EventTest.php @@ -2,8 +2,6 @@ /** * Test the basic event class. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/BaseTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/BaseTest.php index d000cabda..93323e6c1 100644 --- a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/BaseTest.php +++ b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/BaseTest.php @@ -2,8 +2,6 @@ /** * Test the basic notification handler class. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel @@ -218,4 +216,4 @@ class Horde_Notification_Listener_Dummy extends Horde_Notification_Listener public function getMessage($message, $options = array()) { } -} \ No newline at end of file +} diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php index 93431c873..7037488f7 100644 --- a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php +++ b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php @@ -2,8 +2,6 @@ /** * Test the alarm notification handler class. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel @@ -142,4 +140,4 @@ extends PHPUnit_Framework_TestCase $this->assertEquals(1, $this->alarm_handler->count('listener')); } -} \ No newline at end of file +} diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php index e0cbdcaec..bf4750ce1 100644 --- a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php +++ b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php @@ -2,8 +2,6 @@ /** * Test the notification handler class that logs to the horde log. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel @@ -136,4 +134,4 @@ extends PHPUnit_Framework_TestCase $this->assertEquals(1, $this->logged_handler->count('listener')); } -} \ No newline at end of file +} diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php index 8ad170326..056abfbc0 100644 --- a/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php +++ b/framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php @@ -2,8 +2,6 @@ /** * Test the logging notification handler class. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel @@ -135,4 +133,4 @@ extends PHPUnit_Framework_TestCase $this->assertEquals(1, $this->logged_handler->count('listener')); } -} \ No newline at end of file +} diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Listener/AudioTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Listener/AudioTest.php index 856db9699..b629ad4ac 100644 --- a/framework/Notification/test/Horde/Notification/Class/Notification/Listener/AudioTest.php +++ b/framework/Notification/test/Horde/Notification/Class/Notification/Listener/AudioTest.php @@ -2,8 +2,6 @@ /** * Test the audio listener class. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Listener/JavascriptTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Listener/JavascriptTest.php index 6c7474101..0dbaa4696 100644 --- a/framework/Notification/test/Horde/Notification/Class/Notification/Listener/JavascriptTest.php +++ b/framework/Notification/test/Horde/Notification/Class/Notification/Listener/JavascriptTest.php @@ -2,8 +2,6 @@ /** * Test the javascript listener class. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Listener/MobileTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Listener/MobileTest.php index e879dd548..951b8cd83 100644 --- a/framework/Notification/test/Horde/Notification/Class/Notification/Listener/MobileTest.php +++ b/framework/Notification/test/Horde/Notification/Class/Notification/Listener/MobileTest.php @@ -2,8 +2,6 @@ /** * Test the mobile listener class. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/Listener/StatusTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/Listener/StatusTest.php index 0167cad19..f6095620c 100644 --- a/framework/Notification/test/Horde/Notification/Class/Notification/Listener/StatusTest.php +++ b/framework/Notification/test/Horde/Notification/Class/Notification/Listener/StatusTest.php @@ -2,8 +2,6 @@ /** * Test the status listener class. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel diff --git a/framework/Notification/test/Horde/Notification/Class/Notification/ListenerTest.php b/framework/Notification/test/Horde/Notification/Class/Notification/ListenerTest.php index 3f3e50258..becbc6c8f 100644 --- a/framework/Notification/test/Horde/Notification/Class/Notification/ListenerTest.php +++ b/framework/Notification/test/Horde/Notification/Class/Notification/ListenerTest.php @@ -2,8 +2,6 @@ /** * Test the basic listener class. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel diff --git a/framework/Notification/test/Horde/Notification/Class/NotificationTest.php b/framework/Notification/test/Horde/Notification/Class/NotificationTest.php index 90dadede0..b036cc4a2 100644 --- a/framework/Notification/test/Horde/Notification/Class/NotificationTest.php +++ b/framework/Notification/test/Horde/Notification/Class/NotificationTest.php @@ -2,8 +2,6 @@ /** * Test the notification class. * - * PHP version 5 - * * @category Horde * @package Notification * @author Gunnar Wrobel @@ -46,8 +44,7 @@ class Horde_Notification_Class_NotificationTest extends PHPUnit_Framework_TestCa $this->markTestSkipped('The Horde_Alarm package is not installed!'); } - global $conf; - $conf['alarms']['driver'] = 'Mock'; + $GLOBALS['conf']['alarms']['driver'] = 'Mock'; $this->assertType( 'Horde_Notification_Handler_Decorator_Alarm', @@ -67,7 +64,6 @@ class Horde_Notification_Instance extends Horde_Notification static public function newInstance($stack) { $storage = new Horde_Notification_Storage_Session($stack); - $instance = new Horde_Notification_Handler_Base($storage); - return $instance; + return new Horde_Notification_Handler_Base($storage); } } -- 2.11.0