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 <glo...@nebm.ist.utl.pt> wrote: > On Thu, 16 Sep 2010 21:56:04 +0100, Chad Fulton <chadful...@gmail.com> > 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 or > to implement other new features in the future, e.g.: > > class A { > �...@readonly > public $var; > > �...@propertygetter("virtualPropertyName") > public function baz() { } > > �...@classinvariant > public static function bar() { } > > �...@instanceinvariant > public function foo() { } > > /** > * A closure that could be called as if it were a non-static method > * and which would be automatically rebound. > * @var Closure > */ > �...@methodclosure("staticMethod" => false, "rebind" => true) > public static $clos; > > �...@before("self::whatever", instance=true) /* Or @After, or @Around */ > �...@log("entering foobar") /* user-defined specialization of Before */ > �...@precondition(...) > public 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 > > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php