Skip to content

Commit 7ef29a4

Browse files
committed
feat: create php cs fixer auto workflow
1 parent d86f6ef commit 7ef29a4

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Check & fix styling
2+
3+
on: [push]
4+
5+
permissions:
6+
contents: write
7+
8+
jobs:
9+
php-cs-fixer:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.head_ref }}
17+
18+
- name: Run PHP CS Fixer
19+
uses: docker://oskarstark/php-cs-fixer-ga
20+
with:
21+
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
22+
23+
- name: Commit changes
24+
uses: stefanzweifel/git-auto-commit-action@v5
25+
with:
26+
commit_message: Fix styling

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ yarn.lock
3131
/.sass-cache
3232

3333
__MACOSX
34+
*.cache

.php-cs-fixer.dist.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in([
5+
__DIR__ . '/src',
6+
__DIR__ . '/tests',
7+
__DIR__ . '/common',
8+
__DIR__ . '/config',
9+
])
10+
->name('*.php')
11+
->ignoreDotFiles(true)
12+
->ignoreVCS(true);
13+
14+
return (new PhpCsFixer\Config())
15+
->setRules([
16+
'@PSR12' => true,
17+
'simplified_null_return' => true,
18+
'braces' => false,
19+
'new_with_braces' => [
20+
'anonymous_class' => false,
21+
'named_class' => false,
22+
],
23+
'array_syntax' => ['syntax' => 'short'],
24+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
25+
'no_unused_imports' => true,
26+
'trailing_comma_in_multiline' => true,
27+
'phpdoc_scalar' => true,
28+
'unary_operator_spaces' => true,
29+
'binary_operator_spaces' => true,
30+
'blank_line_before_statement' => [
31+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
32+
],
33+
'phpdoc_single_line_var_spacing' => true,
34+
'phpdoc_var_without_name' => true,
35+
'class_attributes_separation' => [
36+
'elements' => [
37+
'const' => 'one',
38+
'method' => 'one',
39+
'property' => 'one',
40+
],
41+
],
42+
'method_argument_space' => [
43+
'on_multiline' => 'ensure_fully_multiline',
44+
'keep_multiple_spaces_after_comma' => true,
45+
],
46+
'single_trait_insert_per_statement' => true,
47+
'blank_lines_before_namespace' => true,
48+
'doctrine_annotation_indentation' => true,
49+
'doctrine_annotation_spaces' => true,
50+
'elseif' => true,
51+
'full_opening_tag' => true,
52+
'include' => true,
53+
'php_unit_method_casing' => false,
54+
'phpdoc_types' => true,
55+
'phpdoc_types_order' => true,
56+
'phpdoc_var_annotation_correct_order' => true,
57+
])
58+
->setFinder($finder);

0 commit comments

Comments
 (0)