mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 10:07:12 +00:00
Add better support for macros and mixins (#1006)
Co-authored-by: Dominik Krämer <[email protected]>
This commit is contained in:
+21
-1
@@ -3,6 +3,7 @@
|
||||
namespace Barryvdh\LaravelIdeHelper;
|
||||
|
||||
use Barryvdh\Reflection\DocBlock;
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
class Macro extends Method
|
||||
{
|
||||
@@ -30,7 +31,26 @@ class Macro extends Method
|
||||
*/
|
||||
protected function initPhpDoc($method)
|
||||
{
|
||||
$this->phpdoc = new DocBlock($method);
|
||||
$this->phpdoc = new DocBlock('/** */');
|
||||
|
||||
// Add macro parameters
|
||||
foreach ($method->getParameters() as $parameter) {
|
||||
$type = $parameter->hasType() ? $parameter->getType()->getName() : 'mixed';
|
||||
$type .= $parameter->hasType() && $parameter->getType()->allowsNull() ? '|null' : '';
|
||||
|
||||
$name = $parameter->isVariadic() ? '...' : '';
|
||||
$name .= '$' . $parameter->getName();
|
||||
|
||||
$this->phpdoc->appendTag(Tag::createInstance("@param {$type} {$name}"));
|
||||
}
|
||||
|
||||
// Add macro return type
|
||||
if ($method->hasReturnType()) {
|
||||
$type = $method->getReturnType()->getName();
|
||||
$type .= $method->getReturnType()->allowsNull() ? '|null' : '';
|
||||
|
||||
$this->phpdoc->appendTag(Tag::createInstance("@return {$type}"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user