Skip to content

Commit e60926d

Browse files
committed
Add default class for HttpClient macro
1 parent 0bbca8f commit e60926d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Macro.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55
use Barryvdh\Reflection\DocBlock;
66
use Barryvdh\Reflection\DocBlock\Tag;
77
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
8+
use Illuminate\Http\Client\PendingRequest;
89
use Illuminate\Support\Collection;
910

1011
class Macro extends Method
1112
{
13+
protected $macroDefaults = [
14+
\Illuminate\Http\Client\Factory::class => PendingRequest::class,
15+
];
16+
1217
/**
1318
* Macro constructor.
1419
*
@@ -77,6 +82,12 @@ protected function initPhpDoc($method)
7782

7883
$this->phpdoc->appendTag(Tag::createInstance("@return {$type}"));
7984
}
85+
86+
$class = ltrim($this->declaringClassName, "\\");
87+
if (!$this->phpdoc->hasTag('return') && isset($this->macroDefaults[$class])) {
88+
$type = $this->macroDefaults[$class];
89+
$this->phpdoc->appendTag(Tag::createInstance("@return {$type}"));
90+
}
8091
}
8192

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

0 commit comments

Comments
 (0)