Skip to content

DRAFT [DeadCode] Skip RemoveReturnTagIncompatibleWithNativeTypeRector on a type alias nested in a union - #8319

Draft
Philosoft wants to merge 1 commit into
rectorphp:mainfrom
Philosoft:fix/respect-union-of-aliases
Draft

DRAFT [DeadCode] Skip RemoveReturnTagIncompatibleWithNativeTypeRector on a type alias nested in a union#8319
Philosoft wants to merge 1 commit into
rectorphp:mainfrom
Philosoft:fix/respect-union-of-aliases

Conversation

@Philosoft

@Philosoft Philosoft commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

A @phpstan-type alias name is not resolved to the type it stands for, it becomes a NonExistingObjectType. So "@return ConfigArray|CustomConfig" over a native "array" looked like a contradiction and the tag was removed.

The alias guard only matched when the whole @return type was a single IdentifierTypeNode. Look the name up in every identifier of the type node instead, which covers unions, nullables and intersections as well.

draft fix for rectorphp/rector#9846

…type alias nested in a union

A @phpstan-type alias name is not resolved to the type it stands for, it
becomes a NonExistingObjectType. So "@return ConfigArray|CustomConfig" over a
native "array" looked like a contradiction and the tag was removed.

The alias guard only matched when the whole @return type was a single
IdentifierTypeNode. Look the name up in every identifier of the type node
instead, which covers unions, nullables and intersections as well.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Philosoft
Philosoft marked this pull request as draft August 7, 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.

1 participant