Add meta override for user return types (#1642)

* Add meta override for user return types

* composer fix-style

---------

Co-authored-by: laravel-ide-helper <[email protected]>
This commit is contained in:
Barry vd. Heuvel
2024-12-30 10:31:30 +01:00
committed by GitHub
co-authored by laravel-ide-helper
parent c324438731
commit 791ba555f4
2 changed files with 19 additions and 0 deletions
+6
View File
@@ -21,6 +21,12 @@ namespace PHPSTORM_META {
])); ]));
<?php endforeach; ?> <?php endforeach; ?>
<?php foreach ($userMethods as $method) : ?>
override(<?= $method ?>, map([
'' => \<?= $userModel ?>::class,
]));
<?php endforeach; ?>
<?php foreach ($configMethods as $method) : ?> <?php foreach ($configMethods as $method) : ?>
override(<?= $method ?>, map([ override(<?= $method ?>, map([
<?php foreach ($configValues as $name => $value) : ?> <?php foreach ($configValues as $name => $value) : ?>
+13
View File
@@ -73,6 +73,15 @@ class MetaCommand extends Command
'\Illuminate\Support\Facades\Config::set()', '\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 = []; protected $templateCache = [];
/** /**
@@ -135,6 +144,8 @@ class MetaCommand extends Command
return gettype($value); 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', [ $content = $this->view->make('ide-helper::meta', [
'bindings' => $bindings, 'bindings' => $bindings,
'methods' => $this->methods, 'methods' => $this->methods,
@@ -143,6 +154,8 @@ class MetaCommand extends Command
'configValues' => $configValues, 'configValues' => $configValues,
'expectedArgumentSets' => $this->getExpectedArgumentSets(), 'expectedArgumentSets' => $this->getExpectedArgumentSets(),
'expectedArguments' => $this->getExpectedArguments(), 'expectedArguments' => $this->getExpectedArguments(),
'userModel' => $defaultUserModel,
'userMethods' => $this->userMethods,
])->render(); ])->render();
$filename = $this->option('filename'); $filename = $this->option('filename');