Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
关联数组对齐=>;使用PHP-CS-Fixer_Php_Phpcs - Fatal编程技术网

关联数组对齐=>;使用PHP-CS-Fixer

关联数组对齐=>;使用PHP-CS-Fixer,php,phpcs,Php,Phpcs,关联数组=>应该与PHP CS Fixer对齐吗 $array = [ 1 => 'a', '1' => 'b', 1.5 => 'c', true => 'd', ]; 或 我在中找不到该过滤器,它是align\u double\u arrow这现在是一种正确的方法,可以使用较新版本的PHP CS Fixer(v2,v3)运行align\u double\u arrow,它将对齐双箭头('=>')后的数组元素: 更多内容请阅读

关联数组=>应该与PHP CS Fixer对齐吗

$array = [
    1    => 'a',
    '1'  => 'b',
    1.5  => 'c',
    true => 'd',
];


我在

中找不到该过滤器,它是
align\u double\u arrow
这现在是一种正确的方法,可以使用较新版本的PHP CS Fixer(v2,v3)运行
align\u double\u arrow
,它将对齐双箭头('=>')后的数组元素:

更多内容请阅读:

这是一个无效数组,只能使用整型值或字符串值作为数组键;包含整数值的字符串键将被静默转换为整数,因此所有这些都将被转换为整数1,值
d
将覆盖键
1
的值
a
,而实际问题的答案可能取决于您使用的编码标准事实上,我们并不关心内容,这只是一个例子
$array = [
    1 => 'a',
    '1' => 'b',
    1.5 => 'c',
    true => 'd',
];
php-cs-fixer fix path \
--rules='{"binary_operator_spaces": {"operators": {"=>": "align_single_space_minimal"}}}'