File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed
Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 2222 "require" : {
2323 "php" : " ^8.2" ,
2424 "ext-json" : " *" ,
25- "barryvdh/reflection-docblock" : " ^2.1. 2" ,
25+ "barryvdh/reflection-docblock" : " ^2.2" ,
2626 "composer/class-map-generator" : " ^1.0" ,
2727 "illuminate/console" : " ^11.15" ,
2828 "illuminate/database" : " ^11.15" ,
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefau
5050namespace <?= $ namespace === '__root ' ? '' : trim ($ namespace , '\\' ) ?> {
5151 <?php foreach ($ aliases as $ alias ) : ?>
5252 <?php if ($ alias ->getExtendsNamespace () === '\Illuminate\Database\Eloquent ' ) : ?>
53- /** @template TModel of static */
53+ <?= $ alias -> getPhpDocTemplates ( ' ' ) ?>
5454 <?php endif ?>
5555 <?= $ alias ->getClassType () ?> <?= $ alias ->getShortName () ?> extends <?= $ alias ->getExtends () ?> {<?php if ($ alias ->getExtendsNamespace () === '\Illuminate\Database\Eloquent ' ) : ?>
5656 <?php foreach ($ alias ->getMethods () as $ method ) : ?>
Original file line number Diff line number Diff line change @@ -468,6 +468,35 @@ public function getDocComment($prefix = "\t\t")
468468 return $ serializer ->getDocComment ($ this ->phpdoc );
469469 }
470470
471+ /**
472+ * @param $prefix
473+ * @return string
474+ * @throws \ReflectionException
475+ */
476+ public function getPhpDocTemplates ($ prefix = "\t\t" )
477+ {
478+ $ templateDoc = new DocBlock ('' );
479+ $ serializer = new DocBlockSerializer (1 , $ prefix );
480+
481+ foreach ($ this ->classes as $ class ) {
482+ $ reflection = new ReflectionClass ($ class );
483+ $ traits = collect ($ reflection ->getTraitNames ());
484+
485+ foreach ($ traits as $ trait ) {
486+ $ phpdoc = new DocBlock (new ReflectionClass ($ trait ));
487+ $ templates = $ phpdoc ->getTagsByName ('template ' );
488+
489+ /** @var DocBlock\Tag\TemplateTag $template */
490+ foreach ($ templates as $ template ) {
491+ $ template ->setBound ('static ' );
492+ $ template ->setDocBlock ($ templateDoc );
493+ $ templateDoc ->appendTag ($ template );
494+ }
495+ }
496+ }
497+ return $ serializer ->getDocComment ($ templateDoc );
498+ }
499+
471500 /**
472501 * Removes method tags from the doc comment that already appear as functions inside the class.
473502 * This prevents duplicate function errors in the IDE.
You can’t perform that action at this time.
0 commit comments