Fix coding style missed by phpbcf#2875
Conversation
jtojnar
commented
Jul 1, 2022
$ composer require --dev friendsofphp/php-cs-fixer
$ echo >.php-cs-fixer.dist.php "<?php
$finder = PhpCsFixer\Finder::create()
->exclude('squizlabsD')
->in(__DIR__);
$rules = [
'@psr12' => true,
// '@psr12:risky' => true,
'@PHP74Migration' => true,
// '@PHP74Migration:risky' => true,
// buggy, duplicates existing comment sometimes
'no_break_comment' => false,
'array_syntax' => true,
'binary_operator_spaces' => true,
'lowercase_static_reference' => true,
'visibility_required' => false,
];
$config = new PhpCsFixer\Config();
return $config
->setRules($rules)
// ->setRiskyAllowed(true)
->setFinder($finder);
"
$ vendor/bin/php-cs-fixer --version
PHP CS Fixer 3.8.0 BerSzcz against war! by Fabien Potencier and Dariusz Ruminski.
PHP runtime: 7.4.30
$ vendor/bin/php-cs-fixer fix
|
I prefer not create a big diff in the vcs history since we already did one. Reproducing this diff requires additional tooling which I don't like. Most of these add a trailing comma in arrays which isn't super important. I am unsure about the indentation changes in heredocs and in array key => val alignment. |
That’s why I proposed doing it as a part of #2872. Now we have no other choice than making a second PR.
You can just install it one time and then drop it with Or we could replace CodeSniffer with PHP-CS-Fixer project-wide since it seems to work more reliably. I felt that the PHP-CS-Fixer defaults were reasonable but can adjust the formatting further if necessary:
|