composer global require friendsofphp/php-cs-fixer
- Add the provided .php_cs.php file to your home folder
- Adjust to match your preferences
- Add the following alias to your bash_rc
alias php-cs-fixer='php-cs-fixer fix -v --config ~/.php_cs.php'
<?php | |
// Only fix files in the current directory | |
$finder = PhpCsFixer\Finder::create() | |
->in(getcwd()) | |
->name('*.php') | |
->ignoreDotFiles(true) | |
->ignoreVCS(true) | |
->depth('== 0') | |
; | |
return PhpCsFixer\Config::create() | |
->setUsingCache(false) | |
->setRules([ | |
'@Symfony' => true, | |
'single_import_per_statement' => false, | |
'concat_space' => ['spacing' => 'one'], | |
'array_syntax' => ['syntax' => 'short'], | |
'yoda_style' => false, | |
'binary_operator_spaces' => [ | |
'operators' => [ | |
'=' => 'align_single_space', | |
'=>' => 'align_single_space', | |
], | |
], | |
]) | |
->setFinder($finder) | |
; |
composer global require friendsofphp/php-cs-fixer
alias php-cs-fixer='php-cs-fixer fix -v --config ~/.php_cs.php'