Skip to content

[CodingStyle] Keep partially qualified names as written on import names - #8932

Merged
TomasVotruba merged 1 commit into
mainfrom
keep-aliased-namespace-names
Nov 14, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
keep-aliased-namespace-names

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

With withImportNames(), a name written partially qualified in the source is now kept as written, without a new option:

use App\Search\Field;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Column]            // kept
new Field\TextField();   // kept, before: "use App\Search\Field\TextField; new TextField()"
  • Names that start with an aliased use (as ORM, as Assert) were already kept. This PR adds regression fixtures for them: attributes, new, ::class, types, docblocks, Doctrine annotations.
  • Names that start with a plain namespace use (use App\Search\Field; Field\TextField) and relative names (namespace\Sub\Foo) are now kept too. The check uses the parser's originalName attribute.
  • Fully qualified names (\App\Foo) and names that rules create are still imported.

This is a behaviour change. 10 existing fixtures asserted that partially qualified names get imported. They are now skip_* fixtures.

Alternative to #8884, with no new withImportNames() argument.

Names written as Field\TextField, ORM\Column or namespace\Sub\Foo are no longer imported. Fully qualified names and names created by rules are still imported.
@TomasVotruba
TomasVotruba merged commit 8dd83d8 into main Nov 14, 2026
51 checks passed
@TomasVotruba
TomasVotruba deleted the keep-aliased-namespace-names branch November 14, 2026 20:33
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