Add better support for macros and mixins (#1006)

Co-authored-by: Dominik Krämer <[email protected]>
This commit is contained in:
domkrm
2020-09-06 07:58:13 +02:00
committed by GitHub
co-authored by Dominik Krämer
parent 24596b67f1
commit 3a22b8daf6
4 changed files with 93 additions and 2 deletions
+21 -1
View File
@@ -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}"));
}
}
/**