有需要web在线查看对象文档需求,简单测试可行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
function test1(){ $class = new ReflectionClass('TestObject'); //$properties = $class->getProperties(); $methods = $class->getMethods(ReflectionMethod::IS_PUBLIC); foreach($methods as $method){ $doc = $method->getDocComment(); echo "\t" . $doc; echo "\n"; $params = $method->getParameters(); echo implode(' ', Reflection::getModifierNames($method->getModifiers())); echo ' ', $method->getName() . '('; foreach($params as $param){ echo $param->getName(); if($param->isDefaultValueAvailable()){ $value = $param->getDefaultValue(); echo "=", $value; } } echo ")"; echo "\n"; } } |