Skip to content

Ordered imports no groups#21

Merged
mikadamczyk merged 6 commits intomainfrom
ordered-imports-no-groups
Mar 30, 2026
Merged

Ordered imports no groups#21
mikadamczyk merged 6 commits intomainfrom
ordered-imports-no-groups

Conversation

@mikadamczyk
Copy link
Copy Markdown
Contributor

🎫 Issue N/A

Description:

This PR makes the ordered imports behavior explicit in the Ibexa code style preset. Instead of relying on the upstream default configuration of ordered_imports, the preset now defines the intended import grouping order directly, so class, function, and const imports are grouped consistently, and each group is sorted alphabetically. This avoids behavior changes caused by future php-cs-fixer default changes.

For example, input like:

  use function Symfony\Component\DependencyInjection\Loader\Configurator\tagged_iterator;
  use Symfony\Component\DependencyInjection\Reference;
  use const Symfony\Component\DependencyInjection\Loader\Configurator\SOME_CONST;
  use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

is now expected to be formatted as:

  use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
  use Symfony\Component\DependencyInjection\Reference;

  use function Symfony\Component\DependencyInjection\Loader\Configurator\tagged_iterator;

  use const Symfony\Component\DependencyInjection\Loader\Configurator\SOME_CONST;

The PR also strengthens test coverage by adding a regression test for grouped imports and running the same expectations against both Ibexa46RuleSet and Ibexa50RuleSet.

For QA:

Documentation:

@mikadamczyk mikadamczyk self-assigned this Mar 30, 2026
@mikadamczyk mikadamczyk requested a review from a team March 30, 2026 09:13
$orderedImportsFixer = new OrderedImportsFixer();
$orderedImportsFixer->configure($orderedImportsRule);

/** @var list<FixerInterface> $fixers */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lists are PHPStan-specific

Suggested change
/** @var list<FixerInterface> $fixers */
/** @phpstan-var list<FixerInterface> $fixers */

@sonarqubecloud
Copy link
Copy Markdown

@mikadamczyk mikadamczyk merged commit 2eaf69a into main Mar 30, 2026
5 checks passed
@mikadamczyk mikadamczyk deleted the ordered-imports-no-groups branch March 30, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants