Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82819 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82308 invoked from network); 16 Feb 2015 11:35:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Feb 2015 11:35:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=cesar@rodas.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cesar@rodas.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain rodas.me designates 109.74.200.116 as permitted sender) X-PHP-List-Original-Sender: cesar@rodas.me X-Host-Fingerprint: 109.74.200.116 li147-116.members.linode.com Received: from [109.74.200.116] ([109.74.200.116:35934] helo=li147-116.members.linode.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E6/11-05176-7E5D1E45 for ; Mon, 16 Feb 2015 06:35:04 -0500 Message-ID: <54E1D5DF.3050309@rodas.me> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rodas.me; s=mail; t=1424086500; bh=5hSo5IzrPAyk1ERnv3d9c1Qt6SRbXXp4bWSP1CRpj3U=; h=Date:From:To:CC:Subject:References:In-Reply-To:From; b=aTwhPF6JlUFqXNkpabVIp4U0ot+lnF2sy93DoYEOk0N3FNcg4MiTYktNkAgjmqtVg V8iqsDWFMOPFl9kYZph6ccM2m8MuX1B88jRVThPvOlylYRR9V1yfEHYAPtgvWauhgh fOOiFJjqB8IMDxj4qzndZsgdHFtnYHM9twCwL8PE= Date: Mon, 16 Feb 2015 12:34:55 +0100 MIME-Version: 1.0 To: Dmitry Stogov CC: PHP Internals References: <54E1D2F8.30606@rodas.me> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5aG7KQIoqVrsIXWkaKDJ1wLNP2LhE8wPc" Subject: Re: [PHP-DEV] Re: Annotations in PHP7 From: cesar@rodas.me (Cesar Rodas) --5aG7KQIoqVrsIXWkaKDJ1wLNP2LhE8wPc Content-Type: multipart/alternative; boundary="------------020706060809010303050700" This is a multi-part message in MIME format. --------------020706060809010303050700 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 16/02/15 12:32, Dmitry Stogov wrote: > you already have doc-block. nothing should be done in PHP core, but > you have to parse it yourself. > The goal of annotations is to provide standard and powerful way. > On the other hand standard PHP expression syntax may be not enough for > all cases. Agreed on that. I just thought it could be wise parse natively what is already out there. Anyways adapt our DocBlock annotation parsers to parse both (native PHP annotations and docblocks) shouldn't be that hard either. As far as I see annotations are supposed to be accessed through reflections right? Or will it do something automatically as in Python? Cheers, > > Thanks. Dmitry. > > On Mon, Feb 16, 2015 at 2:22 PM, Cesar Rodas > wrote: > > > On 16/02/15 12:19, Dmitry Stogov wrote: > > I decided to explain the proposed annotation syntax "in words" > to avoid > > misunderstanding > > > > annotations ::=3D { annotation }. > > annotation ::=3D '<' STRING '>' | '<' STRING '(' expr ')' '>'. > > > > where is regular PHP expression. > Why not doc-block annotations? So it can be parse/understand that i= s > already there (Doctrine annotations for instance). > > > > > Thanks. Dmitry. > > > > > > On Mon, Feb 16, 2015 at 2:07 PM, Dmitry Stogov > 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 solv= ed. > >> Right now, we just need to answer a question - if we like this > in PHP7? > >> Thought and opinions are welcome... > >> > >> Thanks. Dmitry. > >> > > -- > C=C3=A9sar D. Rodas > Open Source developer > +595-983-161124 > PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6 > > > --=20 C=C3=A9sar D. Rodas Open Source developer +595-983-161124 PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6 --------------020706060809010303050700 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On 16/02/15 12:32, Dmitry Stogov wrote= :
you already have doc-block. nothing should be done in PHP core, but you have to parse it yourself.
The goal of annotations is to provide standard and powerful way.
On the other hand standard PHP expression syntax may be not enough for all cases.

Agreed on that. I just thought it could be wise parse natively what is already out there. Anyways adapt our DocBlock annotation parsers to parse both (native PHP annotations and docblocks) shouldn't be that hard either.

As far as I see annotations are supposed to be accessed through reflections right? Or will it do something automatically as in Python?

Cheers,


Thanks. Dmitry.

On Mon, Feb 16, 2015 at 2:22 PM, Cesar= Rodas <cesar@roda= s.me> wrote:

On 16/02/15 12:19, Dmitry Stogov wrote:
> I decided to explain the proposed annotation syntax "in words" to avoid
> misunderstanding
>
> annotations ::=3D { annotation }.
> annotation=C2=A0 =C2=A0::=3D '<' STRING '>' | '&= lt;' STRING '(' expr ')' '>'.
>
> where <expr> is regular PHP expression.
Why not doc-block annotations? So it can be parse/understand that is
already there (Doctrine annotations for instance).

>
> Thanks. Dmitry.
>
>
> On Mon, Feb 16, 2015 at 2:07 PM, Dmitry Stogov <<= a moz-do-not-send=3D"true" href=3D"mailto:dmitry@zend.com= ">dmitry@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<= /a>
>>
https://wiki.php.net/rfc/annotations-= in-docblock
>> https://wiki.php.net/rfc/reflection_d= occomment_annotations
>>
>> HHVM already implemented similar concept
>>
>> http://docs.hhvm.com/manual/en/hack.a= ttributes.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/dbf2a= 8f46e43719bd2c2
>>
>> 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.
>>

--
C=C3=A9sar D. Rodas
Open Source developer
+595-983-161124
PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6



--=20
C=C3=A9sar D. Rodas
Open Source developer
+595-983-161124
PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6
--------------020706060809010303050700-- --5aG7KQIoqVrsIXWkaKDJ1wLNP2LhE8wPc Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJU4dXfAAoJEBWKAzbHBwqmuO8QANnzWJq9cgEsWb4Q25HSuWNF JiPfSHq8q+RX7WXnL/BR1/MNPBAcA+L7xf2NotePi21NqaETTbOqnaHQFwWLEhiW JSJPIPbPRB0uzuMBTPcknAL0lmZZoxH1WC/GHRiCcFcyHgHieq2FBFDttFmxVnUE myK2MLo7OpCwXY/gh1QOaKQjmpFyPhHSdqJA5niELXpZ4AzGGU8wTU0KjXXJRmAj IujezuwmAPG1xikzDaX/9jrQ5G99Lm3VB9p5QLY7qY++0YlJ5wQvnoHYS9LCD6PR svybUUc4c0/slm16jLWuXr3jYqPanmEdO5qNxpPuMaHepTv6FC06tVqFY1+mEW4l b+wD3yoZgQgywC5tQYSPwKdRPB42TOSz6MnH9b92ysLBhSbQE5g2hl/gYeEtb47U wIsy2H7rDPieJn04cnxSXQNxf8gfOQKKPm7QE3Epzuo3nwmGrxKLx9DyqekLneZi U0ifVEbItx0iR/+CIn8BtzYur7f2xgbBfzO+gjUGuQ8H50P18DpkQ1OsLrP5W6Br CiVzyM9YQ/1lM2X3l2ycWkUKMtEN4awlcNozsWw6OTW6qFJ2i23xoWOau87CNX/U BoMBEiSHhqvzHgC3PcrbX3PLgfvJGL0aIsVt5yXrx2zqtMsI2RpUEr2MZ9LZpiJL xxUcvYLaaURdzvzSw+OQ =mfoQ -----END PGP SIGNATURE----- --5aG7KQIoqVrsIXWkaKDJ1wLNP2LhE8wPc--