public function location($class_name, $method_name = null)
{
try {
if ($class_name) {
$reflection = new \ReflectionClass($class_name);
if (!$method_name) {
$method_name = '__construct';
}
if ($reflection->hasMethod($method_name)) {
$reflection = $reflection->getMethod($method_name);
} elseif ($reflection->hasConstant($method_name)) {
// 常量则返回 [ path, 'const CONST_NAME' ]
return [$this->getConstPath($method_name, $reflection), 'const ' . $method_name];
}
} else {
$reflection = new \ReflectionFunction($method_name);
}
return [$reflection->getFileName(), $reflection->getStartLine()];
} catch (\ReflectionException $e) {
return ['', null];
}
}