]> granicus.if.org Git - php/commitdiff
* Added getStaticProperty() for static methods.
authorRichard Heyes <richard@php.net>
Mon, 8 Apr 2002 21:03:41 +0000 (21:03 +0000)
committerRichard Heyes <richard@php.net>
Mon, 8 Apr 2002 21:03:41 +0000 (21:03 +0000)
pear/PEAR.php

index 2d4edd619cb6819682b28105ec02fd21d8121c66..b3ccf74fb34a10718afdf0073f91105bc6860f47 100644 (file)
@@ -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()