diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..2051653 --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,42 @@ +name: PHP CS Fixer +on: + push: + branches: + - 'main' + pull_request: + paths: + - '**.php' + +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + php-cs-fixer: + name: "PHP CS Fixer" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + + - uses: "ramsey/composer-install@v3" + with: + dependency-versions: highest + + - name: Run PHP CS Fixer + run: "composer run-script cs" + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: ":art: Fix code styling" diff --git a/.gitignore b/.gitignore index 359e502..0c11122 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ cldr-json/ data-git/ tests/testOutput/ /.phpunit.result.cache +/.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..1333547 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,24 @@ +in(__DIR__); + +$config = new PhpCsFixer\Config(); +return $config->setRules( + [ + '@PER-CS2.0' => true, + '@PHP74Migration' => true, + 'single_quote' => true, + 'no_unused_imports' => true, + 'no_superfluous_phpdoc_tags' => [ + 'allow_hidden_params' => true, + 'allow_mixed' => true, + 'remove_inheritdoc' => true, + ], + 'phpdoc_trim' => true, + ] +) +->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) +->setFinder($finder); diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index cd67bf6..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,5 +0,0 @@ -preset: psr12 - -finder: - exclude: - - "data" diff --git a/build.xml b/build.xml index 1253c42..6de376f 100644 --- a/build.xml +++ b/build.xml @@ -22,7 +22,7 @@ + depends="cleanup-data,build-data,cs-fixer"> @@ -65,4 +65,9 @@ + + + + + diff --git a/composer.json b/composer.json index a771089..3320725 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": ">=7.2" + "php": "^7.4|^8.0" }, "require-dev": { "ext-json": "*", @@ -24,7 +24,8 @@ "symfony/console": "^5.0|^6.0", "symfony/filesystem": "^5.0|^6.0", "symfony/process": "^5.0|^6.0", - "symfony/finder": "^5.0|^6.0" + "symfony/finder": "^5.0|^6.0", + "friendsofphp/php-cs-fixer": "^3.64" }, "autoload": { "psr-4": { @@ -43,7 +44,7 @@ "tests/", ".gitattributes", ".gitignore", - ".styleci.yml", + ".php-cs-fixer.dist.php", ".travis.yml", "build.xml", "phpunit.xml.dist"