private function getDocBlock(Project $project, int $objectType, string $namespace = null, string $object = null, string $function)
{
switch ($objectType) {
case self::OBJECT_FUNCTION:
if (null === $namespace) {
$function = sprintf('\\%s()', $function);
} else {
$function = sprintf('%s\\%s()', $namespace, $function);
}
foreach ($project->getFiles() as $file) {
return $this->getDocBlockForFunction($file->getFunctions(), $function);
}
return;
case self::OBJECT_CLASS:
$method = 'getClasses';
break;
case self::OBJECT_INTERFACE:
$method = 'getInterfaces';
break;
case self::OBJECT_TRAIT:
$method = 'getTraits';
break;
}
$fqsen = $namespace . '\\' . $object;
$fqfunction = sprintf('%s::%s()', $fqsen, $function);
foreach ($project->getFiles() as $file) {
foreach ($file->{$method}() as $obj) {
if ($obj->getFqsen()->__toString() === $fqsen) {
$docBlock = $this->getDocBlockForFunction($obj->getMethods(), $fqfunction);
if (self::OBJECT_TRAIT === $objectType || null !== $docBlock && 0 !== strcasecmp('{@inheritdoc}', trim($docBlock->getSummary()))) {
return $docBlock;
}
if ($obj instanceof Class_) {
if ($docBlock = $this->getDocBlockForInterfaces($project, $obj->getInterfaces(), $function)) {
return $docBlock;
}
$parentFqsen = $obj->getParent();
if (null === $parentFqsen || !($parent = $this->getObject($project, $parentFqsen, self::OBJECT_CLASS))) {
return;
}
return $this->getDocBlock($project, self::OBJECT_CLASS, $this->getNamespace($parentFqsen), $parent->getName(), $function);
}
if ($obj instanceof Interface_ && ($docBlock = $this->getDocBlockForInterfaces($project, $obj->getParents(), $function))) {
return $docBlock;
}
}
}
}
}