Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82920 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13843 invoked from network); 17 Feb 2015 03:45:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Feb 2015 03:45:19 -0000 Authentication-Results: pb1.pair.com header.from=francois@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=francois@php.net; spf=unknown; 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:35400] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8B/31-05651-549B2E45 for ; Mon, 16 Feb 2015 22:45:10 -0500 Received: from moorea (unknown [82.240.16.115]) by smtp2-g21.free.fr (Postfix) with ESMTP id 7CEE74B0163; Tue, 17 Feb 2015 04:44:50 +0100 (CET) Reply-To: To: "'Dmitry Stogov'" , "'PHP Internals'" Cc: "'Nikita Popov'" , "'Guilherme Blanco'" , "'Pierrick CHARRON'" , "'Alexander Lisachenko'" , "'Pierre Joye'" , "'Zeev Suraski'" , "'Andi Gutmans'" , "'Joe Watkins'" , "'Yasuo Ohgaki'" , "'Sebastian Bergmann'" , "'Stanislav Malyshev'" , "'Rasmus Lerdorf'" References: In-Reply-To: Date: Tue, 17 Feb 2015 04:45:03 +0100 Message-ID: <01c401d04a64$1df25470$59d6fd50$@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/lLV51yibmvdAFGYlMAnF51JnA= Content-Language: fr X-Antivirus: avast! (VPS 150216-2, 16/02/2015), Outbound message X-Antivirus-Status: Clean Subject: RE: [PHP-DEV] Re: Annotations in PHP7 From: francois@php.net (=?utf-8?Q?Fran=C3=A7ois_Laupretre?=) Hi Dmitry, In my mind, annotation syntax was one level lower, dealing with strings = of unknown syntax, not PHP expressions. Something like : '*' '@' STRING free-string-up-to-eol This supports : * @requires $a > 0 But also : * @statement INSERT INTO ?? VALUES (13, 'Phoenix', 'AZ', 33, 112) Using Reflection, the application would get an array of (STRING =3D> = array of ) in order of appearance and that's all = for the annotation layer. Then, the client has the responsibility to = interpret the strings the way it wants. Even if it is a valid PHP expression, getting it as a string is not a = problem. DbC, for instance, would get the string, eval() them and error = if one of them evaluates to false. Performance must not be a problem = with annotations. This is what makes it suitable for DbC or offline = metadata. If we restrict it to a PHP expression, you need to interpret it at = compile time, which makes the process more complex. I must admit I don't = understand the reason, as the only one I see is performance. And I am = totally out of sync with suggestions to include namespaces, nested = annotations, or using class constants in expressions. I even feel = incomfortable because it's just 'PHP code, but elsewhere'. I don't see = the use case. About the syntax, I'm probably faulty there, but I don't understand why = we cannot use doc blocks. That's easy to parse at compile time, the API = is easy to define, the parser already parses them, and everyone is = already using that. Existing applications like doctrine just miss the = API to use it in a cleaner way but it would be 100% compatible. = Actually, I saw several people refusing to consider doc blocks as = annotations but I was never given the reason why. So, I am just curious. Anyway, I don't like the OO features people want to add everywhere. They = can get strings and inject them to OO, but that's not the role of the = annotation layer, IMHO. I definitely prefer the KISS approach. Regards Fran=C3=A7ois