From b0e785d0e54de53262a0d69b3bbf4a59a395cd88 Mon Sep 17 00:00:00 2001 From: zingimmick Date: Thu, 20 Jan 2022 17:54:36 +0800 Subject: [PATCH 1/2] Add ECS set for PHP --- config/set/php54.php | 12 +++++++++++ config/set/php56.php | 13 ++++++++++++ config/set/php70.php | 13 ++++++++++++ config/set/php71.php | 13 ++++++++++++ config/set/php72.php | 13 ++++++++++++ config/set/php73.php | 13 ++++++++++++ config/set/php74.php | 13 ++++++++++++ config/set/php80.php | 13 ++++++++++++ config/set/php81.php | 13 ++++++++++++ ecs.php | 4 +--- src/Set/ECSSetList.php | 45 ++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 config/set/php54.php create mode 100644 config/set/php56.php create mode 100644 config/set/php70.php create mode 100644 config/set/php71.php create mode 100644 config/set/php72.php create mode 100644 config/set/php73.php create mode 100644 config/set/php74.php create mode 100644 config/set/php80.php create mode 100644 config/set/php81.php diff --git a/config/set/php54.php b/config/set/php54.php new file mode 100644 index 0000000..35aa423 --- /dev/null +++ b/config/set/php54.php @@ -0,0 +1,12 @@ +import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP54_MIGRATION); +}; diff --git a/config/set/php56.php b/config/set/php56.php new file mode 100644 index 0000000..f875454 --- /dev/null +++ b/config/set/php56.php @@ -0,0 +1,13 @@ +import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP54_MIGRATION); + $containerConfigurator->import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP56_MIGRATION_RISKY); +}; diff --git a/config/set/php70.php b/config/set/php70.php new file mode 100644 index 0000000..ef36398 --- /dev/null +++ b/config/set/php70.php @@ -0,0 +1,13 @@ +import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP70_MIGRATION); + $containerConfigurator->import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP70_MIGRATION_RISKY); +}; diff --git a/config/set/php71.php b/config/set/php71.php new file mode 100644 index 0000000..58a1809 --- /dev/null +++ b/config/set/php71.php @@ -0,0 +1,13 @@ +import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP71_MIGRATION); + $containerConfigurator->import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP71_MIGRATION_RISKY); +}; diff --git a/config/set/php72.php b/config/set/php72.php new file mode 100644 index 0000000..fe55220 --- /dev/null +++ b/config/set/php72.php @@ -0,0 +1,13 @@ +import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP71_MIGRATION); + $containerConfigurator->import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP71_MIGRATION_RISKY); +}; diff --git a/config/set/php73.php b/config/set/php73.php new file mode 100644 index 0000000..f3332bd --- /dev/null +++ b/config/set/php73.php @@ -0,0 +1,13 @@ +import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP73_MIGRATION); + $containerConfigurator->import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP71_MIGRATION_RISKY); +}; diff --git a/config/set/php74.php b/config/set/php74.php new file mode 100644 index 0000000..96752b0 --- /dev/null +++ b/config/set/php74.php @@ -0,0 +1,13 @@ +import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP74_MIGRATION); + $containerConfigurator->import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP74_MIGRATION_RISKY); +}; diff --git a/config/set/php80.php b/config/set/php80.php new file mode 100644 index 0000000..2c6c861 --- /dev/null +++ b/config/set/php80.php @@ -0,0 +1,13 @@ +import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP80_MIGRATION); + $containerConfigurator->import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP80_MIGRATION_RISKY); +}; diff --git a/config/set/php81.php b/config/set/php81.php new file mode 100644 index 0000000..9e49f74 --- /dev/null +++ b/config/set/php81.php @@ -0,0 +1,13 @@ +import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP81_MIGRATION); + $containerConfigurator->import(\Zing\CodingStandard\Set\PhpCsFixerSetList::PHP80_MIGRATION_RISKY); +}; diff --git a/ecs.php b/ecs.php index 26f6325..1ea2fd9 100644 --- a/ecs.php +++ b/ecs.php @@ -8,9 +8,7 @@ use Zing\CodingStandard\Set\ECSSetList; return static function (ContainerConfigurator $containerConfigurator): void { - \PHP_CodeSniffer\Config::setConfigData('php_version', 70200); - $containerConfigurator->import(ECSSetList::PHP71_MIGRATION); - $containerConfigurator->import(ECSSetList::PHP71_MIGRATION_RISKY); + $containerConfigurator->import(ECSSetList::PHP_72); $containerConfigurator->import(ECSSetList::CUSTOM); $parameters = $containerConfigurator->parameters(); diff --git a/src/Set/ECSSetList.php b/src/Set/ECSSetList.php index acd800e..85fcb85 100644 --- a/src/Set/ECSSetList.php +++ b/src/Set/ECSSetList.php @@ -95,4 +95,49 @@ final class ECSSetList * @var string */ public const CUSTOM = __DIR__ . '/../../config/ecs.php'; + + /** + * @var string + */ + public const PHP_54 = __DIR__ . '/../../config/set/php54.php'; + + /** + * @var string + */ + public const PHP_56 = __DIR__ . '/../../config/set/php56.php'; + + /** + * @var string + */ + public const PHP_70 = __DIR__ . '/../../config/set/php70.php'; + + /** + * @var string + */ + public const PHP_71 = __DIR__ . '/../../config/set/php71.php'; + + /** + * @var string + */ + public const PHP_72 = __DIR__ . '/../../config/set/php72.php'; + + /** + * @var string + */ + public const PHP_73 = __DIR__ . '/../../config/set/php73.php'; + + /** + * @var string + */ + public const PHP_74 = __DIR__ . '/../../config/set/php74.php'; + + /** + * @var string + */ + public const PHP_80 = __DIR__ . '/../../config/set/php80.php'; + + /** + * @var string + */ + public const PHP_81 = __DIR__ . '/../../config/set/php81.php'; } From dd1ec1bd2cf77abfdae44f59e685f73179c68ff7 Mon Sep 17 00:00:00 2001 From: zingimmick Date: Tue, 25 Jan 2022 19:24:11 +0800 Subject: [PATCH 2/2] Generate ruleset for friendsofphp/php-cs-fixer 3.5.0 --- composer.json | 2 +- config/set/php-cs-fixer-custom.php | 1 + config/set/php-cs-fixer/php-cs-fixer.php | 1 + config/set/php-cs-fixer/php80-migration-risky.php | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b1d6b27..4790f15 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "php": "^7.2 || ^8.0", "rector/rector": "^0.12", "slevomat/coding-standard": "^7.0", - "symplify/easy-coding-standard": "^10.0" + "symplify/easy-coding-standard": "^10.0.16" }, "require-dev": { "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", diff --git a/config/set/php-cs-fixer-custom.php b/config/set/php-cs-fixer-custom.php index a837aa9..1614f69 100644 --- a/config/set/php-cs-fixer-custom.php +++ b/config/set/php-cs-fixer-custom.php @@ -291,6 +291,7 @@ 'goto', 'include', 'include_once', + 'phpdoc', 'require', 'require_once', 'return', diff --git a/config/set/php-cs-fixer/php-cs-fixer.php b/config/set/php-cs-fixer/php-cs-fixer.php index 5aaeac1..08e504f 100644 --- a/config/set/php-cs-fixer/php-cs-fixer.php +++ b/config/set/php-cs-fixer/php-cs-fixer.php @@ -257,6 +257,7 @@ 'goto', 'include', 'include_once', + 'phpdoc', 'require', 'require_once', 'return', diff --git a/config/set/php-cs-fixer/php80-migration-risky.php b/config/set/php-cs-fixer/php80-migration-risky.php index 2c410c3..51adad4 100644 --- a/config/set/php-cs-fixer/php80-migration-risky.php +++ b/config/set/php-cs-fixer/php80-migration-risky.php @@ -19,6 +19,7 @@ $services->set(\PhpCsFixer\Fixer\Alias\PowToExponentiationFixer::class); $services->set(\PhpCsFixer\Fixer\FunctionNotation\VoidReturnFixer::class); $services->set(\PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer::class); + $services->set(\PhpCsFixer\Fixer\LanguageConstruct\GetClassToClassKeywordFixer::class); $services->set(\PhpCsFixer\Fixer\FunctionNotation\UseArrowFunctionsFixer::class); $services->set(\PhpCsFixer\Fixer\Basic\NonPrintableCharacterFixer::class); $services->set(\PhpCsFixer\Fixer\Alias\RandomApiMigrationFixer::class)