Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49589 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30088 invoked from network); 8 Sep 2010 18:58:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Sep 2010 18:58:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=kontakt@beberlei.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=kontakt@beberlei.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain beberlei.de from 87.230.78.165 cause and error) X-PHP-List-Original-Sender: kontakt@beberlei.de X-Host-Fingerprint: 87.230.78.165 www.mysqlusers.de Linux 2.5 (sometimes 2.4) (4) Received: from [87.230.78.165] ([87.230.78.165:55039] helo=beberlei.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/26-33683-4DCD78C4 for ; Wed, 08 Sep 2010 14:58:29 -0400 Received: from [192.168.1.34] (koln-4d0b144a.pool.mediaWays.net [77.11.20.74]) by beberlei.de (Postfix) with ESMTPSA id 25D4425A008E; Wed, 8 Sep 2010 20:58:25 +0200 (CEST) To: Stas Malyshev Cc: internals In-Reply-To: <4C87D315.2030306@sugarcrm.com> References: <4C873C0F.1010200@zend.com> <4C879613.7090709@zend.com> <4C87D315.2030306@sugarcrm.com> Content-Type: text/plain; charset="UTF-8" Date: Wed, 08 Sep 2010 20:58:24 +0200 Message-ID: <1283972304.3280.49.camel@benny-pc> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: PHP Annotations RFC + Patch From: kontakt@beberlei.de (Benjamin Eberlei) Hello Stas, I agree, using an array like syntax would make the intent much clearer in the context of PHP, the syntax is just slightly more verbose: [JoinTable(array( "name" => "users_phonenumbers", "joinColumns" => array( array("name" => "user_id", "referendedColumnName" => "id"), ), "inverseJoinColumns" => array( array("name => "phonenumber_id", "referendColumnName" => "id", "unique" => true), ), )] [Validation(array("type" => "EMail", "options" => array("checkMX" => true))] I think that is even possible with the current patch, it just allows additional [] blocks inside that convert into an object instead of an array. Annotations is hardly a feature relevant for ORMs only, its just a very obvious one to pick. I can find bazzilions of other good examples: * SOAP/XML-RPC - Hint your service/functions for that WSDL generator you want to use (instead of writing it by hand) * ACLs - Configure an access control layer that wraps around your service-calls (is Foo allowed to do this?) * Testing - Allow nicer configuration of test-setup, fixtures, pre-conditions. * Validation - Explain to a validation component what the fields of your classes are. * Hooks/Event-Systems - Explicit mechanisms to register classes/methods/functions as plugins, event listener or hooks. No more writing FrameworkHookListener::add('myMagicCallback') * Frameworks - Leave INI, YAML, XML behind, configuration visible at the applied context inside PHP is very valuable, instead of having to browse the source to the configuration directories, see the Routing, Action and View configuration examples Fabien has posted on Symfony 2 yesterday. * Dependency Injection - Configuring how dependencies should be wired between objects, so that a DI container can help you bootstrap your application. * Forms - Tell a form generator how an object property should be rendered, validated and such. greetings, Benjamin On Wed, 2010-09-08 at 11:16 -0700, Stas Malyshev wrote: Hi! > > >>> [JoinTable( > >>> name="users_phonenumbers", > >>> joinColumns=array( > >>> [JoinColumn(name="user_id", referencedColumnName="id")] > >>> ), > >>> inverseJoinColumns=array( > >>> [JoinColumn(name="phonenumber_id", referencedColumnName="id", > >>> unique=true)] > >>> ) > >>> )] > > [Validation([Email(checkMX = true)])] > > I'm getting a feeling we are developing language inside language here. > We rejected [] syntax for arrays because it makes the intent unclear. > I'd say if that's unclear [Validation([Email(checkMX = true)])] is > super-unclear - what exactly is supposed to happen there? It is very > non-obvious. I think it needs to be radically simplified. > I understand that people that write ORMs etc. want their work to be > easier, but I don't think turning PHP into a mesh of random brackets and > words worth it. If we can't find a model that is easy to comprehend, > ORMs would have to use XML or other outside-of-syntax means. > > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > > On Wed, 2010-09-08 at 11:16 -0700, Stas Malyshev wrote: > Hi! > > >>> [JoinTable( > >>> name="users_phonenumbers", > >>> joinColumns=array( > >>> [JoinColumn(name="user_id", referencedColumnName="id")] > >>> ), > >>> inverseJoinColumns=array( > >>> [JoinColumn(name="phonenumber_id", referencedColumnName="id", > >>> unique=true)] > >>> ) > >>> )] > > [Validation([Email(checkMX = true)])] > > I'm getting a feeling we are developing language inside language here. > We rejected [] syntax for arrays because it makes the intent unclear. > I'd say if that's unclear [Validation([Email(checkMX = true)])] is > super-unclear - what exactly is supposed to happen there? It is very > non-obvious. I think it needs to be radically simplified. > I understand that people that write ORMs etc. want their work to be > easier, but I don't think turning PHP into a mesh of random brackets and > words worth it. If we can't find a model that is easy to comprehend, > ORMs would have to use XML or other outside-of-syntax means. > > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 >