Hello,

I am playing around with an extension to the Zend Engine 2 to allow class 
properties and methods to be tagged with attributes. These attributes would 
then be accessible through the Reflection classes:

!---------- example -------------!
class Storable {

        [serializer:toString; persistent:true; ] public $date;

        function __construct() {
                $this->date = new CDate();
        }
        ...
        ...
}

$store = new Storable();

$rf = new ReflectionProperty("Storable","date");
$s = $rf->getAttributeValue("serializer");
if(!is_null($s) && method_exists($store, $s)) {
        $v = $store->date->$s();
} else {
        $v = $store->date;
}

echo "the value of the date property is $v";

!------------- /example -------------!

I would find the ability to set attributes extremely useful in building 
frameworks a la Ruby On Rails. 

Anyone think this is a good idea?

Duncan

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to