PHPStan Effect System

An experimental PHPStan extension that tracks named behaviours, like calling external services, through the call graph and flags them where they aren't allowed.

DaveLiddament/phpstan-effect-system View on GitHub


The PHPStan Effect System lets you mark methods with effects, such as #[Effect('slow')] on a method that calls an external service, and declare where those effects aren't allowed, such as #[EffectFree('slow')] on a controller. Effects propagate back through the call graph, so PHPStan reports a controller that reaches a slow method several calls away, along with the call path. Rules can also be applied across whole groups of classes and methods in PHPStan's configuration.

Related articles