PHPStan ΒΆ
PHPStan - a static analysis tool - will run during the ‘unit-test’ activity under Github Actions.
You can also run this locally, via:
./vendor/bin/phpstan analyze --memory-limit=-1
The current configuration is in phpstan.neon
, and currently only runs ‘level 1’ checks (see https://phpstan.org/user-guide/rule-levels):
0
: basic checks, unknown classes, unknown functions, unknown methods called on $this, wrong number of arguments passed to those methods and functions, always undefined variables1
: possibly undefined variables, unknown magic methods and properties on classes with __call and __get2
: unknown methods checked on all expressions (not just $this), validating PHPDocs3
: return types, types assigned to properties4
: basic dead code checking - always false instanceof and other type checks, dead else branches, unreachable code after return; etc.5
: checking types of arguments passed to methods and functions6
: report missing typehints7
: report partially wrong union types - if you call a method that only exists on some types in a union type, level 7 starts to report that; other possibly incorrect situations8
: report calling methods and accessing properties on nullable types
Ideally, we’ll get to level 4 or 5 over time.
PHPStan is installed via ‘larastan’, an extension package with some Laravel-specific rules.