Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49654 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42196 invoked from network); 15 Sep 2010 05:33:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Sep 2010 05:33:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=christian.kaps@mohiva.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=christian.kaps@mohiva.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain mohiva.com designates 78.46.69.5 as permitted sender) X-PHP-List-Original-Sender: christian.kaps@mohiva.com X-Host-Fingerprint: 78.46.69.5 zucker.schokokeks.org Received: from [78.46.69.5] ([78.46.69.5:36428] helo=zucker.schokokeks.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E6/32-33442-C9A509C4 for ; Wed, 15 Sep 2010 01:33:18 -0400 Received: from [192.168.178.2] (p57B544E8.dip.t-dialin.net [::ffff:87.181.68.232]) (AUTH: PLAIN christian.kaps@mohiva.com, SSL: TLSv1/SSLv3,256bits,CAMELLIA256-SHA) by zucker.schokokeks.org with esmtp; Wed, 15 Sep 2010 07:33:14 +0200 id 0000000000018005.000000004C905A9A.00006889 Message-ID: <4C905A99.9050802@mohiva.com> Date: Wed, 15 Sep 2010 07:33:13 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100903 Lightning/1.0b2pre Thunderbird/3.1.2 MIME-Version: 1.0 To: internals@lists.php.net References: <39505F13-655A-43AF-941E-77750B7F7201@gmail.com> <001601cb543a$d81ebac0$885c3040$@com> <4C8FC695.2060800@sugarcrm.com> <4C8FD72B.1070108@sugarcrm.com> In-Reply-To: <4C8FD72B.1070108@sugarcrm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Re: PHP Annotations RFC + Patch From: christian.kaps@mohiva.com (Christian Kaps) Am 14.09.2010 22:12, schrieb Stas Malyshev: > I think we _already_ have metadata in PHP, albeit done through > phpdocs. So the question is kind of moot :) We should see if it's > enough for us or we want to add/change/extend it and if so, how. > Hi, in my mind there is a big mistake when using annotations in PHPDoc comments. As example let as use a JSR 303 - Bean Validator like Hibernate Validator for PHP. namespace my\project\models\dto; class User { /** * @com\jsr303\validator\constraints\NotNull * @com\jsr303\validator\constraints\Integer */ public $id; /** * @com\jsr303\validator\constraints\NotNull * @com\jsr303\validator\constraints\Regexp('/[a-z]*/i') * @com\jsr303\validator\constraints\MinLength(2) * @com\jsr303\validator\constraints\MaxLength(255) */ public $name; /** * @com\jsr303\validator\constraints\NotNull * @my\project\validator\constraints\Zipcode */ public $zipcode; } It is possible to use this type of annotations but it is impracticable. An other problem is that every framework use its one annotation syntax. So it makes the framework end user more confusing as using a clear unique syntax. I think the PHP way should be as in the next example. namespace my\project\models\dto; use com\jsr303\validator\constraints\NotNull; use com\jsr303\validator\constraints\Integer; use com\jsr303\validator\constraints\Regexp; use com\jsr303\validator\constraints\MinLength; use com\jsr303\validator\constraints\MaxLength; use my\project\validator\constraints\Zipcode; class User { [NotNull] [Integer] public $id; [NotNull] [Regexp('/[a-z]*/i')] [MinLength(2)] [MaxLength(255)] public $name; [NotNull] [Zipcode] public $zipcode; } With this out of the box PHP annotations it makes it possible to create powerful frameworks which can used by a great range of developers without learning a new syntax for it. Pleas do not argue about thy syntax of the annotation because this isn't final. Greetings, Christian