Skip to content

Read short-names map through ClassNameImportContext in FullyQualifiedName skip voter - #8691

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-import-context-shortnames
Oct 17, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-import-context-shortnames

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

What

FullyQualifiedNameClassNameImportSkipVoter depended on ShortNameResolver directly. It now reads the short-name-to-FQN map through the shared ClassNameImportContext, matching how AliasClassNameImportSkipVoter and UsesClassNameImportSkipVoter already consume file-global import facts (#8687).

Change

  • ClassNameImportContext gains resolveShortNamesToFullyQualifiedNames(File), delegating to ShortNameResolver::resolveFromFile().
  • The voter now injects the context instead of ShortNameResolver.

Pure consolidation step - no behavior change. ShortNameResolver::resolveFromFile() keeps its own caching, so performance is unchanged; the win is that voters now read from one place, setting up later collapse of the voter services behind the context.

Follow-up noted

ShortNameResolver::resolveFromFile() caches by file path only and never invalidates across stmts versions. Left as-is here to keep this step behavior-neutral; worth a dedicated version-keyed fix (moving that cache into the context) in a later step.

Tests

153 import tests green (rules-tests/CodingStyle/ClassNameImport, ImportFullyQualifiedNamesRector, tests/Issues/AutoImport*, NamespacedUseAutoImport, docblock import). ECS clean. PHPStan clean on changed files (the 2 unrelated shipmonk.deadMethod hits on main are from #8690's deprecated VO, not this PR).

@TomasVotruba
TomasVotruba force-pushed the tv-import-context-shortnames branch from f6fc1c9 to 8c0d2ca Compare October 17, 2026 19:46
@TomasVotruba
TomasVotruba marked this pull request as ready for review October 17, 2026 19:46
@TomasVotruba
TomasVotruba merged commit fb1cb18 into main Oct 17, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-import-context-shortnames branch October 17, 2026 19:47
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