Skip to content

[Naming] Deprecate RenameForeachValueVariableToMatchMethodCallReturnTypeRector - #8550

Merged
TomasVotruba merged 2 commits into
mainfrom
deprecate-rename-foreach-value-to-method-call-return-type
Oct 8, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
deprecate-rename-foreach-value-to-method-call-return-type

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Deprecates RenameForeachValueVariableToMatchMethodCallReturnTypeRector.

Renaming a foreach value variable to match the method-call return type is risky - it can clobber meaningful local variable names and introduce naming conflicts. The original variable name often carries more context than the callee return type, so the rename tends to reduce readability rather than improve it.

The rule now implements DeprecatedInterface and throws from refactor(), following the existing deprecation pattern (see SwitchNegatedTernaryRector). It is unregistered from the naming set and its tests are removed.

Cascade cleanup of services left orphaned by the removal:

  • Rector\Naming\Matcher\ForeachMatcher - deleted (sole user)
  • Rector\Naming\ValueObject\VariableAndCallForeach - deleted (sole user)
  • Rector\Naming\RectorNamingInflector - deleted (only fed the removed singularized name)
  • ExpectedNameResolver::resolveForForeach() and its private helpers - removed
  • ExpectedName::getSingularized() / isSingular() and the singularized property - removed, as only the foreach path consumed them
  • CallMatcher::matchCall() param narrowed to Assign (the only remaining caller)

@TomasVotruba
TomasVotruba merged commit ec543a5 into main Oct 8, 2026
50 checks passed
@TomasVotruba
TomasVotruba deleted the deprecate-rename-foreach-value-to-method-call-return-type branch October 8, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants