php-cs-fixer常用规则,备份下:

<?php

return PhpCsFixer\Config::create()
                        ->setRiskyAllowed(true)
                        ->setRules([
                            // 遵循PSR2
                            '@PSR2'                             => true,
                            // 设置数组格式为[]这种格式
                            'array_syntax'                      => ['syntax' => 'short'],
                            // return前面不需要有空行
                            'blank_line_before_return'          => true,
                            // !前面和后面都有一个空格
                            //'not_operator_with_space'  => false,
                            // !后面有一个空格
                            'not_operator_with_successor_space' => false,
                            // 类的use按长度由小到大排序
                            'ordered_imports'                   => [
                                'sort_algorithm' => 'length',
                            ],
                            // 删除无用的else
                            'no_useless_else'                   => true,
                            // 删除无用的return
                            'no_useless_return'                 => true,
                            // 自增样式[放在后面,如:$i++]
                            'increment_style'                   => ['style' => 'post'],
                            //// 开始花括号的位置
                            //'braces' => [
                            //    //'position_after_functions_and_oop_constructs' => 'same',
                            //],
                            // 等号对齐
                            'binary_operator_spaces'            => [
                                //'operators' => [
                                //    // 二元操作符: "=", "*", "/", "%", "<", ">", "|", "^", "+", "-", "&", "&=",
                                //    //   "&&", "||", ".=", "/=", "=>", "==", ">=", "===", "!=", "<>", "!==", "<=", "and", "or", "xor", "-=", "%=
                                //    //  ", "*=", "|=", "+=", "<<", "<<=", ">>", ">>=", "^=", "**", "**=", "<=>", "??"
                                //    '='  => 'align',
                                //    '=>' => 'align',
                                //],
//                                'align_double_arrow' => true,
//                                'align_equals'       => true,
                                '=>' => 'align',
                            ],
                            // 三元运算符的空格
                            'ternary_operator_spaces'           => true,
                            //'unary_operator_spaces'             => true,
                        ])
                        ->setFinder(
                            PhpCsFixer\Finder::create()
                                             ->in(__DIR__ . '/app')
                        );