Posts tagged #static-analysis

The case for contravariant template types

PHPStan has only supported invariant and covariant template types because they are so prevalent in real-world applications. But contravariant template types also have their use cases, and the latest release of PHPStan adds support for them, among other small improvements to generics.

The true power of sealed classes

In my recent post, I've introduced a PHPStan extension that brings support for sealed classes and interfaces to statically analyzed PHP. Looking back, I feel I haven't stressed the main benefit enough, so here I am doing it justice.

Seal your classes with PHPStan

Sealed classes are a useful feature of Kotlin: they allow you to specify which classes are allowed to extend a sealed class (or implement a sealed interface). With the recently released PHPStan 1.9.0, you can now introduce sealed classes to your PHP codebase too!