ReflectionClass::getDocComment
作用:获取文档注释
用例:
<?php
/**
* A test class
*
* @param foo bar
* @return baz
*/
class TestClass {
/**
* This class1111 will test annotations.
*
* @test
* @constTest(TestClass::ABC)
* @order('ASC', 'field1')
* @order('DESC', 'field2')
*/
function fn(){
echo "22";
}
}
$rc = new ReflectionClass('TestClass');
var_dump($rc->getDocComment())
//output:
string(55) "/**
* A test class
*
* @param foo bar
* @return baz
*/"
var_dump($rc->getMethod('fn')->getDocComment());
//output:
string(152) "/**
* This class1111 will test annotations.
*
* @test
* @constTest(TestClass::ABC)
* @order('ASC', 'field1')
* @order('DESC', 'field2')
*/"
?>
参考
http://php.net/manual/zh/reflectionclass.getdoccomment.php