Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check-pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 10 additions & 4 deletions src/Configuration/Defaults/CommonRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
],
];
}
17 changes: 17 additions & 0 deletions tests/codestyle/CommonRulesetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public static function providePhp82Fixtures(): array
];
}

public static function providePhp84Fixtures(): array
{
return [
["php84"],
];
}

/**
* @throws Exception
*/
Expand Down Expand Up @@ -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);
}
}
27 changes: 27 additions & 0 deletions tests/fixtures/php84/actual.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

class Php84
{
public string $languageCode;

public string $countryCode
{
set (string $countryCode) {
$this->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;
}
}
22 changes: 22 additions & 0 deletions tests/fixtures/php84/expected.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

class Php84
{
public string $combinedCode {
get => \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);
}
},
) {}
}