diff --git a/config/ide-helper.php b/config/ide-helper.php index efcb0ee06..1500783aa 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -123,6 +123,7 @@ 'helper_files' => [ base_path() . '/vendor/laravel/framework/src/Illuminate/Support/helpers.php', + base_path() . '/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php', ], /* diff --git a/src/Generator.php b/src/Generator.php index 78607b64b..dc312f24e 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -80,7 +80,7 @@ public function generate() ->with('namespaces_by_extends_ns', $this->getAliasesByExtendsNamespace()) ->with('namespaces_by_alias_ns', $this->getAliasesByAliasNamespace()) ->with('real_time_facades', $this->getRealTimeFacades()) - ->with('helpers', $this->helpers) + ->with('helpers', $this->detectHelpers()) ->with('include_fluent', $this->config->get('ide-helper.include_fluent', true)) ->with('factories', $this->config->get('ide-helper.include_factory_builders') ? Factories::all() : []) ->render(); @@ -112,6 +112,24 @@ public function generateEloquent() ->render(); } + protected function detectHelpers() + { + $helpers = $this->helpers; + + $replacements = [ + '($guard is null ? \Illuminate\Contracts\Auth\Factory : \Illuminate\Contracts\Auth\StatefulGuard)' => '\\Auth', + ]; + foreach ($replacements as $search => $replace) { + $helpers = Str::replace( + "@return {$search}", + "@return $replace|$search", + $helpers + ); + } + + return $helpers; + } + protected function detectDrivers() { $defaultUserModel = config('auth.providers.users.model', config('auth.model', 'App\User'));