PHPStan v0.12.67 releases: PHP Static Analysis Tool
PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code. It moves PHP closer to compiled languages in the sense that the correctness of each line of the code can be checked before you run the actual line.
What it currently checks for?
- Existence of classes used in instanceof, catch, typehints and other language constructs. PHP does not check this and just stays instead, rendering the surrounded code unused.
- Existence and accessibility of called methods and functions. It also checks the number of passed arguments.
- Whether a method returns the same type it declares to return.
- Existence and visibility of accessed properties. It will also point out if a different type from the declared one is assigned to the property.
- The correct number of parameters passed to sprintf/printf calls based on format strings.
- Existence of variables while respecting scopes of branches and loops.
- Useless casting like (string) ‘foo’ and strict comparisons (=== and !==) with different types as operands which always result in false.
PHPStan is fast…
It manages to check the whole codebase in a single pass. It doesn’t need to go through the code multiple times. And it only needs to go through the code you wish to analyze, e.g. the code you have written. It doesn’t need to parse and analyze 3rd party dependencies. Instead, it uses reflection to find out useful information about somebody else’s code your codebase uses.
PHPStan is able to check our codebase (6000 files, 600k LOCs) in around a minute. And it checks itself under a second.
@varsupport so that view files can be analysed successfully (phpstan/phpstan-src@22d363c, phpstan/phpstan-src@27481c3), #4155, #3516, #3515, #351
- Report only relevant “unable to resolve template type” message (phpstan/phpstan-src@a5f9f0c), #3853
- Unable to resolve the template type – tip with a blogpost link (phpstan/phpstan-src@3c56362)
- NewStaticRule – tip with a blogpost link (phpstan/phpstan-src@96f1e10)
PHPStan\Reflection\Generic\ResolvedFunctionVariantin favor of
- Fixed skipping shadowed trait method by a native method (phpstan/phpstan-src@2de6a24), #4214
$thisstate (phpstan/phpstan-src@c8174d5), #4351
- Smoother parallel process quitting when the child process crashes (phpstan/phpstan-src@cbbbd36), phpstan/phpstan-doctrine#169
Copyright (c) 2016 Ondřej Mirtes