Skip to content

Commit a3abe8d

Browse files
authored
Use PHP 8.0 syntax and add CI automation to enforce it (#5)
1 parent 4f69c46 commit a3abe8d

12 files changed

Lines changed: 151 additions & 262 deletions

File tree

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
.gitattributes export-ignore
2020
.gitignore export-ignore
2121
phpcs.xml.dist export-ignore
22-
phpunit.xml export-ignore
22+
phpunit.xml.dist export-ignore
2323
mago.toml export-ignore
2424

2525
# Exclude directories from distribution

.github/workflows/lint-test.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Lint and Test
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-24.04
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
php-version:
14+
- '8.0'
15+
- '8.1'
16+
- '8.2'
17+
- '8.3'
18+
- '8.4'
19+
- '8.5'
20+
name: PHP ${{ matrix.php-version }}
21+
steps:
22+
- uses: actions/checkout@v6
23+
24+
- name: Set up PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php-version }}
28+
coverage: none
29+
tools: composer:v2
30+
31+
- name: Validate composer.json
32+
run: composer validate --strict
33+
34+
- name: Install dependencies
35+
run: composer install
36+
37+
- name: Lint
38+
run: composer lint
39+
40+
- name: Analyze
41+
run: composer analyze
42+
43+
- name: Test
44+
run: composer test

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
#### ignore all dotfiles and dot-dirs, with exceptions
22
.*
33
!.config/
4+
!.github/
45
!.distignore
56
!.dockerignore
67
!.editorconfig
78
!.env.example
89
!.gitattributes
910
!.gitignore
1011

12+
#### local tooling overrides
13+
phpunit.xml
14+
phpstan.neon
15+
1116
#### ignore these patterns
1217
*.bak
1318
*.log

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,16 @@ See [examples](examples):
6363
## Testing
6464

6565
```bash
66-
composer tests
6766
composer lint
6867
composer analyze
68+
composer test
6969
```
70+
71+
Formatting can be applied with:
72+
73+
```bash
74+
composer lint
75+
composer format
76+
```
77+
78+
The project uses a custom PSR-12-derived PHPCS ruleset for coding standards, PHPStan for static analysis, and PHPUnit for tests.

composer.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
"ext-json": "*",
1616
"afragen/wordpress-plugin-readme-parser": "^1.2025.12",
1717
"erusev/parsedown": "^1.7",
18-
"fairpm/did-manager": ">=0.0.5"
18+
"fairpm/did-manager": "^0.0.5"
1919
},
2020
"require-dev": {
21-
"carthage-software/mago": "^1.0.0-rc.12",
2221
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
22+
"phpstan/phpstan": "^1.12",
2323
"phpcompatibility/php-compatibility": "^9.3",
2424
"phpunit/phpunit": "^10.0",
2525
"squizlabs/php_codesniffer": "^3.7",
@@ -36,15 +36,13 @@
3636
}
3737
},
3838
"scripts": {
39-
"analyze": "mago analyze",
40-
"format": "mago format",
41-
"lint": "mago lint",
42-
"detect-min-php": "sh -c 'for v in 5.4 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4; do echo Testing PHP $v...; if docker run --rm -v \"$PWD:/app\" -w /app php:${v}-cli sh -c \"find . -type f -name \\\"*.php\\\" -not -path \\\"*/vendor/*\\\" -print0 | xargs -0 -n1 php -l\" >/dev/null 2>&1; then echo Minimum supported PHP version: $v; exit 0; fi; done; echo No supported PHP version detected; exit 1'",
43-
"tests": "phpunit"
39+
"analyze": "phpstan analyse --memory-limit=1G",
40+
"format": "phpcbf",
41+
"lint": "phpcs",
42+
"test": "phpunit"
4443
},
4544
"config": {
4645
"allow-plugins": {
47-
"carthage-software/mago": true,
4846
"dealerdirect/phpcodesniffer-composer-installer": true
4947
},
5048
"notify-on-install": false,

composer.lock

Lines changed: 62 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)