我需要获取 php 类中特定函数的注释,例如:
/* 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() {}
}
是的,我知道,这可以通过 ReflectionMethod->getDocComment() 轻松完成,但它对我不起作用,因为我使用 eAccelerator 并且它会从代码中删除所有注释,因此 getDocComment 总是返回 FALSE。
我也不想重新编译 eAccelerator :)
我需要这样的功能:
function get_function_comment($class_contents, $function_name) {}
所以我会返回一个函数的注释,$class_contents 是一个变量,它存储类内容,如上例所示。
我尝试自己做,但我无法创建正确的正则表达式..
请帮我 :)