Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64784 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96722 invoked from network); 9 Jan 2013 20:09:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jan 2013 20:09:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=cpriest@zerocue.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cpriest@zerocue.com; 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:57578] helo=mail.zerocue.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 39/68-02684-46ECDE05 for ; Wed, 09 Jan 2013 15:09:09 -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 7B338120807; Wed, 9 Jan 2013 20:09:05 +0000 (UTC) Message-ID: <50EDCE5A.4090003@zerocue.com> Date: Wed, 09 Jan 2013 14:08:58 -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: Stas Malyshev CC: PHP internals References: <50ED4C18.3090806@zerocue.com> <9f792e7e11c481c5f4c62ce69ae216b6@mohiva.com> <50ED707E.1070503@zerocue.com> <50ED9E0E.4050100@sugarcrm.com> In-Reply-To: <50ED9E0E.4050100@sugarcrm.com> 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) I was just looking into C# attributes at the time since I had used them in the past. It was a loose translation to something for php from the example on this page: http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.stringlengthattribute.aspx In essence the example would be something along the lines of "$s must be a string with length exactly 4 and if not, trigger_error() with the given error message and error level. One of the beautiful things about the C# way of attributes is that they can be user-defined, so long as they are written to the API for C# Attributes. A similar type of thing could occur for PHP, the recent use case of Nullable for Type Hints would be a great use of such attributes, but there are dozens of other uses for them, especially if implemented in a way similar to C#. On 1/9/2013 10:42 AM, Stas Malyshev wrote: > Hi! > >> class a { >> [php:Param($s) = StringLength(4, ErrorMessage='Parameter $s length >> cannnot exceed 4.', ErrorLevel=E_USER_ERROR)] >> public function foo($s) { ... ] >> } > What this is supposed to do? > -- -Clint