lim*_*boy 2 php methods comments
我想获取一个方法的注释,以下面的方法为例:
/**
* Returns the regex to extract all inputs from a file.
* @param string The class name to search for.
* @return string The regex.
*/
public function method($param)
{
//...
}
Run Code Online (Sandbox Code Playgroud)
结果应该是
Returns the regex to extract all inputs from a file.
@param string The class name to search for.
@return string The regex.
Run Code Online (Sandbox Code Playgroud)
我发现的方法是使用像 file_get_content 这样的函数来获取文件内容 -> 过滤我想要的方法 -> 使用正则表达式获取评论
好像有点复杂,有什么方便的存档方法吗?
实际上,您可以使用 getDocComment 获取方法的文档注释
$ref=new ReflectionMethod('className', 'methodName');
echo $ref->getDocComment();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1911 次 |
| 最近记录: |