Hey everyone,
I want to re-drop my proposal onto the table that is just a shortcut
notation for php class instantiation inside that brackets (omiting the
new keyword):
annotation := [className(classArgs*)]
classArgs := array | string | int | float | ...
Re-pasting my examples (this time from simple to complex):
[ExpectedException("InvalidArgumentException")]
[ExpectedException("InvalidArgumentException", "Expected message", 40")]
[Validation(array("type" => "EMail", "options" => array("checkMX" =>
true))]
[JoinTable(array(
"name" => "users_phonenumbers",
"joinColumns" => array(
array("name" => "user_id", "referendedColumnName" => "id"),
),
"inverseJoinColumns" => array(
array("name => "phonenumber_id", "referendColumnName" => "id",
"unique" => true),
),
)]
The only thing new here would be the brackets [] and the implicit class
instantiation through omitting the new keyword.
i.e. [Foo("bar")] would essentially mean new Foo("bar") when
$refl->getAnnotation() is called.
greetings,
Benjamin
On Sat, 2010-09-11 at 20:24 +0200, Pierre Joye wrote:
> On Sat, Sep 11, 2010 at 8:19 PM, Stas Malyshev <[email protected]> wrote:
> > Hi!
> >
> >> The separator never was a problem... but I definately don't want to
> >> see another 6 months just to define what would the separator be.
> >> If we need to drop [] in favor of array support, I vote for ! as
> >> separator.
> >
> > The separator is not a problem (even though 1-char one produces much less
> > clutter). The cryptic syntax is.
>
> It seems that there is a misunderstanding about the goals of the
> annotations. They are not meant to be read by human being
> (javadoc/phpdoc/etc. are) but to be parsed automatically to be used
> for services.
>
> In that sense, to have a syntax closed to one of the best (or less
> worst, if you are on the opposed side ;-) syntax out there (c#/.net)
> may be a good thing to do, instead of re einventing the php wheel.
>
> Cheers,
> --
> Pierre
>
> @pierrejoye | http://blog.thepimp.net | http://www.libgd.org
>
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php