将PHP-cs-fixer缩进配置为2个空格而不是4个?

dlu*_*cru 6 php atom-editor phpcs

不知道这对这里还是SuperUser是一个更好的问题。如果它属于那里,请随意移动。

我正在使用php-cs-fixer,并且对缩进有一个独特的要求-我需要两个空格而不是四个空格。有没有办法更改此设置?

请注意,我正在使用atom-beautifier运行php-cs-fixer,因此从那里开始,任何解决方案都应该是理想的。

Zac*_*ith 6

您可以按照PHP-CS-Fixer 文档网站中的定义进行设置PHP-CS-Fixer config file path并设置setIndent()值。

参见图片了解Atom软件包设置

设置.php_cs像这样的东西。需要注意->setIndent(" ")有两个空格代替一个\t字符。

<?php

/*
 * This file is part of PHP CS Fixer.
 * (c) Fabien Potencier <fabien@symfony.com>
 *     Dariusz Rumi?ski <dariusz.ruminski@gmail.com>
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

$header = <<<'EOF'
This file is part of PHP CS Fixer.
(c) Fabien Potencier <fabien@symfony.com>
    Dariusz Rumi?ski <dariusz.ruminski@gmail.com>
This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;

return PhpCsFixer\Config::create()
  /* ... other settings */
  ->setIndent("  ")
  /* ... other settings */
Run Code Online (Sandbox Code Playgroud)

我在php-cs-fixer这里使用插件版本4.1.0。