簡體   English   中英

關聯數組對齊 => 與 PHP-CS-Fixer

[英]Associative array align => with PHP-CS-Fixer

關聯數組 => 應該與 PHP-CS-Fixer 對齊嗎?

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

或者

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

我沒有在https://github.com/FriendsOfPHP/PHP-CS-Fixer 中找到過濾器

這是現在使用較新版本的 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

過濾器是align_double_arrow

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM