PHP-CS-Fixer-如何不在内联语句上添加花括号?

时间:2019-12-05 16:56:27

标签: php php-cs-fixer

例如,我已经开始使用PHP-CS-Fixer了,我想知道是否有任何配置不能在行内语句中自动添加大括号

//I want to keep this way
if (empty($var))
    throw new Exception('An error message..')

但是当我格式化时会变成这样:

if (empty($var)) {
    throw new Exception('An error message..')
}

我的php_cs.dist配置:

...
->setRules([
          'no_unneeded_curly_braces' => true,
          'braces' => [
            'allow_single_line_closure' => true,
            'position_after_functions_and_oop_constructs' => 'same'
          ]
    ])
...

使用PHP-CS-Fixer是否可以实现?

0 个答案:

没有答案