Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52191 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56054 invoked from network); 10 May 2011 00:56:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 May 2011 00:56:06 -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 209.85.213.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: 209.85.213.42 mail-yw0-f42.google.com Received: from [209.85.213.42] ([209.85.213.42:36225] helo=mail-yw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/C6-14908-52D88CD4 for ; Mon, 09 May 2011 20:56:05 -0400 Received: by ywh1 with SMTP id 1so2444500ywh.29 for ; Mon, 09 May 2011 17:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=bVZ4l4jWjA74RVP+ovOajJrx+B/TyEMbtk0CJPAN10k=; b=MBmcU4iGi6lOkI3KFG1lonAVip/KxCvaS93kmbKMC/0g9nENhMt32zL9Vhz9aEjaQY 0Tdy4nx73loPoW6cQcGTRZy9PCo2OzJP3XhaofcekKI1dbaDjrwu5TeQg90ng1dE3XQx LE4ePOr9evEvQJi6xW3bzAxWZIrxcp0OAPD00= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=B4cfHXyWTgTj6O8G4PUeLy5e6v70mdnPj1LRSL+g6FojeOh7huEHHScIBJOabBHOTp ImDesGrF582A/X4P+ck+enlLm+SUmZ9SDUIP9xdskHgu1LjOZiND5pzCuymPTfoqNrJI +NebbeRr5J3VeY8xncAKSEh+AGaEuxX9EClio= Received: by 10.236.185.163 with SMTP id u23mr8586294yhm.177.1304988962117; Mon, 09 May 2011 17:56:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.147.171.4 with HTTP; Mon, 9 May 2011 17:55:42 -0700 (PDT) In-Reply-To: <4DC8885C.9090608@sugarcrm.com> References: <4DC826B1.4090806@lerdorf.com> <4DC82A36.8090604@lerdorf.com> <4DC85FBE.2060005@lsces.co.uk> <4DC8885C.9090608@sugarcrm.com> Date: Mon, 9 May 2011 21:55:42 -0300 Message-ID: To: Stas Malyshev Cc: Lester Caine , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Please let's not bitch about lazy users not learning C to implement THEIR missing feature. (Was Re: [PHP-DEV] 5.4 again) From: guilhermeblanco@gmail.com ("guilhermeblanco@gmail.com") Hi Stas, On Mon, May 9, 2011 at 9:35 PM, Stas Malyshev wrot= e: > Hi! > >> I updated the RFC. I may have missed one thing or two, but overall >> idea and how code behave is there. >> This question is answered on wiki RFC. =3D) >> >> Here is the direct link: https://wiki.php.net/rfc/annotations > > Some questions I didn't find the answers in the RFC: > 1. When the annotation objects are instantiated? Objects are only instantiated when requested (getAnnotations() or getAnnotation()) > 2. What is permissible in the arguments of annotation - e.g. can I put an= y > expression there? You are allowed to use any scalar value + array + any object that implements ReflectionAnnotation interface. > 3. What )> actually means and how it is supposed to be parsed? It would instantiate a class Bar and would pass it as an instance of Foo that is also being created when doing getAnnotations() or getAnnotation('Foo') > 4. What happens if ctor for annotation has error/exception? There're error support just like PHP has. Here is a sample: Fatal error: Uncaught exception 'Exception' with message 'Fooooo' in /src/php-src/trunk/ok.php:6 Stack trace: #0 [internal function]: simpleannotation->__construct() #1 /src/php-src/trunk/ok.php(15): ReflectionClass->getAnnotation('simpleannotatio...') #2 {main} thrown in /src/php-src/trunk/ok.php on line 6 Code: class SimpleAnnotation implements ReflectionAnnotation { public function __construct() { throw new Exception('Fooooo'); } } class Foo { } $r =3D new ReflectionClass('Foo'); var_dump($r->getAnnotation('SimpleAnnotation')); > 5. Are there any limitations on classes that can be used as annotations? As I said, only classes that implement ReflectionAnnotation are allowed to be used. It gives errors if you attempt to do something invalid. Here is the error you get if you attempt to use a non-declared annotation: class Foo implements ReflectionAnnotation { public function __construct($bar) {} } class Bar {} )> class FooBar { } $r =3D new ReflectionClass('FooBar'); var_dump($r->getAnnotations()); Fatal error: ReflectionClass::getAnnotations(): 'Bar' must implement 'ReflectionAnnotation' to act as an annotation in - on line 15 > 6. Do we need any special support for bytecode caches? Yes. Every structure which can be annotated now will have a new member in their C structure which is annotations, this structure is populated at compile time and store all the metadata information. So if you have an opcode cache the compilation will not occur, so the annotations will be NULL. That's why the opcode cache will have to store the annotations, so that it can be retrieved every time. > > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > --=20 Guilherme Blanco Mobile: +55 (16) 9215-8480 MSN: guilhermeblanco@hotmail.com S=C3=A3o Paulo - SP/Brazil