Skip to content

PEAR.ControlStructures.MultiLineCondition.Alignment not detected if closing brace is first token on line #1138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nkovacs opened this issue Sep 1, 2016 · 1 comment

Comments

@nkovacs
Copy link
Contributor

nkovacs commented Sep 1, 2016

PEAR.ControlStructures.MultiLineCondition.Alignment is detected here for the closing brace:

<?php

function bar() {
    if ($a
        && $b
 ) {
        echo 'bar';
    }
}

But not here (because the loop exits before the closing brace):

<?php

function bar() {
    if ($a
        && $b
) {
        echo 'bar';
    }
}

Unfortunately, the autofixer produces code like the second one when fixing the CloseBracket error here:

<?php

function bar() {
    if ($a
        && $b) {
        echo 'bar';
    }
}

(try this with phpcbf --standard=PEAR --exclude=PEAR.WhiteSpace.ScopeIndent)

The ScopeIndent Sniff fixes the second example if it is enabled, but I think this should be detected and fixed by the MultiLineCondition sniff as well (since it does so if there's at least one space).

@gsherwood gsherwood changed the title PEAR.ControlStructures.MultiLineCondition.Alignment is not detected if closing brace is the first token on the line. PEAR.ControlStructures.MultiLineCondition.Alignment not detected if closing brace is first token on line Sep 20, 2016
gsherwood added a commit that referenced this issue Sep 20, 2016
… not detected if closing brace is first token on line
@gsherwood
Copy link
Member

I've added a fix for this. Thanks for the bug report.

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

No branches or pull requests

2 participants