This is what I was going for. Your idea looks better.

On Mon, Jan 7, 2013 at 4:45 PM, Anthony Ferrara <ircmax...@gmail.com> wrote:
> Yahav and all,
>
>
> On Sun, Jan 6, 2013 at 4:58 PM, Yahav Gindi Bar <g.b.ya...@gmail.com> wrote:
>
>> Hi internals!
>>
>> In one of the discussions (about the "deprecated" keyword, to be specific),
>> it was been said that adding ability to read doc-comment annotation could
>> be handy. Personally, I really think it can be great.
>>
>> So, I've created an RFC that propose to improve the Reflection extension by
>> adding the ability to read annotations decorated in the doc-comment.
>>
>> https://wiki.php.net/rfc/reflection_doccomment_annotations
>>
>> What is your opinion about this?
>>
>> Regards,
>> Yahav.
>>
>
> Why does this need to be part of Reflection? Seems a rather odd place for
> it IMHO, since it basically hard-codes the functionality into part of the
> core that's not trivially extendable (at least $class->getMethods() is hard
> to override)...
>
> Instead, what about adding a SPL class to parse the comment. Something like
>
> class SplAnnotationParser {
>     const PARSE_DEFAULT = 1;
>     const PARSE_FUNCTION = 2;
>     public function __construct($rules = self::PARSE_DEFAULT);
>
>     /**
>      * @param string $comment The comment to parse
>      * @returns array An array of parsed annotations, pursuant to the
> ruleset used
>     public function parseAnnotations($comment);
> }
>
> That way, you'd do:
>
> $parser = new SplAnnotationParser(SplAnnotationParser::PARE_FUNCTION);
> foreach ($class->getMethods() as $method) {
>     $annotations = $parser->parseAnnotations($method->getDocComment());
> }
>
> It decouples the implementation, and allows for people to polymorphically
> substitute different parsers for different needs.
>
> Thoughts?
>
> Anthony

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

Reply via email to