cvs: php4 /pear PEAR.php
| From: | Richard Heyes | Date: | Mon, 08 Apr 2002 21:03:42 +0000 |
| Subject: | cvs: php4 /pear PEAR.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-3152@lists.php.net to get a copy of this message | ||
richard Mon Apr 8 17:03:42 2002 EDT
Modified files:
/php4/pear PEAR.php
Log:
* Added getStaticProperty() for static methods.
Index: php4/pear/PEAR.php
diff -u php4/pear/PEAR.php:1.36 php4/pear/PEAR.php:1.37
--- php4/pear/PEAR.php:1.36 Sat Apr 6 12:01:14 2002
+++ php4/pear/PEAR.php Mon Apr 8 17:03:41 2002
@@ -18,7 +18,7 @@
// | Tomas V.V.Cox <cox@idecnet.com> |
// +----------------------------------------------------------------------+
//
-// $Id: PEAR.php,v 1.36 2002/04/06 17:01:14 richard Exp $
+// $Id: PEAR.php,v 1.37 2002/04/08 21:03:41 richard Exp $
//
define('PEAR_ERROR_RETURN', 1);
@@ -171,6 +171,27 @@
if ($this->_debug) {
printf("PEAR destructor called, class=%s\n", get_class($this));
}
+ }
+
+ // }}}
+ // {{{ 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];
}
// }}}