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 > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php