|
12 | 12 | namespace Barryvdh\LaravelIdeHelper\Console; |
13 | 13 |
|
14 | 14 | use Barryvdh\LaravelIdeHelper\Factories; |
| 15 | +use Dotenv\Parser\Entry; |
| 16 | +use Dotenv\Parser\Parser; |
15 | 17 | use Illuminate\Console\Command; |
16 | 18 | use Illuminate\Contracts\Config\Repository; |
17 | 19 | use Illuminate\Contracts\View\Factory; |
@@ -68,9 +70,7 @@ class MetaCommand extends Command |
68 | 70 | protected $configMethods = [ |
69 | 71 | '\config()', |
70 | 72 | '\Illuminate\Config\Repository::get()', |
71 | | - '\Illuminate\Config\Repository::set()', |
72 | 73 | '\Illuminate\Support\Facades\Config::get()', |
73 | | - '\Illuminate\Support\Facades\Config::set()', |
74 | 74 | ]; |
75 | 75 |
|
76 | 76 | protected $userMethods = [ |
@@ -202,59 +202,105 @@ protected function registerClassAutoloadExceptions(): callable |
202 | 202 | protected function getExpectedArgumentSets() |
203 | 203 | { |
204 | 204 | return [ |
| 205 | + 'auth' => $this->loadTemplate('auth')->keys()->filter()->toArray(), |
205 | 206 | 'configs' => $this->loadTemplate('configs')->pluck('name')->filter()->toArray(), |
| 207 | + 'middleware' => $this->loadTemplate('middleware')->keys()->filter()->toArray(), |
206 | 208 | 'routes' => $this->loadTemplate('routes')->pluck('name')->filter()->toArray(), |
207 | 209 | 'views' => $this->loadTemplate('views')->pluck('key')->filter()->map(function ($value) { |
208 | 210 | return (string) $value; |
209 | 211 | })->toArray(), |
210 | 212 | 'translations' => $this->loadTemplate('translations')->filter()->keys()->toArray(), |
| 213 | + 'env' => $this->getEnv(), |
211 | 214 | ]; |
212 | 215 | } |
213 | 216 |
|
214 | 217 | protected function getExpectedArguments() |
215 | 218 | { |
216 | 219 | return [ |
217 | | - '\config()' => [ |
218 | | - 0 => 'configs', |
| 220 | + [ |
| 221 | + 'class' => '\Illuminate\Support\Facades\Gate', |
| 222 | + 'method' => [ |
| 223 | + 'has', |
| 224 | + 'allows', |
| 225 | + 'denies', |
| 226 | + 'check', |
| 227 | + 'any', |
| 228 | + 'none', |
| 229 | + 'authorize', |
| 230 | + 'inspect', |
| 231 | + ], |
| 232 | + 'argumentSet' => 'auth', |
219 | 233 | ], |
220 | | - '\Illuminate\Config\Repository::get()' => [ |
221 | | - 0 => 'configs', |
| 234 | + [ |
| 235 | + 'class' => ['\Illuminate\Support\Facades\Route', '\Illuminate\Support\Facades\Auth'], |
| 236 | + 'method' => ['can', 'cannot'], |
| 237 | + 'argumentSet' => 'auth', |
222 | 238 | ], |
223 | | - '\Illuminate\Config\Repository::set()' => [ |
224 | | - 0 => 'configs', |
| 239 | + [ |
| 240 | + 'method' => 'config', |
| 241 | + 'argumentSet' => 'configs', |
225 | 242 | ], |
226 | | - '\Illuminate\Support\Facades\Config::get()' => [ |
227 | | - 0 => 'configs', |
| 243 | + [ |
| 244 | + 'class' => ['\Illuminate\Config\Repository', '\Illuminate\Support\Facades\Config'], |
| 245 | + 'method' => [ |
| 246 | + 'get', |
| 247 | + 'getMany', |
| 248 | + 'set', |
| 249 | + 'string', |
| 250 | + 'integer', |
| 251 | + 'boolean', |
| 252 | + 'float', |
| 253 | + 'array', |
| 254 | + 'prepend', |
| 255 | + 'push', |
| 256 | + ], |
| 257 | + 'argumentSet' => 'configs', |
228 | 258 | ], |
229 | | - '\Illuminate\Support\Facades\Config::set()' => [ |
230 | | - 0 => 'configs', |
| 259 | + [ |
| 260 | + 'class' => ['\Illuminate\Support\Facades\Route', '\Illuminate\Routing\Router'], |
| 261 | + 'method' => ['middleware', 'withoutMiddleware'], |
| 262 | + 'argumentSet' => 'middleware', |
231 | 263 | ], |
232 | | - '\route()' => [ |
233 | | - 0 => 'routes', |
| 264 | + [ |
| 265 | + 'method' => ['route', 'to_route', 'signedRoute'], |
| 266 | + 'argumentSet' => 'routes', |
234 | 267 | ], |
235 | | - '\Illuminate\Support\Facades\Route::get()' => [ |
236 | | - 0 => 'routes', |
| 268 | + [ |
| 269 | + 'class' => [ |
| 270 | + '\Illuminate\Support\Facades\Redirect', |
| 271 | + '\Illuminate\Support\Facades\URL', |
| 272 | + '\Illuminate\Routing\Redirector', |
| 273 | + '\Illuminate\Routing\UrlGenerator', |
| 274 | + ], |
| 275 | + 'method' => ['route', 'signedRoute', 'temporarySignedRoute'], |
| 276 | + 'argumentSet' => 'routes', |
237 | 277 | ], |
238 | | - '\Illuminate\Routing\Router::get()' => [ |
239 | | - 0 => 'routes', |
| 278 | + [ |
| 279 | + 'method' => 'view', |
| 280 | + 'argumentSet' => 'views', |
240 | 281 | ], |
241 | | - '\view()' => [ |
242 | | - 0 => 'views', |
| 282 | + [ |
| 283 | + 'class' => ['\Illuminate\Support\Facades\View', '\Illuminate\View\Factory'], |
| 284 | + 'method' => 'make', |
| 285 | + 'argumentSet' => 'views', |
243 | 286 | ], |
244 | | - '\Illuminate\Support\Facades\View::make()' => [ |
245 | | - 0 => 'views', |
| 287 | + [ |
| 288 | + 'method' => ['__', 'trans'], |
| 289 | + 'argumentSet' => 'translations', |
246 | 290 | ], |
247 | | - '\Illuminate\View\Factory::make()' => [ |
248 | | - 0 => 'views', |
| 291 | + [ |
| 292 | + 'class' => ['\Illuminate\Contracts\Translation\Translator'], |
| 293 | + 'method' => ['get'], |
| 294 | + 'argumentSet' => 'translations', |
249 | 295 | ], |
250 | | - '\__()' => [ |
251 | | - 0 => 'translations', |
| 296 | + [ |
| 297 | + 'method' => 'env', |
| 298 | + 'argumentSet' => 'env', |
252 | 299 | ], |
253 | | - '\trans()' => [ |
254 | | - 0 => 'translations', |
255 | | - ], |
256 | | - '\Illuminate\Contracts\Translation\Translator::get()' => [ |
257 | | - 0 => 'translations', |
| 300 | + [ |
| 301 | + 'class' => '\Illuminate\Support\Env', |
| 302 | + 'method' => 'get', |
| 303 | + 'argumentSet' => 'env', |
258 | 304 | ], |
259 | 305 | ]; |
260 | 306 | } |
@@ -290,6 +336,21 @@ protected function getOptions() |
290 | 336 | ]; |
291 | 337 | } |
292 | 338 |
|
| 339 | + protected function getEnv() |
| 340 | + { |
| 341 | + $envPath = base_path('.env'); |
| 342 | + if (!file_exists($envPath)) { |
| 343 | + return []; |
| 344 | + } |
| 345 | + |
| 346 | + $parser = new Parser(); |
| 347 | + $entries = $parser->parse(file_get_contents($envPath)); |
| 348 | + |
| 349 | + return collect($entries)->map(function (Entry $entry) { |
| 350 | + return $entry->getName(); |
| 351 | + }); |
| 352 | + } |
| 353 | + |
293 | 354 | /** |
294 | 355 | * Remove our custom autoloader that we pushed onto the autoload stack |
295 | 356 | * |
|
0 commit comments