Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83050 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90604 invoked from network); 18 Feb 2015 11:52:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2015 11:52:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=francois@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=francois@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 212.27.42.2 as permitted sender) X-PHP-List-Original-Sender: francois@php.net X-Host-Fingerprint: 212.27.42.2 smtp2-g21.free.fr Received: from [212.27.42.2] ([212.27.42.2:23488] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/3C-18888-40D74E45 for ; Wed, 18 Feb 2015 06:52:37 -0500 Received: from moorea (unknown [82.240.16.115]) by smtp2-g21.free.fr (Postfix) with ESMTP id 094194B0272; Wed, 18 Feb 2015 12:52:12 +0100 (CET) Reply-To: To: "'Dmitry Stogov'" , Cc: "'Alexander Lisachenko'" , "'Nikita Popov'" , "'Benjamin Eberlei'" , "'PHP Internals'" , "'Pierrick CHARRON'" , "'Pierre Joye'" , "'Zeev Suraski'" , "'Andi Gutmans'" , "'Joe Watkins'" , "'Yasuo Ohgaki'" , "'Sebastian Bergmann'" , "'Stanislav Malyshev'" , "'Rasmus Lerdorf'" References: <02a101d04af9$507484f0$f15d8ed0$@php.net> In-Reply-To: Date: Wed, 18 Feb 2015 12:52:29 +0100 Message-ID: <02fe01d04b71$60af1920$220d4b60$@php.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQIWCTr4msJ5W7DJk/lLV51yibmvdAKzGGCUAgoW0V0B+zpKeAEm3WG2Atzt2IYBTeL0owHXafdoAjxo5a0Bl7QLEwIr57iGm8u78oA= Content-Language: fr X-Antivirus: avast! (VPS 150217-2, 17/02/2015), Outbound message X-Antivirus-Status: Clean Subject: RE: [PHP-DEV] Annotations in PHP7 From: francois@php.net (=?utf-8?Q?Fran=C3=A7ois_Laupretre?=) Hi Dmitry, > De : Dmitry Stogov [mailto:dmitry@zend.com] > Nested annotations are not going to be necessary, because they may be > represented by PHP pseudo-syntax (and/or PHP array syntax) >=20 > ManyToMany($targetEntity=3D"Phonenumber"), > JoinTable($name=3D"users_phonenumbers", > $joinColumns=3DJoinColumn($name=3D"user_id", > $referencedColumnName=3D"id")) > inverseJoinColumns=3DJoinColumn($name=3D"phonenumber_id", > $referencedColumnName=3D"id", $unique=3Dtrue))> > class User { > ... > } >=20 > $r =3D new ReflectionClass("User"); > $ast =3D $r->getAnnotation("Doctine_Join"); > echo $ast->child[0]->child[0]; // "ManyToMany" > echo $ast->child[0]->child[1]->child[0]->child[0]; // "$targetEntity" >=20 > or If we provide API similar to SimpleXML >=20 > echo $ast[0][0]; // "ManyToMany" > echo $ast[0][1][0][0]; // "$targetEntity" Please, no new pseudo language. Either value is a bare string and = application has responsibility to parse it, or it is a PHP expression, = especially since we have short array syntax. If user needs runtime = evaluation, as in DbC, he just passes his expression in a string. Accessing ast elements by index is quite poor too, and if it is to = define associative pseudo-arrays, let's use PHP arrays. Also, a detail, same as Derick's : '<>' reminds html/xml too much, IMO. = While completely different, it will confuse a lot of people. I prefer = '<<>>'. No ambiguity. So : < [ 'targetEntity' =3D> "Phonenumber" ], 'JoinTable' =3D> [ 'name' =3D> "users_phonenumbers" , 'joinColumns' =3D> [ [ 'name' =3D> 'user_id', 'referencedColumnName' =3D> 'id' ] ], 'inverseJoinColumns' =3D> [ [ 'name' =3D> "phonenumber_id", 'referencedColumnName' =3D> "id", = 'unique' =3D> true ] ] ] ] ) >> A last question: in such a case, should '<<' strings appearing in the = expression have to be quoted, or would it take care of string delimiters = when searching for the end of the annotation ? Regards Fran=C3=A7ois