Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64740 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9793 invoked from network); 9 Jan 2013 13:28:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jan 2013 13:28:40 -0000 Authentication-Results: pb1.pair.com header.from=cpriest@zerocue.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cpriest@zerocue.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zerocue.com designates 67.200.53.250 as permitted sender) X-PHP-List-Original-Sender: cpriest@zerocue.com X-Host-Fingerprint: 67.200.53.250 mail.zerocue.com Received: from [67.200.53.250] ([67.200.53.250:57450] helo=mail.zerocue.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 54/F7-02684-7807DE05 for ; Wed, 09 Jan 2013 08:28:39 -0500 Received: from [172.17.0.122] (unknown [66.25.151.173]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.zerocue.com (Postfix) with ESMTPSA id 3F50F120807 for ; Wed, 9 Jan 2013 13:28:37 +0000 (UTC) Message-ID: <50ED707E.1070503@zerocue.com> Date: Wed, 09 Jan 2013 07:28:30 -0600 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: PHP internals References: <50ED4C18.3090806@zerocue.com> <9f792e7e11c481c5f4c62ce69ae216b6@mohiva.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] - "attributes" rather than "annotations" From: cpriest@zerocue.com (Clint Priest) We should probably be referring to this type of syntax as attributes rather than annotations since annotations are currently defined in docblock comments and are recognized by certain software and utilities. Whereas annotations have no effect on compilation or at runtime, attributes do have the possibility of affecting compilation or runtime. I like the idea of having a schema parameter like metadata: as that would allow php to reserve php: for example. Almost like a namespace, in fact it could actually be a namespace, such as: class a { [php:Param($s) = StringLength(4, ErrorMessage='Parameter $s length cannnot exceed 4.', ErrorLevel=E_USER_ERROR)] public function foo($s) { ... ] } I also think that providing no schema should be allowed as well, such as: [: ... ] We could, again, model this after the C# model whereby user-land attributes may be defined, PHP could also provide it's own standard ones. The only reason I mention C# here is that it's been in wide use for some time now. On 1/9/2013 6:03 AM, Yahav Gindi Bar wrote: > On Wed, Jan 9, 2013 at 1:57 PM, Christian Kaps wrote: > >> Hi, >> >> >> I agree here, I think the above, if possible would be best. In my >>> mind annotations should proabably be limited in scope to class >>> declarations and thus only before a class keyword, before a property >>> or method declaration. >>> >>> In none of those scopes would [ ] be a parsing issue I believe... >>> >>> The one case would be at the beginning of a class, but if simply >>> added something such as: >>> [:SomeAttribute(xyz,abc),**SomeAttribute2] >>> >>> It could never be confused with short array syntax and is still brief. >>> >> I think when implementing real annotations, then it should be possible to >> declare arrays in it. So I think the square brackets don't work. >> [Foo([1,2,3])] >> >> Cheers, >> Christian >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> But the colon prefix won't cover this case? > You can, as I've mentioned in my post at the doc-block parser discussion, > use a keyword inside the brackets to symbolize annotation, for example > > [metadata: Key] > [metadata: MaxLength(10)] > [metadata: Relations(["foo", "bar", "baz"])] > public $id; > -- -Clint