PHPStan Effect System

An experimental PHPStan extension that lets you name behaviours, such as calling external services, track them through the call graph, and report when they reach code 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