mglaman/phpstan-drupal
PHPStan extension for Drupal that teaches static analysis about Drupal's APIs—hooks, services, plugins, entity types, and test base classes—so it catches real bugs and deprecations in modules, themes, and profiles while avoiding false positives.
mglaman/phpstan-drupal is the "buy" (well, MIT-license "adopt") answer to the question "do we write our own PHPStan rules for Drupal?" — it encodes Drupal-specific knowledge (hooks, plugins, services, entity types, annotations, Form/Entity APIs) that vanilla PHPStan cannot reason about, so building equivalent rules in-house is almost never justified.Consider adoption when:
Look elsewhere when:
For executives: This is a low-cost, MIT-licensed extension that makes our Drupal code checkable automatically before it ships. It reduces defect escape to production, de-risks and sizes our Drupal upgrade work, and shortens onboarding for new engineers — with no licensing spend and incremental rollout. The main cost is engineering time to adopt and triage, not procurement.
For engineering: It teaches PHPStan how Drupal actually works — hooks, plugins, services, entity annotations, Form API — so we stop getting false positives and start catching real mistakes: deprecated API calls, wrong service signatures, broken plugin definitions. It installs via Composer, plugs into existing PHPStan config, and supports a baseline so we can adopt gradually and ratchet levels over time. It does not replace tests or runtime monitoring; it complements them by shifting cheap checks left into CI.
How can I help you explore Laravel packages today?