Skip to content

PHPCBF fails to fix file with empty statement at start on control structure #2810

@kkmuffme

Description

@kkmuffme

phpcf gets stuck in an inifinite loop if the code contains "{;" (which can happen by accident)
It' will do loads of passes where it encounters 0/ violations remaining but then again there are 1, 2, many violations so it never ends.

Sample code:

if ( 2 === 2 ) {;
    echo "hello";
}

Sample output:

Registering sniffs in the abc standard... DONE (248 sniffs registered)
Creating file list... DONE (1 files in queue)
Changing into directory /some/path/
Processing test.php [PHP => 25 tokens in 5 lines]... DONE in 103ms (2 fixable violations)
        => Fixing file: 1/2 violations remaining [made 34 passes]... ^C

===

Suggested fix:

  1. solve that it doesn't end up stuck
  2. additionally if a line ends with {; the ; can be removed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions