How do you configure PHP-CS-Fixer?

I've added a .php_cs file to my project's root folder, containing this:

<?php
$finder = PhpCsFixer\Finder::create()
->exclude('.repositories')
->in(__DIR__)
;

return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'full_opening_tag' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setCacheFile(__DIR__.'/.php_cs.cache')
->setIndent("\t")
->setFinder($finder)
;
?>

Yet, phpStorm does not load this configuration and does not use this file to set the rules. How do I make phpStorm use the correct rules?

1 comment
Comment actions Permalink

I figured it out. From Preferences -> Editor > Inspections > PHP > Quality tools > PHP CS Fixer Validation -> Custom ruleset, then the three dots and set the path to your .php_cs file.

I still think it should be the default behaviour to look for a .php_cs file in the project root, but I can work with this :)

0

Please sign in to leave a comment.