calvinbaart / vscode-phpstan

PHPStan extension for VSCode
https://marketplace.visualstudio.com/items?itemName=calsmurf2904.vscode-phpstan
10 stars 9 forks source link
php php-static-analysis php7 phpstan static-analysis static-code-analysis vscode-phpstan


Image Sample 1

What is this?

PHPStan is a static analysis tool for PHP. This extension integrates the output of PHPStan in VSCode allowing the developer to find errors quicker.

Installation

PHPStan is required to use this extension. By default the plugin will search the global vendor folder and the workspace vendor folders. The COMPOSER_HOME environment variable can be set to change where the plugin searches. This path can be manually set using the phpstan.path setting.

PHPStan can be installed globally using:

composer global require phpstan/phpstan

or locally using:

composer require --dev phpstan/phpstan

Commands

PHPStan includes an explorer-context command called "PHPStan: Scan for Errors". This command works on both directories and files.


Image Sample 2

Configuration

vscode-phpstan provides the following configuration properties and defaults:

"phpstan.enabled": true,
"phpstan.path": null,
"phpstan.level": "max",
"phpstan.memoryLimit": "2048M",
"phpstan.projectFile": null,
"phpstan.excludeFiles": [],
"phpstan.options": []

<workspacefolder>/phpstan.neon and <workspacefolder>/phpstan.neon.dist will be used when phpstan.projectFile is set to null. phpstan.options can be used to pass extra parameters to the phpstan commandline call.