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