After updating phpstan on a Drupal project, and removing the configuration option autoload_files I suddenly started getting this polite little error message on my static analysis continuous integration runs:
Reflection error: DrupalTestsPhpunitCompatibilityTrait not found. 💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
To fix this, I simply added the trait to the new configuration property scanFiles:
scanFiles: - %currentWorkingDirectory%/drupal/core/tests/Drupal/Tests/PhpunitCompatibilityTrait.php
If your project has Drupal in another folder than “drupal”, simply substitute that with “web”, “docroot” or whatever your project dictates.
That will serve for me as a reminder to next time. And hopefully to you. Speaking of hope, here is an animated gif called “hope”.