Skip to content

Commit bb5b711

Browse files
committed
feat: add php cs fixer
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 6f75779 commit bb5b711

6 files changed

Lines changed: 2652 additions & 0 deletions

File tree

.github/workflows/lint-php-cs.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Lint php-cs
2+
3+
on: pull_request
4+
5+
permissions:
6+
contents: read
7+
8+
concurrency:
9+
group: lint-php-cs-${{ github.head_ref || github.run_id }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
16+
name: php-cs
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
with:
22+
persist-credentials: false
23+
24+
- name: Set up php8.1
25+
uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e # v2.34.1
26+
with:
27+
php-version: 8.1
28+
extensions: json, openssl
29+
coverage: none
30+
ini-file: development
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Install dependencies
35+
run: composer i
36+
37+
- name: Lint
38+
run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.idea
22
.vscode
33
.phpunit.result.cache
4+
.php-cs-fixer.cache
45
vendor
56
/vendor-bin/**/vendor/

.php-cs-fixer.dist.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
require_once './vendor-bin/coding-standard/vendor/autoload.php';
6+
7+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
8+
9+
$config = new PhpCsFixer\Config();
10+
$config
11+
->setParallelConfig(ParallelConfigFactory::detect())
12+
->getFinder()
13+
->ignoreVCSIgnored(true)
14+
->notPath('vendor')
15+
->notPath('vendor-bin')
16+
->in(__DIR__);
17+
return $config;

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
}
3838
},
3939
"scripts": {
40+
"cs:check": "php-cs-fixer fix --dry-run --diff",
41+
"cs:fix": "php-cs-fixer fix",
4042
"test:unit": "vendor/bin/phpunit --no-coverage --colors=always --fail-on-warning --fail-on-risky --display-deprecations --display-phpunit-deprecations",
4143
"test:coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit",
4244
"psalm": "psalm --no-cache --threads=$(nproc)",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"require-dev": {
3+
"friendsofphp/php-cs-fixer": "^3.59"
4+
},
5+
"config": {
6+
"platform": {
7+
"php": "8.1"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)