Skip to content

Commit

Permalink
Feat guess macro types (#1648)
Browse files Browse the repository at this point in the history
* Add default class for HttpClient macro

* composer fix-style

---------

Co-authored-by: laravel-ide-helper <[email protected]>
  • Loading branch information
barryvdh and laravel-ide-helper authored Jan 1, 2025
1 parent 0bbca8f commit beda399
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Macro.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
use Barryvdh\Reflection\DocBlock;
use Barryvdh\Reflection\DocBlock\Tag;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Collection;

class Macro extends Method
{
protected $macroDefaults = [
\Illuminate\Http\Client\Factory::class => PendingRequest::class,
];

/**
* Macro constructor.
*
Expand Down Expand Up @@ -77,6 +82,12 @@ protected function initPhpDoc($method)

$this->phpdoc->appendTag(Tag::createInstance("@return {$type}"));
}

$class = ltrim($this->declaringClassName, '\\');
if (!$this->phpdoc->hasTag('return') && isset($this->macroDefaults[$class])) {
$type = $this->macroDefaults[$class];
$this->phpdoc->appendTag(Tag::createInstance("@return {$type}"));
}
}

protected function concatReflectionTypes(?\ReflectionType $type): string
Expand Down

0 comments on commit beda399

Please sign in to comment.