@yaegassy/coc-phpstan

PHPStan (PHP Static Analysis tool) extension for coc.nvim

Usage no npm install needed!

<script type="module">
  import yaegassyCocPhpstan from 'https://cdn.skypack.dev/@yaegassy/coc-phpstan';
</script>

README

coc-phpstan

PHPStan (PHP Static Analysis tool) extension for coc.nvim.

coc-phpstan-demo

Install

CocInstall:

:CocInstall @yaegassy/coc-phpstan

scoped package

vim-plug:

Plug 'yaegassy/coc-phpstan', {'do': 'yarn install --frozen-lockfile'}

Features

  • Linter
  • CodeAction
  • Downloader

Detect tool: phpstan

  1. phpstan.toolPath setting
  2. vendor/bin/phpstan (project)
  3. Extension-only phpstan retrieved 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

"phpstan.neon" or "phpstan.neon.dist" configuration file

If you wish to use a configuration file you should place the phpstan.neon or phpstan.neon.dist file in the root of your project folder

Configuration options ("coc-settings.json" or ".vim/coc-settings.json")

  • phpstan.enable: Enable coc-phpstan extension, default: true
  • phpstan.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: null
  • phpstan.configuration: Specifies the path to a configuration file, default: null
  • phpstan.memoryLimit: Specifies the memory limit in the same format php.ini accepts, Example: -1, 1024M, 2G, default: "-1"

Commands

  • phpstan.download: Download PHPStan

Code Actions

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-line
  • Add @phpstan-ignore-line

Thanks

License

MIT


This extension is built with create-coc-extension