New singleton style.
authorMichael M Slusarz <slusarz@curecanti.org>
Sun, 22 Feb 2009 02:20:25 +0000 (19:20 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Sun, 22 Feb 2009 04:25:14 +0000 (21:25 -0700)
imp/lib/Contents.php

index 1ea76b9..a55adc7 100644 (file)
@@ -34,6 +34,13 @@ class IMP_Contents
     const RENDER_INLINE_AUTO = 16;
 
     /**
+     * Singleton instances
+     *
+     * @var array
+     */
+    static protected $_instances = array();
+
+    /**
      * The IMAP index of the message.
      *
      * @var integer
@@ -84,17 +91,15 @@ class IMP_Contents
      */
     static public function singleton($in)
     {
-        static $instance = array();
-
         $sig = is_a($in, 'Horde_Mime_Part')
             ? hash('md5', serialize($in))
             : $in;
 
-        if (empty($instance[$sig])) {
-            $instance[$sig] = new IMP_Contents($in);
+        if (empty(self::$_instances[$sig])) {
+            self::$_instances[$sig] = new IMP_Contents($in);
         }
 
-        return $instance[$sig];
+        return self::$_instances[$sig];
     }
 
     /**