First, install the composer package: composer require --dev phpstan/phpstan
.
Then, add this code to your .vscode/tasks.json
:
{
"label": "PhpStan",
"detail": "Run PhpStan",
"type": "process",
"problemMatcher": {
"owner": "php",
"fileLocation": ["absolute"],
"severity": "warning",
"pattern": {
"regexp": "^(.+):(\\d+):(.+)$",
"file": 1,
"location": 2,
"message": 3
}
},
"command": "vendor/bin/phpstan",
"args": [
"analyse",
"--no-progress",
"--error-format=raw",
"${file}"
],
"presentation": {
"reveal": "never"
}
}
After that you should be able to use the task to lint your PHP files
If you prefer PSalm check here:
https://gist.github.com/jrobinsonc/e09f42e4f57deb3acbf2c6746944f6d1