From 9be65c6b88e8271a8d93206b31b53c1deb212e1f Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@enhancesoft.com>
Date: Fri, 10 Jan 2014 01:12:36 +0000
Subject: [PATCH] Make list of subsribers static and private

---
 include/class.signal.php | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/include/class.signal.php b/include/class.signal.php
index 928c15c4d..424ccccc9 100644
--- a/include/class.signal.php
+++ b/include/class.signal.php
@@ -25,6 +25,8 @@
  * the codebase there exists a Signal::send() for the same named signal.
  */
 class Signal {
+    static private $subscribers = array();
+
     /**
      * Subscribe to a signal.
      *
@@ -51,10 +53,9 @@ class Signal {
      * signal handler. The function will receive the signal data and should
      * return true if the signal handler should be called.
      */
-    /*static*/ function connect($signal, $callable, $object=null,
+    static function connect($signal, $callable, $object=null,
             $check=null) {
-        global $_subscribers;
-        if (!isset($_subscribers[$signal])) $_subscribers[$signal] = array();
+        if (!isset(self::$subscribers[$signal])) self::$subscribers[$signal] = array();
         // XXX: Ensure $object if set is a class
         if ($object && !is_string($object))
             trigger_error("Invalid object: $object: Expected class");
@@ -62,7 +63,7 @@ class Signal {
             trigger_error("Invalid check function: Must be callable");
             $check = null;
         }
-        $_subscribers[$signal][] = array($object, $callable, $check);
+        self::$subscribers[$signal][] = array($object, $callable, $check);
     }
 
     /**
@@ -85,11 +86,10 @@ class Signal {
      * possible to propogate changes in the signal handlers back to the
      * originating context.
      */
-    /*static*/ function send($signal, $object, &$data=null) {
-        global $_subscribers;
-        if (!isset($_subscribers[$signal]))
+    static function send($signal, $object, &$data=null) {
+        if (!isset(self::$subscribers[$signal]))
             return;
-        foreach ($_subscribers[$signal] as $sub) {
+        foreach (self::$subscribers[$signal] as $sub) {
             list($s, $callable, $check) = $sub;
             if ($s && !is_a($object, $s))
                 continue;
@@ -99,6 +99,4 @@ class Signal {
         }
     }
 }
-
-$_subscribers = array();
 ?>
-- 
GitLab