记住用户名密码
function getControllers($dir)
{
$pathList = glob($dir . '/*.php');
$res = [];
foreach($pathList as $key => $value) {
$res[] = basename($value, '.php');
}
return $res;
}
function getActions($className, $base='\app\BaseController')
{
$className = '\app\controller\\'.$className;
$methods = array();
$baseMethods = array();
$rMethods = (new \ReflectionClass($className))->getMethods();
$rbMethods = (new \ReflectionClass($base))->getMethods();
foreach ($rMethods as $m) {
$doc = $m->getDocComment();
$s = cc_get_desc($doc);
array_push($methods, $m->getName().'/'.$s);
}
foreach ($rbMethods as $m) {
$doc = $m->getDocComment();
$s = cc_get_desc($doc);
array_push($baseMethods, $m->getName().'/'.$s);
}
$res = array_diff($methods, $baseMethods);
return $res;
}
function cc_get_desc($doc)
{
$tmp = array();
preg_match_all('/@test(.*?)[\r\n|\n]/', $doc, $tmp);
return trim($tmp[1][0] ?? "");
}
// 类注解
/**
* class function quanxian 方法注解
* @test 权限
*/
// 调用
$result = getControllers('../app/controller');
dump($result);
foreach ($result as $v) {
$m = getActions($v);
dump($m);
}
目前有 0 条留言 其中:访客:0 条, 博主:0 条