Hi Dmitry,

> De : Dmitry Stogov [mailto:dmi...@zend.com]
> Nested annotations are not going to be necessary, because they may be
> represented by PHP pseudo-syntax (and/or PHP array syntax)
> 
> <Doctrine_Join(
>     ManyToMany($targetEntity="Phonenumber"),
>     JoinTable($name="users_phonenumbers",
>         $joinColumns=JoinColumn($name="user_id",
> $referencedColumnName="id"))
>     inverseJoinColumns=JoinColumn($name="phonenumber_id",
> $referencedColumnName="id", $unique=true))>
> class User {
>    ...
> }
> 
> $r = new ReflectionClass("User");
> $ast = $r->getAnnotation("Doctine_Join");
> echo $ast->child[0]->child[0]; // "ManyToMany"
> echo $ast->child[0]->child[1]->child[0]->child[0]; // "$targetEntity"
> 
> or If we provide API similar to SimpleXML
> 
> echo $ast[0][0]; // "ManyToMany"
> echo $ast[0][1][0][0]; // "$targetEntity"

Please, no new pseudo language. Either value is a bare string and application 
has responsibility to parse it, or it is a PHP expression, especially since we 
have short array syntax. If user needs runtime evaluation, as in DbC, he just 
passes his expression in a string.

Accessing ast elements by index is quite poor too, and if it is to define 
associative pseudo-arrays, let's use PHP arrays.

Also, a detail, same as Derick's : '<>' reminds html/xml too much, IMO. While 
completely different, it will confuse a lot of people. I prefer '<<>>'. No 
ambiguity.

So :

<<Doctrine_Join([
    'ManyToMany' => [ 'targetEntity' => "Phonenumber" ],
    'JoinTable' => [
        'name' => "users_phonenumbers" ,
        'joinColumns' => [
                        [ 'name' => 'user_id', 'referencedColumnName' => 'id' ]
                ],
        'inverseJoinColumns' => [
                        [ 'name' => "phonenumber_id", 'referencedColumnName' => 
"id", 'unique' => true ]
                ]
    ]
 ] ) >>

A last question: in such a case, should '<<' strings appearing in the 
expression have to be quoted, or would it take care of string delimiters when 
searching for the end of the annotation ?

Regards

François



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to