Skip to content

Commit 299a81b

Browse files
barryvdhlaravel-ide-helper
and
laravel-ide-helper
authored
Convert auth() helper to use Auth facade (#1656)
* Convert auth() helper to use Auth facade * composer fix-style --------- Co-authored-by: laravel-ide-helper <[email protected]>
1 parent 06c1fab commit 299a81b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-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: 19 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,24 @@ 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}",
125+
"@return $replace|$search",
126+
$helpers
127+
);
128+
}
129+
130+
return $helpers;
131+
}
132+
115133
protected function detectDrivers()
116134
{
117135
$defaultUserModel = config('auth.providers.users.model', config('auth.model', 'App\User'));

0 commit comments

Comments
 (0)