On Mon, Feb 16, 2015 at 1:17 PM, Pavel Kouřil <pajou...@gmail.com> wrote:

> On Mon, Feb 16, 2015 at 12:07 PM, Dmitry Stogov <dmi...@zend.com> wrote:
> > hi,
> >
> > During discussion of different ways of implementing "Design by Contract"
> we
> > got an idea of using annotations.
> >
> > BTW: annotations are useful by their own and may be used for different
> > purposes. Support for annotations was proposed long time ago:
> >
> > https://wiki.php.net/rfc/annotations
> > https://wiki.php.net/rfc/annotations-in-docblock
> > https://wiki.php.net/rfc/reflection_doccomment_annotations
> >
> > HHVM already implemented similar concept
> >
> > http://docs.hhvm.com/manual/en/hack.attributes.php
> >
> > I made a quick and dirty PoC that shows how we may implement annotations
> in
> > PHP7 and how powerful they may be :
> > https://gist.github.com/dstogov/dbf2a8f46e43719bd2c2
> >
> > The test there is self explainable. Of course, annotations just provide a
> > way to add metadata, but doesn't define attribute names or the ways they
> > are going to be used. Only Reflection API to read.
> >
> > There are still a lot of technical problems that have to be solved.
> > Right now, we just need to answer a question - if we like this in PHP7?
> > Thought and opinions are welcome...
> >
> > Thanks. Dmitry.
>
> Hello,
>
> I'd personally suggest you to consider that the Annotations could be
> classes, something along the lines of
>
> https://msdn.microsoft.com/en-us/library/aa288454%28v=vs.71%29.aspx#vcwlkattributestutorialanchor1
>
> IMHO it will allow for more usecases and such than simple arrays.
>

They are statements, so you can do whatever. Dimitri just showed scalars,
but it would be possible to do:

<orm(new Entity(["repositoryClass" => "FooRepository"]))>

And then getAnnotations returns something along the lines if evaluated by
the PHP Parser:

"orm" => [new Entity(....), ]

So your requirement would be possible.

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

Reply via email to