对于收到此问题的任何人,这实际上是一个名为 laravel-extra-intellisense 的 VSCode Laravel 插件的问题。
这个问题实际上是插件的问题,因为它使用了 Laravel 5.8 及更高版本的功能,所以如果你的项目使用 Laravel 5.7 及更低版本,你可以这样做来清除错误。
将此行添加到您的config/app.php
'Arr' => Illuminate\Support\Arr::class, dlam config/app.php
添加该行后,您可能会收到类似这样的新错误
[2020-10-06 05:57:04] local.ERROR: Uncaught ReflectionException: Class App\Policies\ModelPolicy does not exist in Command line code:1
Stack trace:
#0 Command line code(1): ReflectionClass->__construct('App\\Policies\\Mo...')
#1 [internal function]: {closure}('App\\Policies\\Mo...', 'App\\Model')
#2 Command line code(1): array_map(Object(Closure), Array, Array)
#3 {main}
thrown {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 1): Uncaught ReflectionException: Class App\\Policies\\ModelPolicy does not exist in Command line code:1
Stack trace:
#0 Command line code(1): ReflectionClass->__construct('App\\\\Policies\\\\Mo...')
#1 [internal function]: {closure}('App\\\\Policies\\\\Mo...', 'App\\\\Model')
#2 Command line code(1): array_map(Object(Closure), Array, Array)
#3 {main}
thrown at Command line code:1)
[stacktrace]
#0 {main}
"}
你可以通过在app\Providers\AuthServiceProvider.php评论这一行来解决这个问题
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
// 'App\Model' => 'App\Policies\ModelPolicy', <-- comment this line
];
所有这些更改已经在最新的 Laravel(5.8 及更高版本)中
我认为发生这种情况是因为插件的记录器处理程序无法正常工作,这就是它登录您的 laravel 项目的原因。因此,在修复之前,请执行上述操作或升级您的 laravel。
您可以查看this issue in the plugin's github