Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:15990 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5388 invoked by uid 1010); 18 Apr 2005 12:26:59 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 5373 invoked from network); 18 Apr 2005 12:26:59 -0000 Received: from unknown (HELO gmail.com) (127.0.0.1) by localhost with SMTP; 18 Apr 2005 12:26:59 -0000 X-Host-Fingerprint: 64.233.184.202 wproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.184.202:56028] helo=wproxy.gmail.com) by pb1.pair.com (ecelerity 1.2.12rc1 r(5476:5477)) with SMTP id 2D/54-18700-397A3624 for ; Mon, 18 Apr 2005 08:26:59 -0400 Received: by wproxy.gmail.com with SMTP id 57so1504818wri for ; Mon, 18 Apr 2005 05:26:55 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=AJ7IWhKH6eH/cGpvem9qfBtYmaRhQzP0FPjaVi+fLC9H5bGLUloI6SGuhMF6PYnzGii4hivXOWLE3HjPIO6W48og47g7sJ8MytRBd/m4F1V5x3xdoByxu++m21xMjEmHx09a43nEutbpblvnpWe31EJMHDRq00PlOwjFYSTx2A0= Received: by 10.54.32.51 with SMTP id f51mr2187024wrf; Mon, 18 Apr 2005 05:26:55 -0700 (PDT) Received: by 10.54.77.4 with HTTP; Mon, 18 Apr 2005 05:26:53 -0700 (PDT) Message-ID: <4e89b4260504180526455dabba@mail.gmail.com> Date: Mon, 18 Apr 2005 08:26:53 -0400 Reply-To: Wez Furlong To: Duncan McIntyre Cc: internals@lists.php.net In-Reply-To: <200504181319.56004.duncan@calligram.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <200504181319.56004.duncan@calligram.co.uk> Subject: Re: [PHP-DEV] Attributes support proposal From: kingwez@gmail.com (Wez Furlong) PHP has interfaces for this kind of thing, and they're clearer/cleaner to use than the code you've posted (for this case at least). It's also worth noting that the rendering of serialized data for an object is usually better handled by the class of that object, not its container. It is fine, of course, for the container to stick that serialized data somewhere else. Placing attributes in the container for this seems like a lot of extra work; you'd be repeating the same mantra for each class that contains and instance of the child class. From a technical viewpoint, how do these attributes affect the class?=20 Are they simply no-ops that are tagged and made available via the reflection API? How does this really help improve PHP? I know it sounds cool, but so does recording phpdoc comments, and we decided to not do that in the default case for performance reasons. How are these attributes much different from that? I'm not against the idea per-se, I just can't see a really good reason to justify it. --Wez. On 4/18/05, Duncan McIntyre wrote: > Hello, >=20 > 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 wou= ld > then be accessible through the Reflection classes: >=20 > !---------- example -------------! > class Storable { >=20 > [serializer:toString; persistent:true; ] public $date; >=20 > function __construct() { > $this->date =3D new CDate(); > } > ... > ... > } >=20 > $store =3D new Storable(); >=20 > $rf =3D new ReflectionProperty("Storable","date"); > $s =3D $rf->getAttributeValue("serializer"); > if(!is_null($s) && method_exists($store, $s)) { > $v =3D $store->date->$s(); > } else { > $v =3D $store->date; > } >=20 > echo "the value of the date property is $v"; >=20 > !------------- /example -------------! >=20 > I would find the ability to set attributes extremely useful in building > frameworks a la Ruby On Rails. >=20 > Anyone think this is a good idea? >=20 > Duncan >=20 > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20 >