From d910f7bffcd08df5f6453f683ddc48714718b3d7 Mon Sep 17 00:00:00 2001 From: DanMat Date: Sun, 2 Aug 2026 11:38:42 -0400 Subject: [PATCH] chore: add PHP-CS-Fixer, matching the core config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same conservative PSR-12 config as nimbuscms/nimbus, so official packages format identically. The existing code was already clean — the one-off run changed nothing — which is the point: the rules encode the style already in use rather than imposing a new one. composer format applies it; composer format:check runs in CI before the tests. Co-Authored-By: Claude Opus 4.8 --- .github/workflows/ci.yml | 3 +++ .gitignore | 1 + .php-cs-fixer.dist.php | 26 ++++++++++++++++++++++++++ composer.json | 5 ++++- 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .php-cs-fixer.dist.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2528558..8db228f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,9 @@ jobs: - name: Install dependencies run: composer install --no-interaction --prefer-dist --no-progress + - name: Formatting + run: vendor/bin/php-cs-fixer fix --dry-run --diff + - name: Static analysis run: vendor/bin/phpstan analyse --no-progress --memory-limit=512M diff --git a/.gitignore b/.gitignore index cc3d67a..a6b3c65 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .phpunit.result.cache .phpunit.cache/ .DS_Store +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..69c32aa --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,26 @@ +in([__DIR__ . '/src', __DIR__ . '/tests']) + ->append([__FILE__]); + +return (new PhpCsFixer\Config()) + ->setRiskyAllowed(false) + ->setRules([ + '@PSR12' => true, + 'array_syntax' => ['syntax' => 'short'], + 'no_unused_imports' => true, + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'single_quote' => true, + 'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments', 'parameters']], + 'no_trailing_whitespace' => true, + 'no_whitespace_in_blank_line' => true, + 'blank_line_after_opening_tag' => true, + ]) + ->setFinder($finder); diff --git a/composer.json b/composer.json index 9b2612f..030b20e 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ "nimbuscms/nimbus": "dev-main" }, "require-dev": { + "friendsofphp/php-cs-fixer": "^3.95", "phpstan/phpstan": "^2.2", "phpunit/phpunit": "^11.0" }, @@ -51,7 +52,9 @@ "check": [ "@analyse", "@test" - ] + ], + "format": "php-cs-fixer fix", + "format:check": "php-cs-fixer fix --dry-run --diff" }, "config": { "sort-packages": true