phpstan-drupal
phpstan-drupal copied to clipboard
ModuleHandler->loadInclude() call is not being processed
Bug report
Drush is getting started with phpstan. I'm using latest versions and configured with a drupal_root but the code below is still warning: Function locale_translation_flush_projects not found..
Code snippet that reproduces the problem
https://github.com/drush-ops/drush/blob/accaf08af5b2bd399f0a4fd8f8b7520074344248/src/Commands/core/LocaleCommands.php#L70-L76
One special thing about Drush is that it lives in the vendor dir, not within the drupal docroot. I wouldnt expect that to matter since I've provided drupal_root parameter but I thought I would mention it.
Anyone wanting to work on this could clone drush, comment out these 2 lines, and run vendor/bin/phpstan. You will see warnings when you should not.
I'm not sure why this wouldn't work in Drush. \mglaman\PHPStanDrupal\Rules\Drupal\LoadIncludes checks for the loadInclude method being invoked on anything implementing ModuleHandlerInterface.
I saw the output for this, and there are no errors from the rule (like file not found) which can only happen when:
- The above checks fail, so the rule is skipped
- The module and filename cannot be determined
- The file is included
Hey @weitzman,
The fix is to add the following to your distribution neon. I have a pull request for drush incoming.
rules:
- mglaman\PHPStanDrupal\Rules\Drupal\LoadIncludes