amir9480 / vscode-laravel-extra-intellisense

This extension adds extra autocompletion for laravel projects to VSCode.
https://marketplace.visualstudio.com/items?itemName=amiralizadeh9480.laravel-extra-intellisense
MIT License
3.44k stars 55 forks source link

PHP Fatal error: Uncaught ReflectionException: Class App\Policies\ModelPolicy does not exist in Command line code:1 #129

Open Ruko97 opened 1 month ago

Ruko97 commented 1 month ago

System: Windows 11 Description: I installed the Laravel Extra Intellisense from the VS Code Extension marketplace. The extension never worked, and the following error message started to occur instead of running properly

PHP Fatal 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 in Command line code on line 1

Because of backward compatibility, I am using PHP 7.4 and Laravel Framework 5.8. Could that be the reason the extension doesn't work?

papandrk commented 1 month ago

For other projects I have tested this extension with all seems to be working normal. In one though I get the same error as @Ruko97. I'm not sure why, but inside the file app/Providers/AuthServiceProvider.php there was this:

    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        'App\Model' => 'App\Policies\ModelPolicy',
    ];

I removed the entry and left the $policies array empty and the error stopped popping up! I don't know if I have inadvertently broken something - I hope not! Does anyone know what that entry could be doing there?