Issue
I am using php-cs-fixer
with Netbeans 8.2
. It is working perfectly except for one case. My arrays are formatted like below
$array = [
'asdf' => 'a',
'a' => 'b',
'asd' => 'c'
];
But after fixing with php-cs-fixer
, they all changed to
$array = [
'asdf' => 'a',
'a' => 'b',
'asd' => 'c'
];
Is there any way to ignore this section only?
Solution
Is there any way to ignore this section only?
No, there is no way. See the response to PHP-CS-Fixer issue #3846: How to ignore specific lines?
This is a design decision that you shall not allow for exceptions per block of code. It may or may not be introduced in the future, depends on amount of ppl requesting it and one who would take a challenge to implement it.
Currently, if you are really in need, you can disable file from being fixed at all. But that would mean it would not be fixed by any other rules as well.
So I guess you can update that existing issue to add your voice, and hope that they listen.
Alternatively, you could raise a new issue requesting that there is a new rule in PHP-CS-Fixer which preserves whitespace when formatting arrays. Your formatting certainly looks better than that of PHP-CS-Fixer to me.
Answered By - skomisa