PHPStan v1.10.39 releases: PHP Static Analysis Tool
PHPStan – 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.
Changelog v1.10.39
Improvements 🔧
- More information about thrown exception in child process (phpstan/phpstan-src@d6a576a)
- PHPStan Pro – allow overriding
pro.tmpDir
config parameter (phpstan/phpstan-src@4a95206, phpstan/phpstan-src@7c4ef6b) - Optimize memory consumption when doing sha1 file hash (#2680), thanks @staabm!
- Optimize memory consumption in ResultCacheManager (#2681), thanks @staabm!
Bugfixes 🐛
- Filter right side of
??=
with=== null
(phpstan/phpstan-src@f407ac6) - Fix possible internal error when analysing code with enums on PHP 7.x (phpstan/phpstan-src@b9d9626), #9974
- NonexistentOffsetInArrayDimFetchRule – do not report errors on expressions after truthy
isset
check (phpstan/phpstan-src@6fbd6e4), #9991 - Use real native function name instead of lowercase one (#2673), #10003, thanks @fredden!
- Include property intializations from parent scope for anonymous functions (#2607), #9831, thanks @fabacino!
- FileFinder – make list of found files unique (phpstan/phpstan-src@7491260)
- Fix internal error with first-class callable in
array_filter
(phpstan/phpstan-src@0228643), #9994 - Fix subclass acceptability when class alias is involved on “ours” side (phpstan/phpstan-src@d5c599c), #10023
Function signature fixes 🤖
- Fix incorrect doc for
SQLite3::openBlob
(#2668), thanks @rodrigoq! - Update
number_format
return fromstring
tonon-empty-string
(#2678), thanks @devnix!
Download & Use
Copyright (c) 2016 Ondřej Mirtes