Skip to content

Match a Collection docblock name with a leading backslash - #548

Merged
TomasVotruba merged 1 commit into
rectorphp:mainfrom
SanderMuller:collection-name-leading-backslash
Nov 2, 2026
Merged

TomasVotruba merged 1 commit into
rectorphp:mainfrom
SanderMuller:collection-name-leading-backslash

Conversation

@SanderMuller

Copy link
Copy Markdown
Contributor

NarrowArrayCollectionToCollectionRector and UnionCollectionTagValueNodeNarrower write \Doctrine\Common\Collections\Collection into a docblock, with a leading backslash. UnionCollectionTagValueNodeNarrower::isCollectionIdentifierTypeNode() and CollectionTagValueNodeAnalyzer::detect() only match the name without it, so the narrowing stops halfway: @param mixed[]|\Doctrine\Common\Collections\Collection $collection and no native type.

With importNames() this was hidden: the name importer shortens the name to Collection before the next pass. Without it, the two TypedCollections set fixtures fail on main. They also fail with rectorphp/rector-src#8909, which runs the post rectors only after the rules finish.

The new test runs the two fixtures without importNames().

@TomasVotruba
TomasVotruba merged commit 3619b47 into rectorphp:main Nov 2, 2026
8 checks passed
@TomasVotruba

Copy link
Copy Markdown
Member

LGTM, thank you

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