private function doc($class_name, $name, $is_method = true)
{
try {
$reflection_class = null;
if ($class_name) {
$reflection = new \ReflectionClass($class_name);
$reflection_class = $reflection;
try {
if (!$is_method) {
// ReflectionProperty does not have the getFileName method
// use ReflectionClass instead
$reflection = $reflection->getProperty($name);
} else {
$interfaces = $reflection->getInterfaces();
foreach ($interfaces as $interface) {
if ($interface->hasMethod($name)) {
$reflection = $interface;
break;
}
}
$reflection = $reflection->getMethod($name);
}
} catch (\ReflectionException $e) {
$this->logger->debug($e->getMessage());
}
} else {
$reflection = new \ReflectionFunction($name);
}
$doc = $reflection->getDocComment();
// use reflection_class to fetch the property's file path
if (preg_match('/@return\\s+(static|self|\\$this)/i', $doc) || $reflection_class) {
$path = $reflection_class->getFileName();
} else {
$path = $reflection->getFileName();
}
return [$path, $this->clearDoc($doc)];
} catch (\ReflectionException $e) {
$this->logger->debug($e->getMessage());
return [null, null];
}
}