From e1bc66fa88dc791c97f1e48ec2a4e9e9cd2639ad Mon Sep 17 00:00:00 2001 From: Peter Mein Date: Thu, 30 Jun 2022 11:12:20 +0200 Subject: [PATCH 1/3] Added support for 8.0 and 8.1 rules Removed deprecated rule `no_extra_blank_lines` for `use_traits` and added alternative Added declare_strict_types rule for 8.1+ projects --- src/PhpCsFixer/Rules.php | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/PhpCsFixer/Rules.php b/src/PhpCsFixer/Rules.php index b653fb2..8836959 100644 --- a/src/PhpCsFixer/Rules.php +++ b/src/PhpCsFixer/Rules.php @@ -9,11 +9,17 @@ */ class Rules { + /** + * @deprecated php version 7.1 is no longer supported + */ public static function getForPhp71(array $overriddenRules = []): array { return array_merge(self::getBaseRules(), $overriddenRules); } + /** + * @deprecated php version 7.2 is no longer supported + */ public static function getForPhp72(array $overriddenRules = []): array { $specific72Rules = [ @@ -23,6 +29,9 @@ public static function getForPhp72(array $overriddenRules = []): array return array_merge(self::getForPhp71($specific72Rules), $overriddenRules); } + /** + * @deprecated php version 7.3 is no longer supported + */ public static function getForPhp73(array $overriddenRules = []): array { $specific73Rules = [ @@ -39,6 +48,33 @@ public static function getForPhp73(array $overriddenRules = []): array return array_merge(self::getForPhp72($specific73Rules), $overriddenRules); } + public static function getForPhp74(array $overriddenRules = []): array + { + $specific74Rules = [ + // At the moment there are no specific 7.4 rules or configurations + ]; + + return array_merge(self::getForPhp73($specific74Rules), $overriddenRules); + } + + public static function getForPhp80(array $overriddenRules = []): array + { + $specific80Rules = [ + // At the moment there are no specific 8.0 rules or configurations + ]; + + return array_merge(self::getForPhp74($specific80Rules), $overriddenRules); + } + + public static function getForPhp81(array $overriddenRules = []): array + { + $specific81Rules = [ + 'declare_strict_types' => true, + ]; + + return array_merge(self::getForPhp80($specific81Rules), $overriddenRules); + } + private static function getBaseRules(): array { return [ @@ -97,6 +133,11 @@ private static function getBaseRules(): array // TODO: Add 'use' when php-cs-fixer #3582 is fixed ], ], + 'class_attributes_separation' => [ + 'elements' => [ + 'trait_import' => 'none', + ], + ], 'no_null_property_initialization' => true, 'no_superfluous_elseif' => true, 'no_superfluous_phpdoc_tags' => true, From d93ac2afb637546e5be2300b526f3d629781e0ec Mon Sep 17 00:00:00 2001 From: Peter Mein Date: Thu, 30 Jun 2022 11:21:59 +0200 Subject: [PATCH 2/3] Added php8.1 to the testing workflow --- .github/workflows/php-cs-fixer.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml index 3003bdb..608492b 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/php-cs-fixer.yml @@ -18,6 +18,7 @@ jobs: - "7.3" - "7.4" - "8.0" + - "8.1" operating-system: - "ubuntu-latest" From ae0325f2251711a0e2996e19d8a694152e28793d Mon Sep 17 00:00:00 2001 From: Peter Mein Date: Thu, 30 Jun 2022 11:25:55 +0200 Subject: [PATCH 3/3] Normalized composer.json according to workflow --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 27ddac2..64e38a3 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { "name": "mollie/php-coding-standards", - "type": "library", "description": "Contains PHP coding standards like rules for PHP-CS-Fixer that serves for purpose of standardization.", "license": "BSD-2-Clause", + "type": "library", "authors": [ { "name": "Mollie B.V.", @@ -13,10 +13,10 @@ "php": "^7.1.3 || ^8.0", "friendsofphp/php-cs-fixer": "^3.1.0" }, + "minimum-stability": "stable", "autoload": { "psr-4": { "Mollie\\PhpCodingStandards\\": "src/" } - }, - "minimum-stability": "stable" + } }