检测函数是否有参数

function need_params($func) {
    $reflection = new ReflectionFunction($func);
    return $reflection->getNumberOfParameters();
}

检测函数的属性

function hasPublicConstructor($class) {
    try {
        $m = new ReflectionMethod($class, $class);
        if ($m->isPublic()) {
             return true;
        }
    }
    catch (ReflectionException $e) {

    }
    try {
     $m = new ReflectionMethod($class,'__construct');
     if ($m->isPublic()) {
         return true;
     }
    }
    catch (ReflectionException $e) {
    }
    return false;
}