Re: native php annotations
| From: | Etienne Kneuss | Date: | Sun, 13 Mar 2011 21:33:56 +0000 |
| Subject: | Re: native php annotations | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51674@lists.php.net to get a copy of this message | ||
On Mar 13 17:50:33, Marcelo Gornstein wrote:
> Hello All,
>
> I'm new to this list, so please excuse me if this subject was already
> discussed, or proposed.
Hi,
it has already been discussed with length. Please take a look at:
http://wiki.php.net/rfc/annotations
it would be more productive if you explain in what ways your proposal
differs from the one above, and why that should be so.
Best,
>
> I've made an experimental patch to ZendEngine/PHP (5.3.5) to allow
> native annotations (without doc comments), using the token @@ (the @
> was already taken). It allows 0 or more annotations (with 0 or more
> arguments each one) for classes, properties, methods, and arguments
> for methods, like:
>
> @@Annotation(key="value1")
> class A {
> @@Annotation(key="value1")
> private $property;
>
> @@Annotation(key="value1")
> private function aMethod(@@Annotation(key="value1") @@Annotation2 $a, $b) {
> ...
> }
> }
>
> The patch can be found at:
> https://github.com/marcelog/AnoForPHP.
>
> The annotations and their optional arguments can be retrieved via the
> getAnnotations() method of ReflectionClass, ReflectionMethod,
> ReflectionParameter, and ReflectionProperty.
>
> I plan to extend this patch with some extended functionality, like
> having PHP instantiate a given class for the given annotation. By
> using convention instead of configuration, the name of the annotation
> is the name of the class, which should also extend some PHP base
> class, like "Annotation".
>
> I'm basically looking for comments on the patch and the functionality,
> since I'm new to the ZendEngine as well.
>
> Again, I'm sorry if this post should not go here or there is not
> interest in such a feature in the language itself. Also, if I missed
> something in the code of the patch, because it's more like a
> proof-of-concept than a final formal proposal.
>
> Regards!
>
>
> --
> // I don't sleep. I coffee.
> "Make everything as simple as possible, but not simpler." -- Albert Einstein
> "The class object inherits from Chuck Norris."
> "Chuck Norris can divide by zero and can unit test an entire
> application with a single assert."
> "There’s a lot of work happening behind the scenes, courtesy of the
> Spring AOP framework"
> "Why do I have this nagging hunch that you have no idea what you're doing?"
> "Any society that would give up a little liberty to gain a little
> security will deserve neither and lose both" - Benjamin Franklin
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>