Skip to content

Commit 7bb6534

Browse files
committed
Add Blade and Twig engine support, update composer.json, add CI workflow
1 parent c80aae6 commit 7bb6534

41 files changed

Lines changed: 3210 additions & 725 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Exclude development-only files from Composer dist tarballs.
2+
/.github export-ignore
3+
/.gitattributes export-ignore
4+
/.gitignore export-ignore
5+
/.php-cs-fixer.dist.php export-ignore
6+
/.phpunit.cache export-ignore
7+
/docs export-ignore
8+
/tests export-ignore
9+
/phpstan.neon.dist export-ignore
10+
/phpunit.xml.dist export-ignore

.github/workflows/ci.yml

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

.gitignore

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
/.idea/
2-
/.vscode/
3-
/composer.lock
4-
/vendor/
1+
/.idea/
2+
/.vs/
3+
/.vscode/
4+
/vendor/
5+
/composer.lock
6+
/build/
7+
/.phpunit.cache/
8+
/.phpunit.result.cache
9+
/.php-cs-fixer.cache

.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+
9+
return (new PhpCsFixer\Config())
10+
->setRiskyAllowed(true)
11+
->setRules([
12+
'@PSR12' => true,
13+
'@PSR12:risky' => true,
14+
'@PHP80Migration' => true,
15+
'@PHP80Migration:risky' => 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)