Skip to content

[DeadCode] Skip leading param removal when a docblock-only typed caller exists on RemoveUnusedPrivateMethodParameterRector - #9165

Merged
TomasVotruba merged 2 commits into
mainfrom
fix-private-param-remover-leading-param
Dec 4, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
fix-private-param-remover-leading-param

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Since #9160, a call on a receiver typed only by docblock keeps its arguments. That is fine for trailing params, but removing a leading one shifts them:

/** @param SomeClass $doc */
public function go($doc)
{
    $this->mid(1, 2);
    $doc->mid(1, 2);
}

private function mid($unused, $value)

became mid($value) with $this->mid(2), while $doc->mid(1, 2) stayed - so $value silently receives 1 at runtime.

Now when such a docblock-only typed caller exists, the method is skipped unless the removed params are trailing. Trailing removal (keep_docblock_only_caller_args.php.inc) still works as before.

@TomasVotruba
TomasVotruba force-pushed the fix-private-param-remover-leading-param branch from 2077587 to b6668d6 Compare December 4, 2026 09:57
@TomasVotruba
TomasVotruba merged commit a2ee82a into main Dec 4, 2026
52 checks passed
@TomasVotruba
TomasVotruba deleted the fix-private-param-remover-leading-param branch December 4, 2026 09:59
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.

1 participant