Add templates to Eloquent

This commit is contained in:
Barry vd. Heuvel
2024-12-28 11:12:50 +01:00
parent a25b947851
commit 0abcb7497e
3 changed files with 31 additions and 2 deletions
+29
View File
@@ -468,6 +468,35 @@ class Alias
return $serializer->getDocComment($this->phpdoc);
}
/**
* @param $prefix
* @return string
* @throws \ReflectionException
*/
public function getPhpDocTemplates($prefix = "\t\t")
{
$templateDoc = new DocBlock('');
$serializer = new DocBlockSerializer(1, $prefix);
foreach ($this->classes as $class) {
$reflection = new ReflectionClass($class);
$traits = collect($reflection->getTraitNames());
foreach ($traits as $trait) {
$phpdoc = new DocBlock(new ReflectionClass($trait));
$templates = $phpdoc->getTagsByName('template');
/** @var DocBlock\Tag\TemplateTag $template */
foreach ($templates as $template) {
$template->setBound('static');
$template->setDocBlock($templateDoc);
$templateDoc->appendTag($template);
}
}
}
return $serializer->getDocComment($templateDoc);
}
/**
* Removes method tags from the doc comment that already appear as functions inside the class.
* This prevents duplicate function errors in the IDE.