Skip to content

Commit 0f5a950

Browse files
committed
fix php version in github style fixer
1 parent 5e7c02c commit 0f5a950

File tree

2 files changed

+53
-46
lines changed

2 files changed

+53
-46
lines changed

.github/workflows/code-style.yml

Lines changed: 13 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,23 @@
1-
name: Code style
1+
name: Check & fix styling
22

3-
on: [push, pull_request]
4-
5-
permissions:
6-
contents: read # Allows checkout
3+
on: [push]
74

85
jobs:
9-
phpcs:
10-
name: PHPCS
6+
php-cs-fixer:
117
runs-on: ubuntu-latest
8+
129
steps:
1310
- name: Checkout code
14-
uses: actions/checkout@v4 # Use latest major version
15-
16-
- name: Setup PHP
17-
uses: shivammathur/setup-php@v2
11+
uses: actions/checkout@v4
1812
with:
19-
php-version: '8.2'
20-
extensions: mbstring, xml # Add common extensions often needed by linters/tools
21-
tools: composer:v2 # Optionally specify composer version
22-
env:
23-
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Recommended for private repos or hitting rate limits
13+
ref: ${{ github.head_ref }}
2414

25-
- name: Get Composer Cache Directory
26-
id: composer-cache
27-
run: |
28-
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
29-
30-
- name: Cache Composer dependencies
31-
uses: actions/cache@v4 # Use latest major version
15+
- name: Run PHP CS Fixer
16+
uses: docker://oskarstark/php-cs-fixer-ga
3217
with:
33-
path: ${{ steps.composer-cache.outputs.dir }}
34-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
35-
restore-keys: |
36-
${{ runner.os }}-composer-
37-
38-
- name: Install dependencies
39-
run: composer install --prefer-dist --no-progress --no-interaction # Use install, add --no-interaction for CI
18+
args: --config=.php_cs.dist.php --allow-risky=yes
4019

41-
# --- IMPORTANT ---
42-
# Choose ONE of the following 'Run PHPCS' steps based on your project setup:
43-
44-
# Option 1: If you have a phpcs.xml or phpcs.xml.dist file in your root
45-
- name: Run PHPCS (using config file)
46-
run: vendor/bin/phpcs --standard=phpcs.xml.dist # Or phpcs.xml if that's your filename
47-
# Optional: Specify paths explicitly if needed:
48-
# run: vendor/bin/phpcs --standard=phpcs.xml.dist ./src ./tests
49-
50-
# Option 2: If you DON'T have a config file and want to use a standard (e.g., PSR12)
51-
# - name: Run PHPCS (using PSR12 standard)
52-
# run: vendor/bin/phpcs --standard=PSR12 ./src ./tests # Adjust paths (./src ./tests) as needed!
53-
54-
# Option 3: Most basic run (relies heavily on defaults - least recommended)
55-
# - name: Run PHPCS (basic)
56-
# run: vendor/bin/phpcs
20+
- name: Commit changes
21+
uses: stefanzweifel/git-auto-commit-action@v5
22+
with:
23+
commit_message: Fix styling

.php_cs.dist.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->in([
5+
__DIR__ . '/src',
6+
__DIR__ . '/tests',
7+
])
8+
->name('*.php')
9+
->notName('*.blade.php')
10+
->ignoreDotFiles(true)
11+
->ignoreVCS(true);
12+
13+
return (new PhpCsFixer\Config())
14+
->setRules([
15+
'@PSR2' => true,
16+
'array_syntax' => ['syntax' => 'short'],
17+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
18+
'no_unused_imports' => true,
19+
'not_operator_with_successor_space' => true,
20+
'trailing_comma_in_multiline' => true,
21+
'phpdoc_scalar' => true,
22+
'unary_operator_spaces' => true,
23+
'binary_operator_spaces' => true,
24+
'blank_line_before_statement' => [
25+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
26+
],
27+
'phpdoc_single_line_var_spacing' => true,
28+
'phpdoc_var_without_name' => true,
29+
'class_attributes_separation' => [
30+
'elements' => [
31+
'method' => 'one',
32+
],
33+
],
34+
'method_argument_space' => [
35+
'on_multiline' => 'ensure_fully_multiline',
36+
'keep_multiple_spaces_after_comma' => true,
37+
],
38+
'single_trait_insert_per_statement' => true,
39+
])
40+
->setFinder($finder);

0 commit comments

Comments
 (0)