Skip to content

Commit

Permalink
Merge pull request #9 from elecena/add/php-cs-fixer
Browse files Browse the repository at this point in the history
Introduce the php-cs-fixer and enforce the formatting
  • Loading branch information
macbre authored Aug 11, 2023
2 parents e4ebc2f + 237f065 commit 6ba41b0
Show file tree
Hide file tree
Showing 17 changed files with 3,038 additions and 1,028 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ jobs:

- name: Run test suite
run: composer run-script test

- name: Lint the code
env:
PHP_CS_FIXER_IGNORE_ENV: '1' # make cs-fixer stop complaining when using PHP 8.3
run: composer run-script lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.phpunit.result.cache
.phpunit.cache
example.php
.php-cs-fixer.cache
17 changes: 17 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src/')
->in(__DIR__ . '/tests/')
;

$config = new PhpCsFixer\Config();

// https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/rules/index.rst
// https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/ruleSets/index.rst
return $config
->setRules([
'@PSR2' => true,
])
->setFinder($finder)
;
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@
"php": "^8.1"
},
"require-dev": {
"phpunit/phpunit": "^10.3"
"phpunit/phpunit": "^10.3",
"friendsofphp/php-cs-fixer": "^3.22"
},
"scripts": {
"test": "phpunit --testdox"
"test": "phpunit --testdox",
"lint": [
"php-cs-fixer fix --config=.php-cs-fixer.php --dry-run --verbose"
],
"format": [
"php-cs-fixer fix --config=.php-cs-fixer.php"
]
}
}
Loading

0 comments on commit 6ba41b0

Please sign in to comment.