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 @var PHPDoc annotations flagged with varTag.differentVariable so the documented variable name matches the assigned variable (or remove obsolete/redundant @var tags where appropriate).
  • Regenerate core/.phpstan-baseline.php to remove the resolved varTag.differentVariable entries.

Remaining tasks

  • Fix all varTag.differentVariable occurrences 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

Command icon 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

mallezie created an issue. See original summary.

longwave’s picture

Title: Fix PHPStan L3 error: class.nameCase » Fix PHPStan L3 error: varTag.differentVariable
mallezie’s picture

Assigned: Unassigned » mallezie

mallezie’s picture

Assigned: mallezie » Unassigned
Status: Active » Needs review