Skip to content

Commit 889f092

Browse files
committed
Add CI for PHP 8.3, update PHP-CS-Fixer config, enhance documentation
1 parent d7ae7ce commit 889f092

31 files changed

Lines changed: 1881 additions & 347 deletions

.github/workflows/ci.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, "*.x", "feat/*", "fix/*"]
6+
pull_request:
7+
branches: [main, "*.x"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
validate:
14+
name: composer validate
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: "8.1"
21+
coverage: none
22+
tools: composer:v2
23+
- run: composer validate --strict
24+
25+
cs:
26+
name: Coding style (PHP-CS-Fixer)
27+
runs-on: ubuntu-latest
28+
needs: validate
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: "8.1"
34+
coverage: none
35+
tools: composer:v2
36+
- name: Install dependencies
37+
run: composer install --prefer-dist --no-progress --no-interaction
38+
- name: Check coding standards
39+
run: composer cs-check
40+
41+
stan:
42+
name: Static analysis (PHPStan)
43+
runs-on: ubuntu-latest
44+
needs: validate
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: shivammathur/setup-php@v2
48+
with:
49+
php-version: "8.3"
50+
coverage: none
51+
tools: composer:v2
52+
- name: Install dependencies
53+
run: composer install --prefer-dist --no-progress --no-interaction
54+
- name: Run PHPStan
55+
run: composer stan
56+
57+
tests:
58+
name: PHPUnit (PHP ${{ matrix.php }}, ${{ matrix.deps }})
59+
runs-on: ubuntu-latest
60+
needs: validate
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
php: ["8.1", "8.2", "8.3", "8.4"]
65+
deps: ["highest"]
66+
include:
67+
- php: "8.1"
68+
deps: "lowest"
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
- name: Set up PHP ${{ matrix.php }}
73+
uses: shivammathur/setup-php@v2
74+
with:
75+
php-version: ${{ matrix.php }}
76+
coverage: none
77+
tools: composer:v2
78+
79+
- name: Get composer cache directory
80+
id: composer-cache
81+
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
82+
83+
- name: Cache composer dependencies
84+
uses: actions/cache@v4
85+
with:
86+
path: ${{ steps.composer-cache.outputs.dir }}
87+
key: composer-${{ matrix.php }}-${{ matrix.deps }}-${{ hashFiles('**/composer.json') }}
88+
restore-keys: composer-${{ matrix.php }}-${{ matrix.deps }}-
89+
90+
- name: Install highest dependencies
91+
if: matrix.deps == 'highest'
92+
run: composer update --prefer-dist --no-progress --no-interaction
93+
94+
- name: Install lowest dependencies
95+
if: matrix.deps == 'lowest'
96+
run: composer update --prefer-dist --no-progress --no-interaction --prefer-lowest --prefer-stable
97+
98+
- name: Run PHPUnit
99+
run: composer test
100+
101+
coverage:
102+
name: Coverage
103+
runs-on: ubuntu-latest
104+
needs: tests
105+
steps:
106+
- uses: actions/checkout@v4
107+
108+
- name: Set up PHP
109+
uses: shivammathur/setup-php@v2
110+
with:
111+
php-version: "8.3"
112+
coverage: pcov
113+
tools: composer:v2
114+
115+
- name: Install dependencies
116+
run: composer install --prefer-dist --no-progress --no-interaction
117+
118+
- name: Run PHPUnit with coverage
119+
run: vendor/bin/phpunit --coverage-clover=coverage.xml
120+
121+
- name: Upload coverage to Codecov
122+
uses: codecov/codecov-action@v5
123+
with:
124+
files: ./coverage.xml
125+
flags: phpunit
126+
fail_ci_if_error: false

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@
33
/.vscode/
44
/vendor/
55
/composer.lock
6-
/.phpunit.result.cache
6+
/build/
7+
/phpunit.xml
8+
/.phpunit.cache/
9+
/.phpunit.result.cache
10+
/.php-cs-fixer.cache
11+
/.php-cs-fixer.php

.php-cs-fixer.dist.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$finder = PhpCsFixer\Finder::create()
6+
->in([__DIR__ . '/src', __DIR__ . '/tests'])
7+
->name('*.php')
8+
->exclude(['Unit/FileLanguages', 'Unit/DirLanguages', 'Unit/Fixtures']);
9+
10+
return (new PhpCsFixer\Config())
11+
->setRiskyAllowed(true)
12+
->setRules([
13+
'@PSR12' => true,
14+
'@PSR12:risky' => true,
15+
'@PHP81Migration' => true,
16+
'array_syntax' => ['syntax' => 'short'],
17+
'declare_strict_types' => true,
18+
'native_function_invocation' => [
19+
'include' => ['@compiler_optimized'],
20+
'scope' => 'namespaced',
21+
'strict' => true,
22+
],
23+
'no_unused_imports' => true,
24+
'ordered_imports' => [
25+
'imports_order' => ['class', 'function', 'const'],
26+
'sort_algorithm' => 'alpha',
27+
],
28+
'single_quote' => true,
29+
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
30+
])
31+
->setFinder($finder)
32+
->setCacheFile(__DIR__ . '/build/php-cs-fixer.cache');

0 commit comments

Comments
 (0)