For projects in a transition phase that are being developed against different PHP versions it would be great to not rebuild the whole cache on PHP version change to keep one cache per PHP version.
$ php -v):=> 5.6, 7.0, 7.1 and 7.2
$ php-cs-fixer -V):=> PHP CS Fixer 2.10.2 Bowling Bear by Fabien Potencier and Dariusz Ruminski (74e4682)
=> composer cs-fix (@php -fvendor/bin/php-cs-fixer -- fix)
<?php
$config = PhpCsFixer\Config::create()
->setCacheFile('build/php-cs/.php_cs.cache')
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'phpdoc_add_missing_param_annotation' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(['application', 'dev', 'library/Vendor'])
->in('tests')
->notPath('schema/metadata.php')
)
;
return $config;
How about:
->setCacheFile('build/php-cs/.php_cs_' . PHP_VERSION . '.cache')
also, it is not advised to run PHP CS Fixer for same project using different PHP engine, as run under different engines will provide different outcomes
Closing as there is nothing to do on PHP CS Fixer side.
Feel free to continue the discussion, nevertheless
The only issue I had w/ multiple PHP versions was the one with rebuilding the cache, I explained it to myself with a different tokenizing per PHP version. Mind the gap. The rules used in this project are pretty lightweight not to say conservative. I have to admit, this is most likely not that applicable to many projects.
Anyway, thanks a lot for the suggestion to solve this in config, I must admit I totally overlooked that. Thanks a lot for @ntzm for the hint, I will give it a try, let's see if it goes south.
Most helpful comment
How about: