Skip to content

Keep generic static union docblock in RemoveDuplicatedReturnSelfDocblockRector#8150

Merged
TomasVotruba merged 2 commits into
rectorphp:mainfrom
maartenpaauw:fix/keep-union-types
Jul 6, 2026
Merged

Keep generic static union docblock in RemoveDuplicatedReturnSelfDocblockRector#8150
TomasVotruba merged 2 commits into
rectorphp:mainfrom
maartenpaauw:fix/keep-union-types

Conversation

@maartenpaauw

Copy link
Copy Markdown
Contributor

RemoveDuplicatedReturnSelfDocblockRector incorrectly strips @return static<string|int> docblocks when the native return type is self. The rule already preserved GenericObjectType annotations (e.g. self<TValue, never>) but did not account for GenericStaticType.

This adds a GenericStaticType check so that generic @return static<...> narrowing annotations are kept, and adds a fixture to cover the case.

@TomasVotruba

Copy link
Copy Markdown
Member

LGTM 👍 Thanks

@TomasVotruba TomasVotruba merged commit ffa770e into rectorphp:main Jul 6, 2026
65 checks passed
@maartenpaauw maartenpaauw deleted the fix/keep-union-types branch July 6, 2026 16:45
@maartenpaauw

Copy link
Copy Markdown
Contributor Author

@TomasVotruba thank you for the quick merge. Is it already possible to ship a new version for rector/rector?

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.

3 participants