Attributes support proposal

From: Date: Mon, 18 Apr 2005 12:19:55 +0000
Subject: Attributes support proposal
Groups: php.internals 
Request: Send a blank email to internals+get-15989@lists.php.net to get a copy of this message
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

« previous php.internals (#15989) next »