Skip to content

Autofix of SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses can delete arbitrary blocks of code #1837

@Firehed

Description

@Firehed

In files that have multiple non-contiguous use blocks, trying to autofix the errors with phpcbf can delete entire blocks of code!

Example:

https://github.com/openemr/openemr/blob/797bb262c95b8bb989996193bb466040c1c3a00a/sphere/process_response.php#L17-L40

When autofixing this file, lines 17-36 are deleted outright.

I'd expect one of two things to happen:

  • The two blocks of use statements are combined, then sorted
  • The two blocks are sorted within themselves, but left alone

In no case would I expect this rule to touch anything other than the use statements.

PHPCS: 4.0.1
Slevomat coding-standard: 8.28.0.

Update: the UseSpacing fixer does the same thing. I suspect the issue is with the UseStatementHeloer

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