Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49639 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57606 invoked from network); 13 Sep 2010 19:47:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Sep 2010 19:47:34 -0000 Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.22 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.22 smtp2.ist.utl.pt Linux 2.6 Received: from [193.136.128.22] ([193.136.128.22:59106] helo=smtp2.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E9/CC-24501-4DF7E8C4 for ; Mon, 13 Sep 2010 15:47:33 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 0ADD67000453; Mon, 13 Sep 2010 20:47:30 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp2.ist.utl.pt ([127.0.0.1]) by localhost (smtp2.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id IHMgSQTdj4EK; Mon, 13 Sep 2010 20:47:29 +0100 (WEST) Received: from mail2.ist.utl.pt (mail2.ist.utl.pt [IPv6:2001:690:2100:1::c]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 8139C700044E; Mon, 13 Sep 2010 20:47:29 +0100 (WEST) Received: from cataphract-old.dulce.lo.geleia.net (a79-168-249-157.cpe.netcabo.pt [79.168.249.157]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 401072003A36; Mon, 13 Sep 2010 20:47:29 +0100 (WEST) Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Stas Malyshev" Cc: "internals@lists.php.net" References: <4C873C0F.1010200@zend.com> <4C879613.7090709@zend.com> <4C887D2B.2000605@zend.com> <4C8AC526.7000505@sugarcrm.com> <4C8B6168.30504@mohiva.com> <4C8BC81E.8000605@sugarcrm.com> <7.0.1.0.2.20100913145703.0d226d90@zend.com> <7.0.1.0.2.20100913172559.0d2277d0@zend.com> <7.0.1.0.2.20100913183427.0d2277d0@zend.com> <4C8E6B6F.4080308@sugarcrm.com> Date: Mon, 13 Sep 2010 20:47:41 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?iso-8859-15?Q?N=FAcleo_de_Eng=2E_Biom=E9dica_?= =?iso-8859-15?Q?do_IST?= Message-ID: In-Reply-To: <4C8E6B6F.4080308@sugarcrm.com> User-Agent: Opera Mail/10.61 (Win32) Subject: Re: [PHP-DEV] Re: PHP Annotations RFC + Patch From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") On Mon, 13 Sep 2010 19:20:31 +0100, Stas Malyshev wrote: >> The proposed annotations are basically object instances that are >> returned when you call getAnnotations. There are no itemized lists of >> rules. I >> don't see how this is complex. > > They aren't just object instances, since they also have separate syntax > to create them - unlike the syntax to create all other objects. And it > wouldn't be a problem if it would be something trivial - like just class > name - but we have here whole new syntax complete with nesting, named > parameters, validation logic and what not. I share some of these concerns. But a new feature like this would always require new syntax. The best (in the sense of "most similar to what we have today") syntax I can think of is to define annotations exactly the same way was you'd define arrays, but replace "array" with the annotation name (plus a prefix). I think this looks like PHP: %JoinTable( "name" => "users_phonenumbers", "joinColumns" => array( %JoinColumn("name" => "user_id", "referencedColumnName" => "id") ), "inverseJoinColumns" => array( %JoinColumn("name" => "phonenumber_id", "referencedColumnName" => "id", unique => true) ) ) The named parameters could be replaced by directly setting the fields (basically like the ReflectionAnnotation::__construct already does) and marking the constructor final. If validation logic is really necessary, we could add a validate() method to ReflectionAnnotation (with an empty default implementation) that subclasses could override to provide their validation logic. Off-topic stuff follows: >> - LSB. Can you explain from the top of your head when when the called >> scope is reset or not (e.g. with parent::, self::, className::, possibly >> in non-static contexts) in a function call? I can't. > > It's not that hard. Keywords forward, classnames don't. Fair enough, though I find surprising that "parent" forwards. But you'll find that most users don't see LSB as a "scope that is forwarded" but instead as some kind of inheritance mechanism. It also exposed the odd behavior of keeping subclass copies of static properties in the same reference set as the parent by default, which causes confusion. -- Gustavo Lopes