Skip to content

Skip PHPStan conditional return type in RemoveSuperfluousReturnNameFixer - #210

Merged
TomasVotruba merged 2 commits into
mainfrom
fix-superfluous-return-conditional-type
Oct 14, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
fix-superfluous-return-conditional-type

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Problem

RemoveSuperfluousReturnNameFixer wrongly strips the condition variable of a PHPStan conditional @return type, corrupting the docblock:

-     * @return $arrayHydration ? array<int, array<string, mixed>> : array<int, LeadList>
+     * @return ? array<int, array<string, mixed>> : array<int, LeadList>

The $arrayHydration is the condition of a conditional return type, not a superfluous variable name.

Fix

Skip @return lines where the variable is immediately followed by ? or is (the conditional type forms $var ? A : B and $var is X ? A : B). Applied to both the PHP fixer and the Go (blink) port, with tests in each.

@TomasVotruba
TomasVotruba enabled auto-merge (squash) October 14, 2026 15:22
@TomasVotruba
TomasVotruba merged commit 038aa03 into main Oct 14, 2026
20 checks passed
@TomasVotruba
TomasVotruba deleted the fix-superfluous-return-conditional-type branch October 14, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant