Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49740 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85769 invoked from network); 16 Sep 2010 23:12:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2010 23:12:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=chadfulton@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=chadfulton@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: chadfulton@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-iw0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:62941] helo=mail-iw0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4D/83-15036-074A29C4 for ; Thu, 16 Sep 2010 19:12:49 -0400 Received: by iwn37 with SMTP id 37so1686304iwn.29 for ; Thu, 16 Sep 2010 16:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=nsjaxkTONezdXlCrAWNHWXc8uVSHPj+c1zr7m+sXyGs=; b=N2Zfe0NGLLJql3N5jQErAEWF0CKy1RxeciD3snLeQB6hck/F7OGJTKBibVX5+ds9fr 6pe8rCe9jPD71/gIWsNhvMhOWBz/TpLb03owZhEz1POXdRXmQnCo2L9xVjNp/oSKeO6e UgvbBMpZlZGcaeAfuy8GWAqNxjgZ4i0RVJJLc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=E2avaQRVt7sQGZXwzdp05pfe3eJCq5QTHBhxONDzU00KZB9gwPOlnj7KoxH7RVH2H3 0/PcWhA3YWzJ0382yQDtrFJDKcDJAbmXSFFXLnILjvtVoIRPMeqh3FrY9XIaM3En1m0k goIJHxtXdqKV+EVUcUpChRyIMkE7veXc2oPQ0= Received: by 10.231.17.11 with SMTP id q11mr3963234iba.63.1284678765147; Thu, 16 Sep 2010 16:12:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.0.234 with HTTP; Thu, 16 Sep 2010 16:12:25 -0700 (PDT) In-Reply-To: References: Date: Thu, 16 Sep 2010 16:12:25 -0700 Message-ID: To: Gustavo Lopes Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] docBlock Parser RFC From: chadfulton@gmail.com (Chad Fulton) Hello, Yes, this is not an RFC for annotations or to replicate the exact functionality you wanted within doc comments. However, there is support based on the annotations thread for "APIs to parse doc blocks". I don't know what is meant by others (Zeev, Stas, etc) when they say this. However, in writing this RFC I was nailing down my interpretation of it. It may not be what they had in mind at all, and that's fine by me. I think that this approach has merit *because* of its simplicity. I also think that the use cases mentioned in the Annotations RFC could be equally served by this approach (PHPUnit, Doctrine, etc). If you look at your own example above, the @ReadOnly, @PropertyGetter, @ClassInvariant, and @InstanceInvariant are all trivially replicated using the doc block approach. I strongly suspect the others would be too, except that I'm not sure exactly what you meant by them. I wrote this because it seems to me from comments in the annotations thread that the main problem with the annotations RFC is that it mixes something people want (simple metadata) with something people don't want (new rules and a new syntax). It's definitely possible that I'm wrong about this. Either way, I think this would be a nice thing to have. Thanks, Chad On Thu, Sep 16, 2010 at 3:34 PM, Gustavo Lopes wro= te: > On Thu, 16 Sep 2010 21:56:04 +0100, Chad Fulton > wrote: > >> Based on comments from the annotations thread, I have created a >> docBlock parser RFC at http://wiki.php.net/rfc/docblockparser >> >> This RFC does not deal with annotations per se, but only with the idea >> of adding a function to the Reflection extension which would parse >> docBlocks according to a set docBlock syntax into a simple associative >> array containing three elements: short description, long description, >> and an array of tags. >> >> This is only meant to aid meta-data retrieval for classes and does not >> automatically instantiate anything objects. >> > > Pointless. > > Well, this will maybe speedup and standardize the usage of doc comments, = but > it's very far from what we could do with real annotations. > > By real annotations, I mean something the engine would recognize and that= we > could use in the future to implement AOP functionality with annotations o= r > to implement other new features in the future, e.g.: > > class A { > =A0 =A0@ReadOnly > =A0 =A0public $var; > > =A0 =A0@PropertyGetter("virtualPropertyName") > =A0 =A0public function baz() { =A0} > > =A0 =A0@ClassInvariant > =A0 =A0public static function bar() { } > > =A0 =A0@InstanceInvariant > =A0 =A0public function foo() { } > > =A0 =A0/** > =A0 =A0 * A closure that could be called as if it were a non-static metho= d > =A0 =A0 * and which would be automatically rebound. > =A0 =A0 * @var Closure > =A0 =A0 */ > =A0 =A0@MethodClosure("staticMethod" =3D> false, "rebind" =3D> true) > =A0 =A0public static $clos; > > =A0 =A0@Before("self::whatever", instance=3Dtrue) /* Or @After, or @Aroun= d */ > =A0 =A0@Log("entering foobar") /* user-defined specialization of Before *= / > =A0 =A0@Precondition(...) > =A0 =A0public function foobar() {} > } > > The current implementation would not allow any of this, but at least it > opened way. A doc comment parser... > > -- > Gustavo Lopes > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >