Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82877 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11245 invoked from network); 16 Feb 2015 19:09:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Feb 2015 19:09:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=pajousek@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pajousek@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: pajousek@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qa0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:42610] helo=mail-qa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 63/AB-36518-D5042E45 for ; Mon, 16 Feb 2015 14:09:17 -0500 Received: by mail-qa0-f42.google.com with SMTP id w8so23014369qac.1 for ; Mon, 16 Feb 2015 11:09:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=pzJ859l9RPnq1mpn/lHmJRRhcoGj+yX8pFk1dB4YVjw=; b=iMTJrmIFd5NfN1jYQPtToWE7zmheKANhnKJonjWHrWkOt5KZltaUnE04AZtsVI+/1J rynfVShwxrbcZL0S1Iyk2cJixI/6XvdgYFi+qYFtPfJNxn5b26IBjUisg+meWiY3MAA3 EZ2nSW58eMUN5wdfl5jgn1RfpGV45fiQgF7JF0puGz3wDHrmoSZ5DMCbaqU46lPokx5k +ujW/VIgblC9GQdA+UjmSTbYuI6tMfZB1rFeElP/u5dKDfgem85rwB/mYsBsG2Ya8TFp HxaMSotTkSuSM/e2pS8Umn2i4E5t6DiZpAh2ASxkm2crXVDTA5ifXMlodPGMn4sCoet+ NHQA== MIME-Version: 1.0 X-Received: by 10.140.148.20 with SMTP id 20mr483589qhu.67.1424113754394; Mon, 16 Feb 2015 11:09:14 -0800 (PST) Received: by 10.96.66.201 with HTTP; Mon, 16 Feb 2015 11:09:14 -0800 (PST) In-Reply-To: References: Date: Mon, 16 Feb 2015 20:09:14 +0100 Message-ID: To: Benjamin Eberlei Cc: Dmitry Stogov , PHP Internals , Nikita Popov , Guilherme Blanco , Pierrick CHARRON , Alexander Lisachenko , Pierre Joye , Zeev Suraski , Andi Gutmans , Joe Watkins , Yasuo Ohgaki , Sebastian Bergmann , Stanislav Malyshev , Rasmus Lerdorf Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Annotations in PHP7 From: pajousek@gmail.com (=?UTF-8?Q?Pavel_Kou=C5=99il?=) On Mon, Feb 16, 2015 at 1:33 PM, Benjamin Eberlei wro= te: > > > On Mon, Feb 16, 2015 at 1:17 PM, Pavel Kou=C5=99il w= rote: >> >> On Mon, Feb 16, 2015 at 12:07 PM, Dmitry Stogov wrote: >> > hi, >> > >> > During discussion of different ways of implementing "Design by Contrac= t" >> > 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 annotatio= ns >> > in >> > PHP7 and how powerful they may be : >> > https://gist.github.com/dstogov/dbf2a8f46e43719bd2c2 >> > >> > The test there is self explainable. Of course, annotations just provid= e >> > a >> > way to add metadata, but doesn't define attribute names or the ways th= ey >> > 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=3Dvs.71%29.aspx#vc= wlkattributestutorialanchor1 >> >> 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: > > "FooRepository"]))> > > And then getAnnotations returns something along the lines if evaluated by > the PHP Parser: > > "orm" =3D> [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 >> > Hello, while the usage of statements in annotations sound good in theory, I find the need for using the "new" and such as ugly. Thefore, I'd probably still prefer the C# style of doing annotations. Regards Pavel Kouril