Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49599 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23402 invoked from network); 11 Sep 2010 17:47:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Sep 2010 17:47:01 -0000 Authentication-Results: pb1.pair.com header.from=guilhermeblanco@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=guilhermeblanco@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: guilhermeblanco@gmail.com X-Host-Fingerprint: 74.125.82.42 mail-ww0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:33185] helo=mail-ww0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 74/71-17717-590CB8C4 for ; Sat, 11 Sep 2010 13:47:01 -0400 Received: by wwb13 with SMTP id 13so950362wwb.5 for ; Sat, 11 Sep 2010 10:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=O7TSmIsRheMCCfPKsRVxnovr9G57JkjnPP6DHRUchyY=; b=G7lSWOz+y9xQee2pvQMDZSdEheFJrIjniUkShEThwpSUPO9ZXysbtucx4Aul9gOoLA bdD4qlBLLNeW7bzgSFty8kAb/3j4sK7WYL0eVOZATJZwIsSZagUV5Q6FSz0yfv0j1pDD k8/Hedb6CVyP7xVysmoBpfiQn9iqfLBVZRXdg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=mvx18ozJv0b4vsoA2VUNDodyPno2xBldSfI5N2bVTbAkyxGJRvrz/nRTIUTmRbGPFw ueQRKWdlIqiYp0VdwHNPWZXzs9ikOkUygKRHbCaZkgcFLI5sqStqkDtRXwNT5g3e1oe4 OVeXE4+g5NHwIx5IqfYnU8Z1C3ar7Hlbvpn8E= MIME-Version: 1.0 Received: by 10.216.49.212 with SMTP id x62mr2404993web.55.1284227218137; Sat, 11 Sep 2010 10:46:58 -0700 (PDT) Received: by 10.216.55.130 with HTTP; Sat, 11 Sep 2010 10:46:58 -0700 (PDT) In-Reply-To: <4C8B6168.30504@mohiva.com> References: <4C873C0F.1010200@zend.com> <4C879613.7090709@zend.com> <4C887D2B.2000605@zend.com> <4C8AC526.7000505@sugarcrm.com> <4C8B6168.30504@mohiva.com> Date: Sat, 11 Sep 2010 14:46:58 -0300 Message-ID: To: Christian Kaps Cc: Pierrick Charron , internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re: PHP Annotations RFC + Patch From: guilhermeblanco@gmail.com (Guilherme Blanco) Hi Stas and Christian, The separator never was a problem... but I definately don't want to see another 6 months just to define what would the separator be. If we need to drop [] in favor of array support, I vote for ! as separator. !Author("Guilherme Blanco") !Validation(!Email(checkMX =3D true)) @Stas: Explaining the example of class User { [Validation([Email(checkMX =3D true)])] public $email; } class Validation extends \ReflectionAnnotation {} class Email extends \ReflectionAnnotation { protected $checkMX; public function getCheckMX() { return $this->checkMX; } } $reflClass =3D new \ReflectionClass('User'); $reflProp =3D $reflClass->getProperty('email'); $emailAnnot =3D $reflProp->getAnnotation('Validation')->getValue(); echo $emailAnnot->getCheckMX(); // true I hope this helps to explain a little bit. Cheers, On Sat, Sep 11, 2010 at 8:00 AM, Christian Kaps wrote: > =C2=A0Hi, > >>> %Annotation(%Email(checkMX =3D true)); > > at first I thought what for an ugly syntax. But after a time I think it > is regardless of whether the % or @(from Java, which I prefer over all, > if it were possible) syntax is used. It looks very similar. So I prefer > the % syntax so we can use the [] for defining arrays in annotations. Is > it possible to define objects from type stdClass in the form > %Annotation({key: 'value'})? > > An other question. Is it necessary to terminate an annotation with a > semicolon, like in your example? > > class Compiler { > > =C2=A0 =C2=A0/** > =C2=A0 =C2=A0 * Compile a node into plain PHP. > =C2=A0 =C2=A0 * > =C2=A0 =C2=A0 * @param Node $node The node to compile. > =C2=A0 =C2=A0 */ > =C2=A0 =C2=A0%Annotation(%Email(checkMX =3D true)) > =C2=A0 =C2=A0%ResourceParameter(['key' =3D> 'name', 'value' =3D> 'annotat= ion']) > =C2=A0 =C2=A0%Inject('\my\name\space\Class') > =C2=A0 =C2=A0%Test > =C2=A0 =C2=A0%Annotation({key: 'value'}) > =C2=A0 =C2=A0public function compile(Node $node) { > > =C2=A0 =C2=A0} > } > > Greetings, > Christian > > Am 11.09.2010 02:23, schrieb Pierrick Charron: >> Hi Stas, >> >> Annotations is a new concept in PHP (even if some framework already >> use an user space implementation of them) and I think it is normal >> that people will have to read a little bit about this eventually new >> feature before using it. This is the same thing for traits, if you >> don't know what is a trait you will not know how to use them. But once >> you know the concept it's really easy to understand what is an >> annotation class, parameter etc... >> >> Is it really the [] Syntax that you don't like for annotations ? I was >> personally not against the [] array syntax and I understand that this >> annotation syntax will make the future implementation of this [] array >> syntax impossible. So I could change it to the syntax proposed by >> Etienne in the first thread : >> >> %Annotation(%Email(checkMX =3D true)); >> >> I'm not against any other proposal of syntax so if you have one to >> proposition do not hesitate. >> >> Regards, >> Pierrick >> >> >> >> 2010/9/10 Stas Malyshev : >>> Hi! >>> >>>> [Validation(Email(checkMX=3D>true))] looks better. >>> Even here it's not clear what is happening. What is "Validation", what = is >>> "Email", what is "checkMX" (are they all classes? or only some of them?= ), >>> what is happening to them (are these classes being instantiated? when? = what >>> is passed as parameters? What is the scope of that? etc). Why can we ha= ve >>> now two ways to instantiate classes, complete with mix of []s and ()s, = but >>> having array syntax using [] is still too complex? >>> >>> -- >>> Stanislav Malyshev, Software Architect >>> SugarCRM: http://www.sugarcrm.com/ >>> (408)454-6900 ext. 227 >>> >>> -- >>> PHP Internals - PHP Runtime Development Mailing List >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 Guilherme Blanco Mobile: +55 (16) 9215-8480 MSN: guilhermeblanco@hotmail.com S=C3=A3o Paulo - SP/Brazil