I have created a file called .gm_cs
in the root of my project and php-cs-fixer
is installed globally.
In the config file is the following
<?php
$rules = array(
'@PSR2' => true,
'combine_consecutive_unsets' => true,
'no_extra_consecutive_blank_lines' => array('break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'),
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'array_syntax' => array('syntax' => 'short'),
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'psr4' => true,
'strict_comparison' => true,
'strict_param' => true,
);
$fixers = array(
'-pre_increment'
);
return PhpCsFixer\Config::create()->setRiskyAllowed(false)->setRules($rules)->fixers($fixers)->in(__DIR__);
I am calling the command from git-bash on windows with the following:
php-cs-fixer fix -vvv ./private --config-file=gm_cs
I have also tried these:
php-cs-fixer fix -vvv ./private --config-file=.gm_cs
php-cs-fixer fix -vvv ./private --config-file=./.gm_cs
php-cs-fixer fix -vvv ./private --config gm_cs
php-cs-fixer fix -vvv ./private --config .gm_cs
php-cs-fixer fix -vvv ./private --config ./.gm_cs
php-cs-fixer fix -vvv ./private --config=gm_cs
php-cs-fixer fix -vvv ./private --config=.gm_cs
php-cs-fixer fix -vvv ./private --config=./.gm_cs
In desperation I copied the .php_cs
from my composer/vendor folder:
<?php
Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);
return Symfony\CS\Config::create()
// use default SYMFONY_LEVEL and extra fixers:
->fixers(array(
'-pre_increment',
))
->finder(
Symfony\CS\Finder::create()
->exclude('Symfony/CS/Tests/Fixtures')
->in(__DIR__)
)
;
And reduced the fixers to just stop the pre-increment one, and then ran it with all the commands listed previously, and it still hasn't solved the issue.
More than anything else, I just want it to stop swapping the $i++
to ++$i
because this is a massive project I have inherited and I don't have time to test all those changes yet (no unit tests exist yet).
Any advice or help anyone could provide would be greatly appreciated.
Turns out the version of php-cs-fixer
I am using is the Symfony\CS\Fixer\
one, and it doesn't take $rules
.
Additionally, the file needs to be named .php_cs