Skip to content

BlankLineBetweenImportGroupsFixer is effectively ignored from PER_CS set #336

Closed
ecsphp/ecs-src
#206

Description

@chrisminett

Sample config containing the demo of the issue:

<?php

declare(strict_types=1);

use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

use function strlen as strlen_alias;

strlen_alias('ecs');

return ECSConfig::configure()
    ->withPaths([
        __FILE__,
    ])

    ->withSets([
        SetList::COMMON,
        SetList::PER_CS,
    ]);

The blank line (line 7) between the class-based import statements and the function-based import statements should be retained (or added if not present) by BlankLineBetweenImportGroupsFixer, but instead it is removed by NoBlankLineBetweenImportsFixer. This is for rule 3 of PER Coding Style (currently v3.1).

I think this is because NoBlankLineBetweenImportsFixer runs with a priority of -50, after BlankLineBetweenImportGroupsFixer which has a priority of -40. Manually changing -40 to -51 stops the blank line being removed, or replaces it if it is not present.

The comment in NoBlankLineBetweenImportsFixer specifically says the priority is to make them run in the current order, so I'm unsure what other issue this may be trying to resolve, but at the moment the result does not match PER CS.


Output when running ecs check --fix:

1) ecs.php

    ---------- begin diff ----------
@@ Line 4 @@

 use Symplify\EasyCodingStandard\Config\ECSConfig;
 use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
-
 use function strlen as strlen_alias;

 strlen_alias('ecs');
    ----------- end diff -----------


Applied checkers:

* PhpCsFixer\Fixer\Whitespace\BlankLineBetweenImportGroupsFixer
* PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer
* Symplify\CodingStandard\Fixer\Spacing\NoBlankLineBetweenImportsFixer


 [OK] 1 error successfully fixed and no other errors found!


 // 1 files · 700ms · 12 MB

Activity

  1. TomasVotruba commented on Oct 13, 2026

    @TomasVotruba
    Member

    Thanks, fixed in ecsphp/ecs-src#206

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions