From f006b2bbc3db5d32f260aacaaaf295c27f145f6b Mon Sep 17 00:00:00 2001 From: Richard Heyes Date: Mon, 8 Apr 2002 21:03:41 +0000 Subject: [PATCH] * Added getStaticProperty() for static methods. --- pear/PEAR.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pear/PEAR.php b/pear/PEAR.php index 2d4edd619c..b3ccf74fb3 100644 --- a/pear/PEAR.php +++ b/pear/PEAR.php @@ -173,6 +173,27 @@ class PEAR } } + // }}} + // {{{ getStaticProperty() + + /** + * If you have a class that's mostly/entirely static, and you need static + * properties, you can use this method to simulate them. Eg. in your method(s) + * do this: $myVar = &PEAR::getStaticProperty('myVar'); + * You MUST use a reference, or they will not persist! + * + * @access public + * @param string $class The calling classname, to prevent clashes + * @param string $var The variable to retrieve. + * @return mixed A reference to the variable. If not set it will be + * auto initialised to NULL. + */ + function &getStaticProperty($class, $var) + { + static $properties; + return $properties[$class][$var]; + } + // }}} // {{{ registerShutdownFunc() -- 2.50.1