From 993b4bf9c5ef5981a3a09de98ae40451b187399e Mon Sep 17 00:00:00 2001 From: Sacha Telgenhof Date: Tue, 30 Jan 2024 01:26:23 +0900 Subject: [PATCH] build: Shorten the PHP CS fix script and add a script to perform a dry-run. Use common PHP CS fixer config package Signed-off-by: Sacha Telgenhof --- .php-cs-fixer.dist.php | 25 ++----------------------- composer.json | 4 +++- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 2f04070..b03c73a 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -12,28 +12,7 @@ * @author Sacha Telgenhof */ -$finder = PhpCsFixer\Finder::create()->in(__DIR__)->notPath('var'); - -$config = new PhpCsFixer\Config(); -$config->setRiskyAllowed(true)->setRules([ - '@Symfony' => true, - '@PER' => true, - 'combine_consecutive_issets' => true, - 'combine_consecutive_unsets' => true, - 'ordered_class_elements' => true, - 'no_superfluous_elseif' => true, - 'no_superfluous_phpdoc_tags' => ['remove_inheritdoc' => true], - 'not_operator_with_successor_space' => true, - - // Risky - 'declare_strict_types' => true, - 'dir_constant' => true, - 'get_class_to_class_keyword' => true, - 'is_null' => true, - 'modernize_strpos' => true, - 'modernize_types_casting' => true, - 'native_constant_invocation' => ['strict' => false], - 'self_accessor' => true, -])->setFinder($finder); +$config = new AzuyaLabs\PhpCsFixerConfig\Config('2017'); +$config->getFinder()->in(__DIR__)->notPath('var'); return $config; diff --git a/composer.json b/composer.json index cadd017..0224485 100644 --- a/composer.json +++ b/composer.json @@ -39,6 +39,7 @@ "guzzlehttp/guzzle": "^7.8" }, "require-dev": { + "azuyalabs/php-cs-fixer-config": "dev-dev", "fakerphp/faker": "^1.23", "friendsofphp/php-cs-fixer": "^v3.15", "infection/infection": "^0.26", @@ -72,7 +73,8 @@ "@psalm", "@infection" ], - "format": "vendor/bin/php-cs-fixer fix", + "cs": "vendor/bin/php-cs-fixer fix -v --diff --dry-run", + "cs-fix": "vendor/bin/php-cs-fixer fix -v", "infection": "vendor/bin/infection run -j 2", "phpstan": "vendor/bin/phpstan analyse", "psalm": "vendor/bin/psalm --threads=2",