Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:16000 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13370 invoked by uid 1010); 18 Apr 2005 15:14:45 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 13226 invoked from network); 18 Apr 2005 15:14:43 -0000 Received: from unknown (HELO pb1.pair.com) (127.0.0.1) by localhost with SMTP; 18 Apr 2005 15:14:43 -0000 X-Host-Fingerprint: 212.227.126.173 moutng.kundenserver.de Received: from ([212.227.126.173:50154] helo=moutng.kundenserver.de) by pb1.pair.com (ecelerity 1.2.12rc1 r(5476:5477)) with SMTP id 95/34-18700-ADEC3624 for ; Mon, 18 Apr 2005 11:14:35 -0400 Received: from [212.227.126.206] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1DNXws-0005pc-00 for internals@lists.php.net; Mon, 18 Apr 2005 17:14:06 +0200 Received: from [84.163.47.113] (helo=banane) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1DNXwr-0006O7-00 for internals@lists.php.net; Mon, 18 Apr 2005 17:14:05 +0200 To: Date: Mon, 18 Apr 2005 17:13:44 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 Thread-Index: AcVED7ty8XtFiVkZQaq/BwdupWdF3gAF5WUg X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 In-reply-to: <200504181319.56004.duncan@calligram.co.uk> Message-ID: X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:bf648c7cefcb4f7c0e2e63c674feb220 Subject: AW: [PHP-DEV] Attributes support proposal From: thekid@thekid.de ("Timm Friebe") References: <200504181319.56004.duncan@calligram.co.uk> Hi, [...] > 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: The PHP development team is usually against these kinds of OOP syntax sugar additions, search Google / the archives for: * Having IException as an interface instead of needing to extend the builtin Exception class (php-internals) * Static initializers (pear-dev) * with() keyword (???) * Namespaces (php-internals, zendengine2) * Operator overloading (php-internals) * throws clause (zendengine2) * Passing NULL to typehints (php-internals) * finally (php-internals) * Return type hints (php-internals) * self should reflect runtime class (php-internals) * Automated getters/setters (php-internals) (this list is by no means complete) Having said that, how about implementing that in userland? class Storable { #[serializer:toString; persistent:true;] public $date; } Extend (or wrap) the reflection classes and add: MyClass::getAnnotations() MyMethod::getAnnotations() MyProperty::getAnnotations() In those, parse the sourcecode with ext/tokenizer and extract all comments beginning with the string "#[", push them into a hashmap and return it. It's not as slow as you might expect. Of course, it'll only work if you don't use "#[" in any other comments:) - Timm