For the past few years PHPStan always had support for the latest PHP version on day one, and I considered a matter of pride to achieve that.
Today is a big milestone for PHPStan after 6 years of development. I realized it reached a level of maturity worthy the major version that’s 1.0.
Static analysis is a very complicated problem. People sometimes get and try out things that might seem like good ideas but in some contexts are rather counterproductive.
Traits are a mechanism to reuse code. They’re copy-paste implemented at the language level.
Exceptions can serve you well, but they can also wreak havoc in your codebase.
PHPStan never used to be very precise about type inference in try-catch-finally blocks.
The developer relies on $person->getName() returning the same value when called a second time.
When developing new features that don’t fit in a minor version, or aren’t expected to be released right away, software developers have two options what to do:
This problem is reported by PHPStan on level 6 when typehinting an array or an iterable object as a parameter type or a return type. It’s there to prevent values of unknown types to be used as a foreach value:
This problem is reported by PHPStan on level 6 when calling a generic method or function. Generic methods and functions declare so-called template types (also known as type variables) via @template PHPDoc tags.
This error is reported for new static() calls that might break once the class is extended, and the constructor is overridden with different parameters.