diff --git a/src/Macro.php b/src/Macro.php index 3679d79fb..42e409d11 100644 --- a/src/Macro.php +++ b/src/Macro.php @@ -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. * @@ -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