Created by: ybelenko
I've added PSR-12 rule set to Php-CS-Fixer config since it's officially supported now.
The config file has been renamed to .php-cs-fixer.dist.php
to be able to overwrite it with local config file without dist
part.
I don't know why we have so many rules since we agreed to follow PSR-12 only at the first place. New config:
/**
* @generated
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/HEAD/doc/config.rst
*/
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('vendor')
->exclude('test')
->exclude('tests')
;
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
'phpdoc_order' => true,
'array_syntax' => [ 'syntax' => 'short' ],
'strict_comparison' => true,
'strict_param' => true,
'no_trailing_whitespace' => false,
'no_trailing_whitespace_in_comment' => false,
'braces' => false,
'single_blank_line_at_eof' => false,
'blank_line_after_namespace' => false,
'no_leading_import_slash' => false,
])
->setFinder($finder)
;
If somebody knows why we have disabled:
'braces' => false,
'single_blank_line_at_eof' => false,
'blank_line_after_namespace' => false,
Also added rule no_leading_import_slash => false
because there are model classes with leadings slashes in imports. No clue why, but still.
Fixer run output:
vendor/bin/php-cs-fixer fix --allow-risky=yes -vv
PHP CS Fixer 3.8.0 BerSzcz against war! by Fabien Potencier and Dariusz Ruminski.
PHP runtime: 8.0.16
Loaded config default from "/Users/ybelenko/Sites/openapi-generator/samples/client/petstore/php/OpenAPIClient-php/.php-cs-fixer.dist.php".
............................................................ 60 / 60 (100%)
Legend: ?-unknown, I-invalid file syntax (file ignored), S-skipped (cached or empty file), .-no changes, F-fixed, E-error
Fixed all files in 2.246 seconds, 28.000 MB memory used
I would remove the old .php_cs
file from samples right in current PR, but the CI workflow will be failed instantly...
Related #4726
cc @jebentier @dkarlovi @mandrean @jfastnacht @renepardon
PR checklist
-
Read the contribution guidelines. -
Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community. -
Run the following to build the project and update samples: ./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh
./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH. -
If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.