3

我已经开始使用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 实现吗?

4

0 回答 0