From 791ba555f45284ea5f830ce3f9f8ec3dfcffb927 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 30 Dec 2024 10:31:30 +0100 Subject: [PATCH] Add meta override for user return types (#1642) * Add meta override for user return types * composer fix-style --------- Co-authored-by: laravel-ide-helper --- resources/views/meta.php | 6 ++++++ src/Console/MetaCommand.php | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/resources/views/meta.php b/resources/views/meta.php index 38fb1bb8b..3735218c2 100644 --- a/resources/views/meta.php +++ b/resources/views/meta.php @@ -21,6 +21,12 @@ ])); + + override(, map([ + '' => \::class, + ])); + + override(, map([ $value) : ?> diff --git a/src/Console/MetaCommand.php b/src/Console/MetaCommand.php index 7e83cdacb..07dcf84c0 100644 --- a/src/Console/MetaCommand.php +++ b/src/Console/MetaCommand.php @@ -73,6 +73,15 @@ class MetaCommand extends Command '\Illuminate\Support\Facades\Config::set()', ]; + protected $userMethods = [ + '\auth()->user()', + '\Illuminate\Contracts\Auth\Guard::user()', + '\Illuminate\Support\Facades\Auth::user()', + '\request()->user()', + '\Illuminate\Http\Request::user()', + '\Illuminate\Support\Facades\Request::user()', + ]; + protected $templateCache = []; /** @@ -135,6 +144,8 @@ public function handle() return gettype($value); }); + $defaultUserModel = $this->config->get('auth.providers.users.model', $this->config->get('auth.model', 'App\User')); + $content = $this->view->make('ide-helper::meta', [ 'bindings' => $bindings, 'methods' => $this->methods, @@ -143,6 +154,8 @@ public function handle() 'configValues' => $configValues, 'expectedArgumentSets' => $this->getExpectedArgumentSets(), 'expectedArguments' => $this->getExpectedArguments(), + 'userModel' => $defaultUserModel, + 'userMethods' => $this->userMethods, ])->render(); $filename = $this->option('filename');