Skip to content

Commit 50fdacc

Browse files
committed
Setup PHP-CS-Fixer config and pipeline
1 parent 6b652ca commit 50fdacc

File tree

6 files changed

+77
-10
lines changed

6 files changed

+77
-10
lines changed

.gitattributes

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
/.github/ export-ignore
2-
/bin/ export-ignore
3-
/tests/ export-ignore
4-
/.editorconfig export-ignore
5-
/.gitattributes export-ignore
6-
/.gitignore export-ignore
7-
/CONTRIBUTING.md export-ignore
8-
/phpunit.dist.xml export-ignore
1+
/.github/ export-ignore
2+
/bin/ export-ignore
3+
/tests/ export-ignore
4+
/.editorconfig export-ignore
5+
/.gitattributes export-ignore
6+
/.gitignore export-ignore
7+
/CONTRIBUTING.md export-ignore
8+
/phpunit.dist.xml export-ignore
9+
/.php-cs-fixer.dist.php export-ignore

.github/workflows/build.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ on:
88
types: [ created ]
99

1010
jobs:
11+
check_code_style:
12+
name: Check code style
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: shivammathur/setup-php@v2
18+
with:
19+
coverage: none
20+
php-version: '8.3'
21+
22+
- name: Install dependencies
23+
run: composer update
24+
25+
- run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --show-progress=dots
26+
1127
tests:
1228
runs-on: ubuntu-latest
1329
name: Build and test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ composer.lock
44
.phpunit.cache
55
.phpunit.result.cache
66
phpunit.xml
7+
.php-cs-fixer.php
8+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())
4+
->in(__DIR__)
5+
->notPath('i18n.php');
6+
7+
return (new PhpCsFixer\Config())
8+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
9+
->setRules([
10+
'@PER-CS' => true,
11+
'@Symfony' => true,
12+
'header_comment' => [
13+
'header' => <<<'TEXT'
14+
This file is part of the Behat Gherkin Parser.
15+
(c) Konstantin Kudryashov <ever.zet@gmail.com>
16+
17+
For the full copyright and license information, please view the LICENSE
18+
file that was distributed with this source code.
19+
TEXT
20+
],
21+
'yoda_style' => [
22+
'equal' => false,
23+
'identical' => false,
24+
'less_and_greater' => false,
25+
],
26+
'concat_space' => ['spacing' => 'one'],
27+
'phpdoc_align' => ['align' => 'left'],
28+
])
29+
->setFinder($finder);

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ We use automated tools to ensure that the code has a consistent style and is of
2727
composer lint
2828
```
2929

30+
## Automated Fixes
31+
32+
Some problems detected by the linting tools can be fixed automatically. Simply run the following:
33+
34+
```shell
35+
composer fix
36+
```
37+
3038
## Contributing to Gherkin Translations
3139

3240
Gherkin supports &rarr;40 different languages and you could add more! You might notice `i18n.php` file in the root of

composer.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"require-dev": {
2121
"symfony/yaml": "^5.4 || ^6.4 || ^7.0",
2222
"phpunit/phpunit": "^10.5",
23-
"cucumber/cucumber": "dev-gherkin-24.1.0"
23+
"cucumber/cucumber": "dev-gherkin-24.1.0",
24+
"friendsofphp/php-cs-fixer": "^3.65"
2425
},
2526

2627
"suggest": {
@@ -67,11 +68,21 @@
6768

6869
"scripts": {
6970
"lint": [
70-
"Composer\\Config::disableProcessTimeout"
71+
"Composer\\Config::disableProcessTimeout",
72+
"vendor/bin/php-cs-fixer fix --dry-run --diff --show-progress=dots"
7173
],
7274
"test": [
7375
"Composer\\Config::disableProcessTimeout",
7476
"vendor/bin/phpunit ./tests"
77+
],
78+
"fix": [
79+
"Composer\\Config::disableProcessTimeout",
80+
"vendor/bin/php-cs-fixer fix --diff --show-progress=dots"
7581
]
82+
},
83+
"config": {
84+
"allow-plugins": {
85+
"phpstan/extension-installer": false
86+
}
7687
}
7788
}

0 commit comments

Comments
 (0)