First, install the composer package: composer require --dev vimeo/psalm
.
Then, add this code to your .vscode/tasks.json
:
{
"label": "Psalm",
"detail": "Run Psalm",
"type": "process",
"problemMatcher": {
"owner": "php",
"fileLocation": ["relative", "${workspaceFolder}"],
"severity": "warning",
"pattern": {
"regexp": "^(ERROR):\\s([^\\s]+)\\s-\\s([^:]+):([0-9]+):([0-9]+)\\s-\\s(.+)$",
"file": 3,
"line": 4,
"column": 5,
"severity": 1,
"message": 6,
"code": 2
}
},
"command": "vendor/bin/psalm",
"args": [
"${file}"
],
"presentation": {
"reveal": "never"
}
}
After that you should be able to use the task to lint your PHP files
If you prefer PHPStan check here:
https://gist.github.com/jrobinsonc/d1672d16bdfd930b7e43ea19f40fd1d3