Skip to content

Commit 73aae3c

Browse files
committed
Convert auth() helper to use Auth facade
1 parent 271682a commit 73aae3c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

config/ide-helper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123

124124
'helper_files' => [
125125
base_path() . '/vendor/laravel/framework/src/Illuminate/Support/helpers.php',
126+
base_path() . '/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php',
126127
],
127128

128129
/*

src/Generator.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function generate()
8080
->with('namespaces_by_extends_ns', $this->getAliasesByExtendsNamespace())
8181
->with('namespaces_by_alias_ns', $this->getAliasesByAliasNamespace())
8282
->with('real_time_facades', $this->getRealTimeFacades())
83-
->with('helpers', $this->helpers)
83+
->with('helpers', $this->detectHelpers())
8484
->with('include_fluent', $this->config->get('ide-helper.include_fluent', true))
8585
->with('factories', $this->config->get('ide-helper.include_factory_builders') ? Factories::all() : [])
8686
->render();
@@ -112,6 +112,22 @@ public function generateEloquent()
112112
->render();
113113
}
114114

115+
protected function detectHelpers()
116+
{
117+
$helpers = $this->helpers;
118+
119+
$replacements = [
120+
'($guard is null ? \Illuminate\Contracts\Auth\Factory : \Illuminate\Contracts\Auth\StatefulGuard)' => '\\Auth'
121+
];
122+
foreach ($replacements as $search => $replace) {
123+
$helpers= Str::replace(
124+
"@return {$search}", "@return $replace|$search", $helpers
125+
);
126+
}
127+
128+
return $helpers;
129+
}
130+
115131
protected function detectDrivers()
116132
{
117133
$defaultUserModel = config('auth.providers.users.model', config('auth.model', 'App\User'));

0 commit comments

Comments
 (0)