Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure PHP-cs-fixer indentation for 2 spaces rather than 4?

Not sure if this a better question for here or SuperUser. If it belongs there feel free to move it.

I'm using php-cs-fixer, and I have a unique requirement on indentations - I need two spaces rather than four. Is there a way to change this setting?

Note that I'm using atom-beautifier to run php-cs-fixer, so any solution should ideally be workable from there.

like image 909
dluxcru Avatar asked May 12 '16 17:05

dluxcru


1 Answers

You can set the PHP-CS-Fixer config file path and set the setIndent() value as defined at PHP-CS-Fixer's documentation website.

See image for Atom package settings

Set the .php_cs with something like this. Note the ->setIndent(" ") with two spaces instead of a \t character.

<?php

/*
 * This file is part of PHP CS Fixer.
 * (c) Fabien Potencier <[email protected]>
 *     Dariusz Rumiński <[email protected]>
 * 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 <[email protected]>
    Dariusz Rumiński <[email protected]>
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 */

I am using php-cs-fixer plugin version 4.1.0 here.

like image 186
Dr.Ransom Avatar answered Oct 10 '22 08:10

Dr.Ransom