PHPStan (PHP Static Analysis tool) extension for coc.nvim.
CocInstall:
:CocInstall @yaegassy/coc-phpstanscoped package
vim-plug:
Plug 'yaegassy/coc-phpstan', {'do': 'yarn install --frozen-lockfile'}- Linter
- CodeAction
- Downloader
phpstan.toolPathsettingvendor/bin/phpstan(project)- Extension-only
phpstanretrieved by the download feature (:CocCommand phpstan.download)- Mac/Linux:
~/.config/coc/extensions/@yaegassy/coc-phpstan-data/phpstan - Windows:
~/AppData/Local/coc/extensions/@yaegassy/coc-phpstan-data/phpstan
- Mac/Linux:
If you wish to use a configuration file you should place the phpstan.neon, phpstan.neon.dist or phpstan.dist.neon file in the root of your project folder
This extension includes a feature to perform linting using the neon-js library in a phpstan configuration file (phpstan.neon, phpstan.neon.dist or phpstan.dist.neon).
To run this linting feature, the filetype must be neon.
Install "neon" related plugin (e.g. yaegassy/nette-neon.vim).
phpstan.enable: Enable coc-phpstan extension, default:truephpstan.toolPath: The path to the phpstan (Absolute path), default:""phpstan.level: Specifies the rule level (0 - 9 and max) to run, If you apply this setting, the level setting in the phpstan.neon file will be ignored, e.g. valid option"9","max", default:nullphpstan.configuration: Specifies the path to a configuration file, default:nullphpstan.memoryLimit: Specifies the memory limit in the same format php.ini accepts, Example: -1, 1024M, 2G, default:"-1"phpstan.download.checkOnStartup: Perform built-in download if phpstan is not present at startup, default:truephpstan.neonLint.enable: Enable neon-js lint (diagnostics). It will only work if the file name isphpstan.neon,phpstan.neon.distorphpstan.dist.neon, default:true
phpstan.download: Download PHPStanphpstan.showOutput: Show phpstan output channel
Example key mapping (Code Action related):
nmap <silent> ga <Plug>(coc-codeaction-line)Usage:
In the line with diagnostic message, enter the mapped key (e.g. ga) and you will see a list of code actions that can be performed.
Actions:
Add @phpstan-ignore-next-lineAdd @phpstan-ignore-line
MIT
This extension is built with create-coc-extension
