From: Richard Heyes Date: Mon, 8 Apr 2002 21:03:41 +0000 (+0000) Subject: * Added getStaticProperty() for static methods. X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~788 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f006b2bbc3db5d32f260aacaaaf295c27f145f6b;p=php * Added getStaticProperty() for static methods. --- 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()