From 9a08f97b5fe9ddf4314954767e9d0847f200b808 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Sat, 21 Feb 2009 19:20:25 -0700 Subject: [PATCH] New singleton style. --- imp/lib/Contents.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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]; } /** -- 2.11.0