Should associative array => should be align with PHP-CS-Fixer ?
$array = [
1 => 'a',
'1' => 'b',
1.5 => 'c',
true => 'd',
];
or
$array = [
1 => 'a',
'1' => 'b',
1.5 => 'c',
true => 'd',
];
I didn't find filter for that in https://github.com/FriendsOfPHP/PHP-CS-Fixer
答案 0 :(得分:4)
现在这是使用较新版本的 PHP-CS-Fixer (v2, v3) 运行 align_double_arrow
的正确方法,它将对齐双箭头 ('=>') 之后的数组元素:>
php-cs-fixer fix path \
--rules='{"binary_operator_spaces": {"operators": {"=>": "align_single_space_minimal"}}}'
更多阅读: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/3.0/doc/rules/operator/binary_operator_spaces.rst
答案 1 :(得分:3)
Filter for that is align_double_arrow