diff --git a/.github/workflows/check-pr-title.yml b/.github/workflows/check-pr-title.yml index 8ec7d91..df68a2b 100644 --- a/.github/workflows/check-pr-title.yml +++ b/.github/workflows/check-pr-title.yml @@ -7,6 +7,6 @@ on: jobs: check-pr-title: name: Check PR title - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: blumilksoftware/action-pr-title@e05fc76a1cc45b33644f1de51218be43ac121dd0 # v1.2.0 diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index dd47671..ce6da3b 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -9,11 +9,11 @@ on: jobs: build: name: "Checking the package: testing and linting" - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: matrix: - php: ["8.2", "8.3"] + php: ["8.3", "8.4"] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 diff --git a/composer.json b/composer.json index d534ebe..6602a7a 100644 --- a/composer.json +++ b/composer.json @@ -1,12 +1,13 @@ { "name": "blumilksoftware/codestyle", + "version": "5.0.0", "description": "Blumilk codestyle configurator", "license": "MIT", "type": "library", "require": { - "php": "^8.2", - "friendsofphp/php-cs-fixer": "^3.75.0", - "kubawerlos/php-cs-fixer-custom-fixers": "^3.25.0" + "php": "^8.3", + "friendsofphp/php-cs-fixer": "^3.80.0", + "kubawerlos/php-cs-fixer-custom-fixers": "^3.30.0" }, "require-dev": { "jetbrains/phpstorm-attributes": "^1.2", @@ -34,7 +35,7 @@ } }, "scripts": { - "cs": "./vendor/bin/php-cs-fixer fix --dry-run --diff --config codestyle.php", + "cs": "./vendor/bin/php-cs-fixer fix --dry-run --diff --verbose --config codestyle.php", "csf": "./vendor/bin/php-cs-fixer fix --diff --config codestyle.php", "test": "./vendor/bin/phpunit tests --colors=always", "unit": "./vendor/bin/phpunit tests/unit --colors=always", diff --git a/src/Configuration/Defaults/CommonRules.php b/src/Configuration/Defaults/CommonRules.php index 990e651..19e5bd1 100644 --- a/src/Configuration/Defaults/CommonRules.php +++ b/src/Configuration/Defaults/CommonRules.php @@ -48,11 +48,13 @@ use PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer; use PhpCsFixer\Fixer\FunctionNotation\LambdaNotUsedImportFixer; use PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer; +use PhpCsFixer\Fixer\FunctionNotation\MultilinePromotedPropertiesFixer; use PhpCsFixer\Fixer\FunctionNotation\NullableTypeDeclarationForDefaultNullValueFixer; use PhpCsFixer\Fixer\FunctionNotation\ReturnTypeDeclarationFixer; use PhpCsFixer\Fixer\FunctionNotation\UseArrowFunctionsFixer; use PhpCsFixer\Fixer\FunctionNotation\VoidReturnFixer; use PhpCsFixer\Fixer\Import\FullyQualifiedStrictTypesFixer; +use PhpCsFixer\Fixer\Import\GlobalNamespaceImportFixer; use PhpCsFixer\Fixer\Import\NoLeadingImportSlashFixer; use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer; use PhpCsFixer\Fixer\Import\OrderedImportsFixer; @@ -80,6 +82,7 @@ use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer; use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer; use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer; +use PhpCsFixer\Fixer\Phpdoc\PhpdocArrayTypeFixer; use PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer; use PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer; use PhpCsFixer\Fixer\Phpdoc\PhpdocNoEmptyReturnFixer; @@ -119,12 +122,10 @@ use PhpCsFixer\Fixer\Whitespace\TypeDeclarationSpacesFixer; use PhpCsFixerCustomFixers\Fixer\CommentedOutFunctionFixer; use PhpCsFixerCustomFixers\Fixer\ConstructorEmptyBracesFixer; -use PhpCsFixerCustomFixers\Fixer\MultilinePromotedPropertiesFixer; use PhpCsFixerCustomFixers\Fixer\NoCommentedOutCodeFixer; use PhpCsFixerCustomFixers\Fixer\NoPhpStormGeneratedCommentFixer; use PhpCsFixerCustomFixers\Fixer\NoUselessCommentFixer; use PhpCsFixerCustomFixers\Fixer\NoUselessParenthesisFixer; -use PhpCsFixerCustomFixers\Fixer\PhpdocArrayStyleFixer; use PhpCsFixerCustomFixers\Fixer\PhpdocNoIncorrectVarAnnotationFixer; use PhpCsFixerCustomFixers\Fixer\PhpdocNoSuperfluousParamFixer; use PhpCsFixerCustomFixers\Fixer\PromotedConstructorPropertyFixer; @@ -279,8 +280,7 @@ class CommonRules extends Rules ConstructorEmptyBracesFixer::class => true, MultilinePromotedPropertiesFixer::class => true, NoUselessCommentFixer::class => true, - PhpdocArrayStyleFixer::class => true, - PromotedConstructorPropertyFixer::class => true, + PhpdocArrayTypeFixer::class => true, SingleSpaceAfterStatementFixer::class => true, SingleSpaceBeforeStatementFixer::class => true, StringableInterfaceFixer::class => true, @@ -374,5 +374,11 @@ class CommonRules extends Rules PhpUnitAttributesFixer::class => true, SpacesInsideParenthesesFixer::class => true, PhpdocAlignFixer::class => ["align" => "left"], + PromotedConstructorPropertyFixer::class => true, + GlobalNamespaceImportFixer::class => [ + "import_classes" => true, + "import_constants" => true, + "import_functions" => true, + ], ]; } diff --git a/tests/codestyle/CommonRulesetTest.php b/tests/codestyle/CommonRulesetTest.php index 904ea92..581c351 100644 --- a/tests/codestyle/CommonRulesetTest.php +++ b/tests/codestyle/CommonRulesetTest.php @@ -58,6 +58,13 @@ public static function providePhp82Fixtures(): array ]; } + public static function providePhp84Fixtures(): array + { + return [ + ["php84"], + ]; + } + /** * @throws Exception */ @@ -87,4 +94,14 @@ public function testPhp82Fixtures(string $name): void { $this->testFixture($name); } + + /** + * @throws Exception + */ + #[DataProvider("providePhp84Fixtures")] + #[RequiresPhp(">= 8.4")] + public function testPhp84Fixtures(string $name): void + { + $this->testFixture($name); + } } diff --git a/tests/fixtures/php84/actual.php b/tests/fixtures/php84/actual.php new file mode 100644 index 0000000..b2e4749 --- /dev/null +++ b/tests/fixtures/php84/actual.php @@ -0,0 +1,27 @@ +countryCode = strtoupper($countryCode); + } + } + + public string $combinedCode + { + get => \sprintf("%s_%s", $this->languageCode, $this->countryCode); + set (string $value) { + [$this->languageCode, $this->countryCode] = explode('_', $value, 2); + } + } + + public function __construct(string $languageCode, string $countryCode) + { + $this->languageCode = $languageCode; + $this->countryCode = $countryCode; + } +} diff --git a/tests/fixtures/php84/expected.php b/tests/fixtures/php84/expected.php new file mode 100644 index 0000000..e2673a1 --- /dev/null +++ b/tests/fixtures/php84/expected.php @@ -0,0 +1,22 @@ + \sprintf("%s_%s", $this->languageCode, $this->countryCode); + set (string $value) { + [$this->languageCode, $this->countryCode] = explode("_", $value, 2); + } + } + + public function __construct( + public string $languageCode, + public string $countryCode { + set (string $countryCode) { + $this->countryCode = strtoupper($countryCode); + } + }, + ) {} +}