Skip to content

Commit

Permalink
🎨 Convert to PHP CS Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
giggsey committed Nov 4, 2024
1 parent 40e5eb0 commit 6bd729b
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 9 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ cldr-json/
data-git/
tests/testOutput/
/.phpunit.result.cache
/.php-cs-fixer.cache
24 changes: 24 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()
->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);
5 changes: 0 additions & 5 deletions .styleci.yml

This file was deleted.

7 changes: 6 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</target>

<target name="compile" description="Build data"
depends="cleanup-data,build-data">
depends="cleanup-data,build-data,cs-fixer">
</target>

<target name="cleanup-data" description="Cleanup built data">
Expand Down Expand Up @@ -65,4 +65,9 @@
</exec>
</target>

<target name="cs-fixer">
<exec executable="vendor/bin/php-cs-fixer" passthru="true">
<arg value="fix"/>
</exec>
</target>
</project>
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": ">=7.2"
"php": "^7.4|^8.0"
},
"require-dev": {
"ext-json": "*",
Expand All @@ -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": {
Expand All @@ -43,7 +44,7 @@
"tests/",
".gitattributes",
".gitignore",
".styleci.yml",
".php-cs-fixer.dist.php",
".travis.yml",
"build.xml",
"phpunit.xml.dist"
Expand Down

0 comments on commit 6bd729b

Please sign in to comment.