php__phplib/misc/attributes.php

36 lines
No EOL
693 B
PHP

<?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() {
}
}