mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
Add @see location for macros & mixins to PhpDoc (#1054)
* Add @see location for macros & mixins to PhpDoc * Fix CS * Add entry to changelog * Improve changelog entry * Adjust CS * Update CHANGELOG.md Co-authored-by: Markus Podar <[email protected]>
This commit is contained in:
co-authored by
Markus Podar
parent
00ee13e0cf
commit
2ff9672a49
@@ -4,6 +4,7 @@ namespace Barryvdh\LaravelIdeHelper;
|
||||
|
||||
use Barryvdh\Reflection\DocBlock;
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class Macro extends Method
|
||||
{
|
||||
@@ -33,6 +34,8 @@ class Macro extends Method
|
||||
{
|
||||
$this->phpdoc = new DocBlock('/** */');
|
||||
|
||||
$this->addLocationToPhpDoc();
|
||||
|
||||
// Add macro parameters
|
||||
foreach ($method->getParameters() as $parameter) {
|
||||
$type = $parameter->hasType() ? $parameter->getType()->getName() : 'mixed';
|
||||
@@ -53,6 +56,24 @@ class Macro extends Method
|
||||
}
|
||||
}
|
||||
|
||||
protected function addLocationToPhpDoc()
|
||||
{
|
||||
$enclosingClass = $this->method->getClosureScopeClass();
|
||||
|
||||
/** @var \ReflectionMethod $enclosingMethod */
|
||||
$enclosingMethod = Collection::make($enclosingClass->getMethods())
|
||||
->first(function (\ReflectionMethod $method) {
|
||||
return $method->getStartLine() <= $this->method->getStartLine()
|
||||
&& $method->getEndLine() >= $this->method->getEndLine();
|
||||
});
|
||||
|
||||
if ($enclosingMethod) {
|
||||
$this->phpdoc->appendTag(Tag::createInstance(
|
||||
'@see \\' . $enclosingClass->getName() . '::' . $enclosingMethod->getName() . '()'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ReflectionFunctionAbstract $method
|
||||
* @param \ReflectionClass $class
|
||||
|
||||
Reference in New Issue
Block a user