Struggling with adding non php extensions to my finder. Done a long google search but came up blank. Found this but couldn't quite understand: How to use other file extensions in php-cs-fixer, for example .ctp?
This is what I have:
<?php
$finder = PhpCsFixer\Finder::create()
->notPath('path/to/some/file.inc')
->notPath('path/to/some/file.class')
->in(__DIR__)
->name('*.php')
->name('*.inc')
->name('*.class');
return PhpCsFixer\Config::create()
->setRules(
array(
'Rule 1' => true,
...
'Rule n' => true,
)
)
->setFinder($finder);
I will like it to work on the *.inc and *.class files but it only seems to be picking the *.php files.
Any clues to what I may have missed?
PS
I forgot to add that trying a single ->name('/(\.php|\.inc|\.class)$/');
makes no difference. It still only picks *.php files.
Also, instead of voting me down without explanation, please give me a definitive answer ... is there something I am doing wrongly? If so, point me to this.
Your issue is not fully described, can't reproduce.
*.inc
file was fixed** EDIT BY OP **
After some great support on the project gitter page: https://gitter.im/PHP-CS-Fixer/Lobby, it turns out the issue was that the way I was calling things on the command line was overwriting the path information in my config file.
A clue was the CLI message that read
Paths from configuration file have been overridden by paths provided as command arguments
.My original command was...
php php-cs-fixer fix /path/to/project/folder --config /path/to/config/file/.php_cs.dist
Two options that should have been used:
Skip the
/path/to/project/folder
Correct command =php php-cs-fixer fix --config /path/to/config/file/.php_cs.dist
. According to the devs, this could have a drawback in that one may not be able to run the tool with sub paths of the root project.Add a
-path-mode=intersection
flag to the CLI statement to make things play nice with each other. Correct command =php php-cs-fixer fix /path/to/project/folder --config /path/to/config/file/.php_cs.dist --path-mode=intersection