Skip to content

Commit 1a557de

Browse files
committed
add(qa) php-cs-fixer config and github action
1 parent 33bebf2 commit 1a557de

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

.github/workflows/lint.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "Code Linting"
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
8+
jobs:
9+
php-cs-fixer:
10+
name: 'PHP-CS-Fixer'
11+
runs-on: 'ubuntu-latest'
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: 8.2
19+
tools: php-cs-fixer:3.45, cs2pr
20+
21+
- uses: actions/cache@v3
22+
with:
23+
path: '.php-cs-fixer.cache'
24+
key: ${{ github.repository }}-8.2-phpcsfixer-${{ github.ref_name }}
25+
restore-keys: |
26+
${{ github.repository }}-8.2-phpcsfixer-master
27+
${{ github.repository }}-8.2-phpcsfixer-
28+
29+
- name: Run PHP-CS-Fixer
30+
# Using cs2pr settings, see: https://github.com/shivammathur/setup-php#tools-with-checkstyle-support
31+
run: 'php-cs-fixer fix --dry-run --format checkstyle | cs2pr'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ tests/DoctrineTest/doctrine_tests/*
44
/tests/tmp
55
/tests/foo.sq3
66
/vendor/
7+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->ignoreVCSIgnored(true)
5+
->in(__DIR__.'/lib')
6+
->in(__DIR__.'/tests')
7+
->append(array(__FILE__))
8+
// Exclude generated files (single files)
9+
->notPath('should-be-ignored.php')
10+
;
11+
12+
$config = new PhpCsFixer\Config();
13+
$config->setRules(array(
14+
'@PhpCsFixer' => true,
15+
'@Symfony' => true,
16+
'array_syntax' => array(
17+
'syntax' => 'long',
18+
),
19+
))
20+
->setCacheFile('.php-cs-fixer.cache')
21+
->setFinder($finder)
22+
;
23+
24+
return $config;

0 commit comments

Comments
 (0)