Add PHPStan as a developer dependency.
PHPStan is a static PHP code analyzer that's aimed at finding actual bugs in the code. Where PHP Code Sniffer is about codeing standards, PHPStan is about correctness of code.
The provided configuration file (phpstan.neon.dist
) is configured to use the lowest level of checks that PHPStan will report on. See https://phpstan.org/user-guide/rule-levels for information about the various rule levels.
Run an analysis of the code base like this:
% ./vendor/bin/phpstan
It will output any found issues to stdout.
You can also run it like this:
% ./vendor/bin/phpstan --error-format=raw > phpstan.log
This will give you an output file in a format that's suitable for use with typical editors for mapping errors to source locations.