Issue summary generated with the help of an LLM.
Problem/Motivation
PHPStan currently flags several varTag.differentVariable errors across Drupal core where an inline @var PHPDoc tag specifies a variable name that does not match the actual variable being assigned (for example: "Variable $foo in PHPDoc tag @var does not match assigned variable $bar."). These errors are currently ignored in core/.phpstan-baseline.php.
When the variable name in a @var annotation does not match the assigned variable—typically due to variable renames or copy-paste mistakes—static analysis tools and IDEs ignore the type hint completely, reducing type safety and code clarity.
Proposed resolution
- Update all
@varPHPDoc annotations flagged withvarTag.differentVariableso the documented variable name matches the assigned variable (or remove obsolete/redundant@vartags where appropriate). - Regenerate
core/.phpstan-baseline.phpto remove the resolvedvarTag.differentVariableentries.
Remaining tasks
- Fix all
varTag.differentVariableoccurrences in core. - Regenerate
core/.phpstan-baseline.php. - Verify PHPStan passes in GitLab CI.
User interface changes
None.
API changes
None.
Data model changes
None.
Issue fork drupal-3640904
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
longwaveComment #3
mallezieComment #5
mallezie