phpdoc; coding standards
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 8 Feb 2010 23:36:56 +0000 (16:36 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 9 Feb 2010 03:52:55 +0000 (20:52 -0700)
24 files changed:
framework/Notification/lib/Horde/Notification.php
framework/Notification/lib/Horde/Notification/Event.php
framework/Notification/lib/Horde/Notification/Handler/Base.php
framework/Notification/lib/Horde/Notification/Handler/Decorator/Alarm.php
framework/Notification/lib/Horde/Notification/Handler/Decorator/Hordelog.php
framework/Notification/lib/Horde/Notification/Handler/Decorator/Log.php
framework/Notification/lib/Horde/Notification/Handler/Interface.php
framework/Notification/lib/Horde/Notification/Listener/Audio.php
framework/Notification/lib/Horde/Notification/Listener/Mobile.php
framework/Notification/lib/Horde/Notification/Storage/Interface.php
framework/Notification/lib/Horde/Notification/Storage/Session.php
framework/Notification/test/Horde/Notification/AllTests.php
framework/Notification/test/Horde/Notification/Autoload.php
framework/Notification/test/Horde/Notification/Class/Notification/EventTest.php
framework/Notification/test/Horde/Notification/Class/Notification/Handler/BaseTest.php
framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php
framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php
framework/Notification/test/Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php
framework/Notification/test/Horde/Notification/Class/Notification/Listener/AudioTest.php
framework/Notification/test/Horde/Notification/Class/Notification/Listener/JavascriptTest.php
framework/Notification/test/Horde/Notification/Class/Notification/Listener/MobileTest.php
framework/Notification/test/Horde/Notification/Class/Notification/Listener/StatusTest.php
framework/Notification/test/Horde/Notification/Class/Notification/ListenerTest.php
framework/Notification/test/Horde/Notification/Class/NotificationTest.php

index 49b9608..6b0b1bb 100644 (file)
@@ -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];
     }
+
 }
index bc7cda2..03bc615 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 /**
- * The Horde_Notification_Event:: class provides a container for passing
- * messages to Horde_Notification_Listener classes.
+ * The Horde_Notification_Event:: class defines a single notification event.
  *
  * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
  *
index 0948ab1..bc512a4 100644 (file)
@@ -37,14 +37,13 @@ implements Horde_Notification_Handler_Interface
     protected $_alarm;
 
     /**
-     * Initialize the notification system, set up any needed session
-     * variables, etc.
+     * Initialize the notification system.
      *
-     * @param Horde_Notification_Storage $storage The storage location to use.
+     * @param Horde_Notification_Storage $storage  The storage location to
+     *                                             use.
      */
-    public function __construct(
-        Horde_Notification_Storage_Interface $storage
-    ) {
+    public function __construct(Horde_Notification_Storage_Interface $storage)
+    {
         $this->_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.
+     * <pre>
+     * 'listeners' - The list of listeners to notify.
+     * </pre>
      */
     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()));
     }
+
 }
index 92a5e10..efab2c2 100644 (file)
@@ -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;
     }
index ccdacbb..506017c 100644 (file)
@@ -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;
     }
 
index 0bad3da..bd0c395 100644 (file)
@@ -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);
     }
+
 }
index d2fc049..b3bb26d 100644 (file)
@@ -114,4 +114,5 @@ interface Horde_Notification_Handler_Interface
      * @return integer  The number of messages in the stack.
      */
     public function count($my_listener = null);
+
 }
index 5ad5af1..364e100 100644 (file)
@@ -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())
     {
index c9de807..fbb2a25 100644 (file)
@@ -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())
     {
index 7680bde..30ef1b2 100644 (file)
@@ -2,8 +2,6 @@
 /**
  * An interface describing a storage location for notification messages.
  *
- * PHP version 5
- *
  * @category Horde
  * @package  Notification
  * @author   Gunnar Wrobel <wrobel@pardus.de>
@@ -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);
 
index f58da07..fc10d24 100644 (file)
@@ -2,8 +2,6 @@
 /**
  * A class that stores notifications in the session.
  *
- * PHP version 5
- *
  * @category Horde
  * @package  Horde_Notification
  * @author   Gunnar Wrobel <wrobel@pardus.de>
@@ -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)
     {
index e7045cf..6124537 100644 (file)
@@ -2,8 +2,6 @@
 /**
  * All tests for the Horde_Notification package.
  *
- * PHP version 5
- *
  * @category Horde
  * @package  Notification
  * @author   Gunnar Wrobel <wrobel@pardus.de>
index 491bbee..f7390db 100644 (file)
@@ -2,8 +2,6 @@
 /**
  * Setup autoloading for the tests.
  *
- * PHP version 5
- *
  * @category Horde
  * @package  Notification
  * @author   Gunnar Wrobel <wrobel@pardus.de>
@@ -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);'
index 0314030..43c8741 100644 (file)
@@ -2,8 +2,6 @@
 /**
  * Test the basic event class.
  *
- * PHP version 5
- *
  * @category Horde
  * @package  Notification
  * @author   Gunnar Wrobel <wrobel@pardus.de>
index d000cab..93323e6 100644 (file)
@@ -2,8 +2,6 @@
 /**
  * Test the basic notification handler class.
  *
- * PHP version 5
- *
  * @category Horde
  * @package  Notification
  * @author   Gunnar Wrobel <wrobel@pardus.de>
@@ -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
+}
index 93431c8..7037488 100644 (file)
@@ -2,8 +2,6 @@
 /**
  * Test the alarm notification handler class.
  *
- * PHP version 5
- *
  * @category Horde
  * @package  Notification
  * @author   Gunnar Wrobel <wrobel@pardus.de>
@@ -142,4 +140,4 @@ extends PHPUnit_Framework_TestCase
         $this->assertEquals(1, $this->alarm_handler->count('listener'));
     }
 
-}
\ No newline at end of file
+}
index e0cbdca..bf4750c 100644 (file)
@@ -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 <wrobel@pardus.de>
@@ -136,4 +134,4 @@ extends PHPUnit_Framework_TestCase
         $this->assertEquals(1, $this->logged_handler->count('listener'));
     }
 
-}
\ No newline at end of file
+}
index 8ad1703..056abfb 100644 (file)
@@ -2,8 +2,6 @@
 /**
  * Test the logging notification handler class.
  *
- * PHP version 5
- *
  * @category Horde
  * @package  Notification
  * @author   Gunnar Wrobel <wrobel@pardus.de>
@@ -135,4 +133,4 @@ extends PHPUnit_Framework_TestCase
         $this->assertEquals(1, $this->logged_handler->count('listener'));
     }
 
-}
\ No newline at end of file
+}
index 3f3e502..becbc6c 100644 (file)
@@ -2,8 +2,6 @@
 /**
  * Test the basic listener class.
  *
- * PHP version 5
- *
  * @category Horde
  * @package  Notification
  * @author   Gunnar Wrobel <wrobel@pardus.de>
index 90daded..b036cc4 100644 (file)
@@ -2,8 +2,6 @@
 /**
  * Test the notification class.
  *
- * PHP version 5
- *
  * @category Horde
  * @package  Notification
  * @author   Gunnar Wrobel <wrobel@pardus.de>
@@ -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);
     }
 }