From: Michael M Slusarz Date: Sun, 22 Feb 2009 02:20:25 +0000 (-0700) Subject: New singleton style. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9a08f97b5fe9ddf4314954767e9d0847f200b808;p=horde.git New singleton style. --- diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index 1ea76b900..a55adc75b 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -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]; } /**