mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +00:00
Alias will grab macros from \Illuminate\Database\Eloquent\Builder too (#1118)
* `Alias` will grab macros from `\Illuminate\Database\Eloquent\Builder` too. * `@return` will contains `|static` for Eloquent Builder macros which return Eloquent Builder instance. * `Macro` tests. * `Alias::detectMethods()` tests. * Mock classes rename.
This commit is contained in:
+7
-2
@@ -4,6 +4,7 @@ namespace Barryvdh\LaravelIdeHelper;
|
||||
|
||||
use Barryvdh\Reflection\DocBlock;
|
||||
use Barryvdh\Reflection\DocBlock\Tag;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class Macro extends Method
|
||||
@@ -49,8 +50,12 @@ class Macro extends Method
|
||||
|
||||
// Add macro return type
|
||||
if ($method->hasReturnType()) {
|
||||
$type = $method->getReturnType()->getName();
|
||||
$type .= $method->getReturnType()->allowsNull() ? '|null' : '';
|
||||
$builder = EloquentBuilder::class;
|
||||
$return = $method->getReturnType();
|
||||
|
||||
$type = $return->getName();
|
||||
$type .= $this->root === "\\{$builder}" && $return->getName() === $builder ? '|static' : '';
|
||||
$type .= $return->allowsNull() ? '|null' : '';
|
||||
|
||||
$this->phpdoc->appendTag(Tag::createInstance("@return {$type}"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user