Re: Re: PHP Annotations RFC + Patch
| From: | Gustavo Lopes | Date: | Mon, 13 Sep 2010 20:34:22 +0000 |
| Subject: | Re: Re: PHP Annotations RFC + Patch | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-49641@lists.php.net to get a copy of this message | ||
On Mon, 13 Sep 2010 21:02:34 +0100, Stas Malyshev <smalyshev@sugarcrm.com> wrote:
Hi!It's not an array syntax for parameters. Those would not be passed to a function, merely used to fill the fields of the annotation, like (object) array("a"=>1) creates a stdClass object with a field named "a" and value 1. The difference would be we wouldn't be creating dynamic fields, but only filling defined ones.The best (in the sense of "most similar to what we have today") syntax I can think of is to define annotations exactly the same way was you'd define arrays, but replace "array" with the annotation name (plus a prefix). I think this looks like PHP:We have here at least two non-PHP constructs - %Name meaning "new Name" and array syntax for parameters.
If I'm not mistaken, the current implementation instantiates an object each time getAnnotation() is called, but it was proposed to change this into a lazy-loading mechanism with the same instance returned every time for each annotation. In that case, we'd only need to validate that one time.could add a validate() method to ReflectionAnnotation (with an empty default implementation) that subclasses could override to provide their validation logic.When this validation logic will be called? On getAnnotation()? Then it would be extremely wasteful - the annotation never changes but each time is re-validated anew.
http://en.wikipedia.org/wiki/Sampling_(statistics) In any case, the manual page could be improved. It has a vague statement "static:: does not work like $this for static methods! $this-> follows the rules of inheritance while static:: doesn't. This difference is detailed later on this manual page" followed only by examples. -- Gustavo LopesFair enough, though I find surprising that "parent" forwards. But you'll find that most users don't see LSB as a "scope that is forwarded" but instead as some kind of inheritance mechanism. It also exposed the oddI don't know how you found out what "most users" of PHP's multi-million user base think - how many millions of people did you ask? - but whoever has wrong preconceptions about how it works should correct them by reading the actual docs. Provided that the actual rule can easily fit on a bumper sticker, I don't think it's too complex.