Hi,

I love this RFC. But I have a view questions.

1.
> Since php does not support named parameter the __construct is called
> with an array as parameter
> [Foo("bar", baz="baz)]
> will call __construct(array("value" => "bar", "baz" => "baz));
>

I am a absolute C noob but I have implemented named and unnamed
exceptions in userland. So it should also be possible in C, or not!? Are
the names from the constructor parameters not available through the
reflection API? This may be a little bit more overhead but I think
unnamed annotations are very useful.

[URL('http://www.php.net', 'PHP', 'blank')] or
[URL('http://www.php.net', 'PHP')] or
[URL('url' = 'http://www.php.net', 'name' = 'PHP', 'target' = 'blank')]

class URL extends ReflectionAnnotation {

    public function __construct($url, $name, $target = 'self') {

    }
}

instead of

[URL('url' = 'http://www.php.net', 'name' = 'PHP', 'target' = 'blank')]

class URL extends ReflectionAnnotation {

    public $url;

    public $title;

    public $target = 'self';

    public function __construct($params) {

    }
}

For me an additional point for providing unnamed annotations is the
possibility to use type hinting. So it isn't possible to pass an integer
when an array is expected. I know I can validate the parameters in the
constructor. But this is additional work.

2. Is it possible to use nested annotations and what is the syntax?

3.
> AliasedName is not implemented yet, but I added in RFC as one of the
> first enhancements to be done.
> The purpose of it is to reduce the over-typing needed to instantiate
> namespaced classes.
>
> Here is the first idea:
>
> ReflectionAnnotation::addNamespaceAlias('Doctrine', 'Doctrine\ORM\Mapping');
>
> [Doctrine:Entity]
>
> would be the same to
>
> [\Doctrine\ORM\Mapping\Entity]

Is it possible to define a use statement for an annotation instead of
defining the namespace alias over the reflection API?

namespace com\mohiva\framework\cache;

use com\mohiva\framework\annotations\File;

[File('/path/to/the/file')]

Greetings,
Christian

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

Reply via email to