Php-cs-fixer: ArrayIndentationFixer - unexpected changes with multiline ternary operator

Created on 18 Jun 2018  Â·  3Comments  Â·  Source: FriendsOfPHP/PHP-CS-Fixer

When reporting an issue (bug) please provide the following information:

The PHP version you are using ($ php -v):

=> 7.2.6

PHP CS Fixer version you are using ($ php-cs-fixer -V):

=> 2.12.1

The command you use to run PHP CS Fixer:

=> vendor/bin/php-cs-fixer fix

The configuration file you are using, if any:

<?php

declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()
    ->in(__DIR__)
    ->exclude('vendor');

return PhpCsFixer\Config::create()
    ->setFinder($finder)
    ->setRules([
        'array_indentation' => true,
    ]);

If applicable, please provide minimum samples of PHP code (as plain text, not screenshots):

  • before running PHP CS Fixer (no changes):
<?php

[
    $test
        ? [
            123,
        ]
        : [
            321,
        ],
];
  • with unexpected changes applied when running PHP CS Fixer:
<?php

[
    $test
        ? [
        123,
    ]
    : [
        321,
    ],
];
  • with the changes you expected instead:

Expected no changes.

kinbug

All 3 comments

Thanks for the report @EvgenyOrekhov , looks buggy indeed :(

Can you propose a fix? That would be great !

I confirm the bug and started to work on a fix. I hope to submit it soon.

It was harder than expected but this should be fixed by #4654.

Was this page helpful?
0 / 5 - 0 ratings