Php_codesniffer: [Feature] PSR12 BooleanOperatorPlacementSniff - Add option to restrict beginning (or end of line) only

Created on 29 Sep 2019  路  5Comments  路  Source: squizlabs/PHP_CodeSniffer

In PSR12, the BooleanOperatorPlacementSniff allow both

if (
    $a &&
    $b
)

and

if (
    $a
    && $b
)

It could be great having an option like $allowFirstOnly to restrict only this

if (
    $a
    && $b
)

And the same way $allowLastOnly to restrict only this

if (
    $a &&
    $b
)
Enhancement

Most helpful comment

Could this also be a single option allowOnly with string values first and last? Defaults to nothing/null as to allow both.
I think having two boolean ones sound a bit weird.

All 5 comments

@gsherwood If you're interested, I can make the PR

Could this also be a single option allowOnly with string values first and last? Defaults to nothing/null as to allow both.
I think having two boolean ones sound a bit weird.

@VincentLanglet Yes, I'm very interested. A single sniff property would be best.

I started something #2680

Thanks. I'm not sure if you can do this after creating the PR, but using the draft PR feature might be good for this one.

Was this page helpful?
0 / 5 - 0 ratings