How to use other file extensions in php-cs-fixer, for example cakephp template .ctp files ?
I have trying this code:
<?php
$finder = PhpCsFixer\Finder::create()
->notPath('bootstrap/cache')
->notPath('storage')
->notPath('vendor')
->in(__DIR__)
->name('*.php') // <===== *.ctp
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
;
return PhpCsFixer\Config::create()
->setRules(array(
'@Symfony' => true,
'binary_operator_spaces' => ['align_double_arrow' => false],
'array_syntax' => ['syntax' => 'short'],
'linebreak_after_opening_tag' => true,
'not_operator_with_successor_space' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
))
->setFinder($finder)
;
Thing is, that with original way of running the PHP CS Fixer, you have path finder configured once in config file, and then you pass the path also as CLI argument. As a result - you have fully defined finder in config, which got later overwritten by CLI argument, also you got a message:
Solution is to: - provide a path only in config file - provide a path only as CLI argument - provide a path in both places (ex, in config
plugins
, while as CLI argumentplugins/subdir
(as passing exactly same value doesn't really make sense...), but then also provide--path-mode=intersection
parameter, to not override the path, but take common part of paths (one in config, one as CLI arg)I try with this config file:
and command
without success.
But when I change
to
and run
fixer is executed and fix (arrays) in old cakephp 2 .ctp files for using in new cakephp 3 app.