Skip to content

PHPCBF creates invalid PHP for inline FOREACH containing multiple control structures #778

@bpicolo

Description

@bpicolo

The first isn't what I'd call good formatting, but it IS valid php. phpcbf autocorrects it to the latter, which is not.
Feels like something should be in place to have it not actually create invalid php?

Before:

<?php $stuff = [1,2,3]; foreach($stuff as $num) if ($num %2 ) { echo "even"; } else { echo "odd"; } 

After:

<?php $stuff = [1,2,3]; foreach($stuff as $num) { if ($num %2 ) { echo "even"; } } else { echo "odd"; } 

Expected:

<?php $stuff = [1,2,3]; foreach($stuff as $num) { if ($num %2 ) { echo "even"; } else { echo "odd"; } } 

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