On Mon, 13 Sep 2010 21:02:34 +0100, Stas Malyshev <smalys...@sugarcrm.com> wrote:

Hi!

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.

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.

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.


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.

Fair 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 odd

I 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.

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 Lopes

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to