You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ModuleHandler->loadInclude() call is not being processed #741
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..
changed the title [-]ModuleHandler->loadInclude() call must not be picked up[/-][+]ModuleHandler->loadInclude() call is not being processed[/+]on Mar 25, 2024
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.
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 cause: the include files that loadInclude() loads are loaded by the LoadIncludes rule, which is in rules.neon. Drush's config included only extension.neon, so the rule never ran and locale_translation_flush_projects() was unknown. Registering LoadIncludes by hand, as Drush did, fixes it. So does including rules.neon.
#1096 updates the README's manual installation section to include both files and to explain what breaks without rules.neon.
@weitzman one more note on Drush's phpstan.neon.dist: src/Commands/core/LanguageAddCommand.php is excluded with "Unclear why the phpstan-drupal rule is not working for this command". That isn't this issue. Its loadInclude() calls work. The function that fails is drush_locale_translation_default_update_options(), which Drush defines in its own includes/legacy.inc, so PHPStan needs it in scanFiles:
Activity
[-]ModuleHandler->loadInclude() call must not be picked up[/-][+]ModuleHandler->loadInclude() call is not being processed[/+]weitzman commentedon Mar 25, 2024
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.
weitzman commentedon Mar 25, 2024
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.mglaman commentedon Sep 27, 2024
I'm not sure why this wouldn't work in Drush.
\mglaman\PHPStanDrupal\Rules\Drupal\LoadIncludeschecks for theloadIncludemethod being invoked on anything implementingModuleHandlerInterface.I saw the output for this, and there are no errors from the rule (like file not found) which can only happen when:
andyg5000 commentedon Sep 27, 2024
Hey @weitzman,
The fix is to add the following to your distribution neon. I have a pull request for drush incoming.
mglaman commentedon Nov 10, 2026
The cause: the include files that
loadInclude()loads are loaded by theLoadIncludesrule, which is inrules.neon. Drush's config included onlyextension.neon, so the rule never ran andlocale_translation_flush_projects()was unknown. RegisteringLoadIncludesby hand, as Drush did, fixes it. So does includingrules.neon.#1096 updates the README's manual installation section to include both files and to explain what breaks without
rules.neon.@weitzman one more note on Drush's
phpstan.neon.dist:src/Commands/core/LanguageAddCommand.phpis excluded with "Unclear why the phpstan-drupal rule is not working for this command". That isn't this issue. ItsloadInclude()calls work. The function that fails isdrush_locale_translation_default_update_options(), which Drush defines in its ownincludes/legacy.inc, so PHPStan needs it inscanFiles:Document that manual installs need rules.neon for loadInclude() files (…