Reference: https://phpstan.org/user-guide/getting-started
install:
composer require --dev phpstan/phpstan
run to check:
vendor/bin/phpstan analyse .\buggy-code.php
with level "-l 6"
vendor/bin/phpstan analyse -l 6 .\buggy-code.php
export errors:
vendor/bin/phpstan analyse -l 6 .\buggy-code.php --generate-baseline