mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0abcb7497e |
+1
-1
@@ -22,7 +22,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.2",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"barryvdh/reflection-docblock": "^2.1.2",
|
"barryvdh/reflection-docblock": "^2.2",
|
||||||
"composer/class-map-generator": "^1.0",
|
"composer/class-map-generator": "^1.0",
|
||||||
"illuminate/console": "^11.15",
|
"illuminate/console": "^11.15",
|
||||||
"illuminate/database": "^11.15",
|
"illuminate/database": "^11.15",
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace <?= $namespace === '__root' ? '' : trim($namespace, '\\') ?> {
|
|||||||
namespace <?= $namespace === '__root' ? '' : trim($namespace, '\\') ?> {
|
namespace <?= $namespace === '__root' ? '' : trim($namespace, '\\') ?> {
|
||||||
<?php foreach ($aliases as $alias) : ?>
|
<?php foreach ($aliases as $alias) : ?>
|
||||||
<?php if ($alias->getExtendsNamespace() === '\Illuminate\Database\Eloquent') : ?>
|
<?php if ($alias->getExtendsNamespace() === '\Illuminate\Database\Eloquent') : ?>
|
||||||
/** @template TModel of static */
|
<?= $alias->getPhpDocTemplates(' ') ?>
|
||||||
<?php endif?>
|
<?php endif?>
|
||||||
<?= $alias->getClassType() ?> <?= $alias->getShortName() ?> extends <?= $alias->getExtends() ?> {<?php if ($alias->getExtendsNamespace() === '\Illuminate\Database\Eloquent') : ?>
|
<?= $alias->getClassType() ?> <?= $alias->getShortName() ?> extends <?= $alias->getExtends() ?> {<?php if ($alias->getExtendsNamespace() === '\Illuminate\Database\Eloquent') : ?>
|
||||||
<?php foreach ($alias->getMethods() as $method) : ?>
|
<?php foreach ($alias->getMethods() as $method) : ?>
|
||||||
|
|||||||
@@ -468,6 +468,35 @@ class Alias
|
|||||||
return $serializer->getDocComment($this->phpdoc);
|
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.
|
* Removes method tags from the doc comment that already appear as functions inside the class.
|
||||||
* This prevents duplicate function errors in the IDE.
|
* This prevents duplicate function errors in the IDE.
|
||||||
|
|||||||
Reference in New Issue
Block a user