7

不确定这对于这里还是超级用户来说是一个更好的问题。如果它属于那里,请随意移动它。

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

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

4

1 回答 1

8

您可以按照 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 */

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

于 2017-07-23T00:38:40.590 回答