PHPStan is a static analysis tool for PHP that catches bugs, type errors, and other issues without running your code. It works well with Drupal through the mglaman/phpstan-drupal extension, which adds Drupal specific rules.
Configure PHPStan at a chosen level, from zero for basic checks to nine for the strictest analysis. Start at a low level on existing projects and gradually increase as you fix issues.
PHPStan catches problems like calling non existent methods, using undefined variables, and type mismatches. It runs in seconds and fits naturally into continuous integration pipelines. Many Drupal agencies now consider PHPStan essential alongside coding standards checks and automated tests. Setting it up early on a new project is much easier than retrofitting it later. It pays for itself quickly by catching bugs before they reach production.