123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- class Foo {
- private static $hash;
- protected static function ensure_hash() {
- if (!isset(self::$hash)) {
- self::$hash = spl_object_hash(self);
- echo "Set hash to " . print_r(self::$hash, TRUE) . "\n";
- }
- }
- protected static function ensure_key($name) {
- $key = self::hash . '_' . $name;
- if (!property_exists(__CLASS__, $key)) {
- self::${$key} = NULL;
- }
- }
- public static function attr_reader() {
- $args = func_get_args();
- if (!empty($args)) {
- self::ensure_hash();
- foreach ($args as $name) {
- self::ensure_key($name);
- }
- }
- }
- public function attr_writer() {
- }
- public function attr_accessor() {
- }
- }
|