Visual Studio Code PHP Intelephense Keep Showing Not Necessary Error

前端 未结 15 855
广开言路
广开言路 2020-12-04 06:14

After the latest update of PHP Intelephense that I get today, the intelephense keep showing an error for an undefined symbol for my route (and other class too), there is no

15条回答
  •  余生分开走
    2020-12-04 06:52

    For anyone going through these issues and uneasy about disabling a whole set of checks, there is a way to pass your own custom signatures to Intelephense.

    Copied from Intelephese repo's comment (by @KapitanOczywisty):
    https://github.com/bmewburn/vscode-intelephense/issues/892#issuecomment-565852100

    For single workspace it is very simple, you have to create .php file with all signatures and intelephense will index them.

    If you want add stubs globally, you still can, but I'm not sure if it's intended feature. Even if intelephense.stubs throws warning about incorrect value you can in fact put there any folder name.

    {   
       "intelephense.stubs": [
           // ...
           "/path/to/your/stub"   
       ] 
    } 
    

    Note: stubs are refreshed with this setting change.

    You can take a look at build-in stubs here: https://github.com/JetBrains/phpstorm-stubs

    In my case, I needed dspec's describe, beforeEach, it... to don't be highlighted as errors, so I just included the file with the signatures /directories_and_paths/app/vendor/bin/dspec in my VSCode's workspace settings, which had the function declarations I needed:

    function describe($description = null, \Closure $closure = null) {
    }
    
    function it($description, \Closure $closure) {
    }
    
    // ... and so on
    

提交回复
热议问题