PHP CS Fixer Hints in PhpStorm
An article a while back on freek.dev about Tools to automatically format PHP, JavaScript and CSS files instructed you to make a .php_cs
file in your project. This file defines the rules for how PHP CS Fixer should behave when run.
<?php
$finder = Symfony\Component\Finder\Finder::create()
->notPath('vendor')
->in(__DIR__ . '/src')
->name('*.php')
->notName('*.blade.php');
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'no_unused_imports' => true,
])
->setFinder($finder);
If you're using PhpStorm, it'll automatically start hinting at issues that PHP CS Fixer is flagging, offering automatic actions for potential fixes.