phpreflectioncommentseaccelerator

How to get php class functions' comments?


I need to get a comment of the particular function in php class, for example:

/* Some commets for a class */
class Foo extends Bar {
    function __construct() {}

    // a single line comment to the function foo()
    function foo() {}

    /* a multi-line comment
    to the function bar() */
    public static function bar() {}

}

Yes i know, that could be easily done with ReflectionMethod->getDocComment(), but it does not work for me because i use eAccelerator and it cuts all comments from the code, so that getDocComment always returns FALSE.

I don't want to recompile eAccelerator too :)

I need a function like this:

function get_function_comment($class_contents, $function_name) {}

so that i will return a function's comment, $class_contents is a variable wich stores the class content as in the example above.

I tried to do it myself but i can't create a proper regexp..

Please help me :)


Solution

  • Try using proper phpDoc comments:

    /**
     * Something explaining this
     *
     * @return string
     */
    function foo(){  }