Skip to content

PHPCBF adds brace for ELSE IF split over multiple lines #558

@meijerm15

Description

@meijerm15

PHPCBF is currently fixing bracketless if-else statements incorrectly and causing a fatal error.
Which means that the code won't run, because of the 2 else statements in a row, as seen in my example.

Before:

 public function test($test) { if ($test) { } else if ($test) { } else { } }

After:

 public function test($test) { if ($test) { } else { if ($test) { } } else { } }

Log:
Processing test.php [PHP => 53 tokens in 12 lines]... DONE in 3ms (9 fixable violations)
=> Fixing file: 0/9 violations remaining [made 6 passes]... DONE in 61ms
Patched 1 file
Time: 146ms; Memory: 5.25Mb

Version:
PHP_CodeSniffer version 2.3.0 (stable) by Squiz (http://www.squiz.net)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions