Skip to content

Commit 8d4d62f

Browse files
committed
chore: require PHP 8.2, adopt Mago for quality checks, and refactor codebase
1 parent c0e5ca5 commit 8d4d62f

24 files changed

Lines changed: 10666 additions & 10545 deletions

.github/workflows/check.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
php-version: ["8.1", "8.2", "8.3", "8.4", "8.5"]
26+
php-version: ["8.2", "8.3", "8.4", "8.5"]
2727
experimental: [false]
2828
os: [ubuntu-latest]
2929
coverage-extension: [pcov]
@@ -46,6 +46,8 @@ jobs:
4646
path: ~/.composer/cache/
4747
key: composer-cache
4848
- name: Install dependencies
49+
env:
50+
GH_TOKEN: ${{ github.token }}
4951
run: make deps
5052
- name: Run all tests
5153
run: make qa

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Please follow the [Security Policy](SECURITY.md) and report them privately.
4040

4141
### Requirements
4242

43-
- PHP **≥ 8.1**
43+
- PHP **≥ 8.2**
4444
- [Composer](https://getcomposer.org/) v2
4545
- `make`, `git`
4646
- Optional: `rpmbuild` (RPM packaging), `dpkg-buildpackage` (DEB packaging)
@@ -120,8 +120,8 @@ The `Makefile` exposes all common development tasks:
120120
|---------|-------------|
121121
| `make qa` | Run linting, static analysis, tests, and reports |
122122
| `make test` | Run PHPUnit with code coverage |
123-
| `make lint` | Check coding standards (PHPCS, PHPMD, PHPStan) |
124-
| `make codefix` | Auto-fix coding standard violations (PHPCBF) |
123+
| `make lint` | Check coding standards |
124+
| `make format` | Auto-format the code |
125125
| `make buildall` | Install dependencies, fix style, run QA, and build packages |
126126
| `make clean` | Remove `vendor/` and `target/` directories |
127127
| `make server` | Start the built-in PHP development server for the examples |
@@ -133,8 +133,8 @@ Run `make help` to see the full list of available targets.
133133
## Coding Standards
134134

135135
- The codebase follows **PSR-12** for formatting.
136-
- Run `make codefix` to auto-fix style violations before committing.
137-
- Run `make lint` to catch remaining issues (PHPCS, PHPMD, PHPStan).
136+
- Run `make format` to auto-format the code.
137+
- Run `make lint` to catch remaining issues.
138138
- All source files live under `src/`, all tests under `test/`.
139139
- Use strict types and explicit visibility on all class members.
140140
- Avoid introducing new external dependencies without prior discussion.

Makefile

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ COMPOSER=$(PHP) -d "apc.enable_cli=0" $(shell which composer)
9292
# phpDocumentor executable file
9393
PHPDOC=$(shell which phpDocumentor)
9494

95-
# phpstan version
96-
PHPSTANVER=2.1.40
97-
9895
# --- MAKE TARGETS ---
9996

10097
# Display general help about this command
@@ -120,7 +117,7 @@ x: buildall
120117

121118
## Full build and test sequence
122119
.PHONY: buildall
123-
buildall: deps codefix qa bz2 rpm deb
120+
buildall: deps format qa bz2 rpm deb
124121

125122
## Package the library in a compressed bz2 archive
126123
.PHONY: bz2
@@ -134,11 +131,6 @@ bz2:
134131
clean:
135132
rm -rf ./vendor $(TARGETDIR)
136133

137-
## Fix code style violations
138-
.PHONY: codefix
139-
codefix:
140-
./vendor/bin/phpcbf --ignore="\./vendor/" --standard=psr12 src test
141-
142134
## Build a DEB package for Debian-like Linux distributions
143135
.PHONY: deb
144136
deb:
@@ -171,8 +163,7 @@ endif
171163
deps: ensuretarget
172164
rm -rf ./vendor/*
173165
($(COMPOSER) install -vvv --no-interaction)
174-
curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/${PHPSTANVER}/phpstan.phar \
175-
&& chmod +x ./vendor/phpstan.phar
166+
curl --proto '=https' --tlsv1.2 --silent --show-error --fail --location https://carthage.software/mago.sh | bash -s -- --install-dir=./vendor/bin
176167

177168
## Generate source code documentation
178169
.PHONY: doc
@@ -209,13 +200,18 @@ ifneq ($(strip $(CONFIGPATH)),)
209200
find $(PATHINSTCFG) -type f -exec chmod 644 {} \;
210201
endif
211202

212-
## Test source code for coding standard violations
203+
## Format the source code
204+
.PHONY: format
205+
format:
206+
./vendor/bin/mago fmt src test
207+
208+
## Analyze and Lint the source code
213209
.PHONY: lint
214210
lint:
215-
./vendor/bin/phpcs --standard=phpcs.xml
216-
./vendor/bin/phpmd src text codesize,unusedcode,naming,design --exclude */vendor/*
217-
./vendor/bin/phpmd test text unusedcode,naming,design --exclude */vendor/*
218-
php -r 'exit((int)version_compare(PHP_MAJOR_VERSION, "7", ">"));' || ./vendor/phpstan.phar analyse
211+
./vendor/bin/mago --config ./mago.src.toml analyze src
212+
./vendor/bin/mago --config ./mago.test.toml analyze test
213+
./vendor/bin/mago --config ./mago.src.toml lint src
214+
./vendor/bin/mago --config ./mago.test.toml lint test
219215

220216
## Run all tests and reports
221217
.PHONY: qa

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ It externalizes large Unicode datasets into a dedicated package so runtime libra
4646

4747
## Requirements
4848

49-
- PHP 8.1 or later
49+
- PHP 8.2 or later
5050
- Composer
5151

5252
---

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.53
1+
2.1.0

composer.json

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
11
{
2-
"name": "tecnickcom/tc-lib-unicode-data",
3-
"description": "PHP library containing Unicode definitions",
4-
"type": "library",
5-
"homepage": "https://tcpdf.org",
6-
"license": "LGPL-3.0-or-later",
7-
"keywords": [
8-
"tc-lib-unicode-data",
9-
"PDF",
10-
"font",
11-
"UTF-8",
12-
"Unicode"
13-
],
14-
"authors": [
15-
{
16-
"name": "Nicola Asuni",
17-
"email": "info@tecnick.com",
18-
"role": "lead"
2+
"name": "tecnickcom/tc-lib-unicode-data",
3+
"description": "PHP library containing Unicode definitions",
4+
"type": "library",
5+
"homepage": "https://tcpdf.org",
6+
"license": "LGPL-3.0-or-later",
7+
"keywords": [
8+
"tc-lib-unicode-data",
9+
"PDF",
10+
"font",
11+
"UTF-8",
12+
"Unicode"
13+
],
14+
"authors": [
15+
{
16+
"name": "Nicola Asuni",
17+
"email": "info@tecnick.com",
18+
"role": "lead"
19+
}
20+
],
21+
"funding": [
22+
{
23+
"type": "github",
24+
"url": "https://github.com/sponsors/tecnickcom"
25+
}
26+
],
27+
"require": {
28+
"php": ">=8.1"
29+
},
30+
"minimum-stability": "dev",
31+
"prefer-stable": true,
32+
"config": {
33+
"allow-plugins": {
34+
"dealerdirect/phpcodesniffer-composer-installer": true
35+
}
36+
},
37+
"require-dev": {
38+
"pdepend/pdepend": "^2.16",
39+
"phpunit/phpunit": "^13.1 || ^12.5 || ^11.5",
40+
"phpcompatibility/php-compatibility": "^10.0.0@dev"
41+
},
42+
"autoload": {
43+
"psr-4": {
44+
"Com\\Tecnick\\Unicode\\Data\\": "src"
45+
}
46+
},
47+
"autoload-dev": {
48+
"psr-4": {
49+
"Test\\": "test"
50+
}
51+
},
52+
"support": {
53+
"issues": "https://github.com/tecnickcom/tc-lib-unicode-data/issues",
54+
"source": "https://github.com/tecnickcom/tc-lib-unicode-data"
55+
},
56+
"scripts": {
57+
"test": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --stderr test",
58+
"cs-check": "./vendor/bin/mago --config ./mago.src.toml lint src && ./vendor/bin/mago --config ./mago.test.toml lint test",
59+
"cs-fix": "./vendor/bin/mago fmt src test",
60+
"analyse": "./vendor/bin/mago --config ./mago.src.toml analyze src && ./vendor/bin/mago --config ./mago.test.toml analyze test"
1961
}
20-
],
21-
"funding": [
22-
{
23-
"type": "github",
24-
"url": "https://github.com/sponsors/tecnickcom"
25-
}
26-
],
27-
"require": {
28-
"php": ">=8.1"
29-
},
30-
"minimum-stability": "dev",
31-
"prefer-stable": true,
32-
"config": {
33-
"allow-plugins": {
34-
"dealerdirect/phpcodesniffer-composer-installer": true
35-
}
36-
},
37-
"require-dev": {
38-
"pdepend/pdepend": "^2.16",
39-
"phpmd/phpmd": "^2.15",
40-
"phpunit/phpunit": "^13.1 || ^12.5 || ^11.5 || ^10.5",
41-
"squizlabs/php_codesniffer": "^4.0",
42-
"phpcompatibility/php-compatibility": "^10.0.0@dev"
43-
},
44-
"autoload": {
45-
"psr-4": {
46-
"Com\\Tecnick\\Unicode\\Data\\": "src"
47-
}
48-
},
49-
"autoload-dev": {
50-
"psr-4": { "Test\\": "test" }
51-
},
52-
"support": {
53-
"issues": "https://github.com/tecnickcom/tc-lib-unicode-data/issues",
54-
"source": "https://github.com/tecnickcom/tc-lib-unicode-data"
55-
},
56-
"scripts": {
57-
"test": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --stderr test",
58-
"cs-check": "./vendor/bin/phpcs --standard=phpcs.xml",
59-
"cs-fix": "./vendor/bin/phpcbf --ignore=\"./vendor/\" --standard=psr12 src test",
60-
"analyse": "./vendor/phpstan.phar analyse"
61-
}
6262
}

mago.src.toml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#:schema https://mago.carthage.software/1.26.0/schema.json
2+
version = "1"
3+
php-version = "8.2.0"
4+
5+
[source]
6+
workspace = "."
7+
paths = ["src"]
8+
includes = ["vendor"]
9+
excludes = []
10+
11+
[source.glob]
12+
literal-separator = true
13+
14+
[formatter]
15+
print-width = 120
16+
tab-width = 4
17+
use-tabs = false
18+
19+
[linter]
20+
integrations = []
21+
22+
[linter.rules]
23+
ambiguous-function-call = { enabled = false }
24+
literal-named-argument = { enabled = false }
25+
cyclomatic-complexity = { enabled = false }
26+
excessive-parameter-list = { enabled = true }
27+
halstead = { enabled = true, effort-threshold = 7000 }
28+
identity-comparison = { enabled = true }
29+
kan-defect = { enabled = false }
30+
no-boolean-flag-parameter = { enabled = false }
31+
no-else-clause = { enabled = false }
32+
no-empty = { enabled = true }
33+
too-many-methods = { enabled = false }
34+
no-isset = { enabled = true, allow-array-checks = true }
35+
36+
[analyzer]
37+
plugins = []
38+
find-unused-definitions = true
39+
find-unused-expressions = true
40+
analyze-dead-code = true
41+
memoize-properties = true
42+
check-throws = true
43+
unchecked-exceptions = [
44+
"Error",
45+
"LogicException",
46+
"ReflectionException",
47+
]
48+
unchecked-exception-classes = []
49+
check-missing-override = true
50+
find-unused-parameters = true
51+
strict-list-index-checks = true
52+
strict-array-index-existence = true
53+
allow-array-truthy-operand = false
54+
no-boolean-literal-comparison = true
55+
check-missing-type-hints = true
56+
register-super-globals = true

mago.test.toml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#:schema https://mago.carthage.software/1.26.0/schema.json
2+
version = "1"
3+
php-version = "8.2.0"
4+
5+
[source]
6+
workspace = "."
7+
paths = ["src", "test"]
8+
includes = ["vendor"]
9+
excludes = []
10+
11+
[source.glob]
12+
literal-separator = true
13+
14+
[formatter]
15+
print-width = 120
16+
tab-width = 4
17+
use-tabs = false
18+
19+
[linter]
20+
integrations = ["phpunit"]
21+
22+
[linter.rules]
23+
ambiguous-function-call = { enabled = false }
24+
literal-named-argument = { enabled = false }
25+
assertion-style = { enabled = false }
26+
cyclomatic-complexity = { enabled = false }
27+
excessive-parameter-list = { enabled = false }
28+
halstead = { enabled = false, effort-threshold = 7000 }
29+
identity-comparison = { enabled = false }
30+
kan-defect = { enabled = false }
31+
no-boolean-flag-parameter = { enabled = false }
32+
no-else-clause = { enabled = false }
33+
no-empty = { enabled = false }
34+
no-empty-catch-clause = { enabled = false }
35+
no-isset = { enabled = false }
36+
readable-literal = { enabled = false }
37+
str-contains = { enabled = false }
38+
strict-assertions = { enabled = false }
39+
strict-behavior = { enabled = false }
40+
strict-types = { enabled = false }
41+
too-many-methods = { enabled = false }
42+
43+
[analyzer]
44+
plugins = []
45+
find-unused-definitions = true
46+
find-unused-expressions = true
47+
analyze-dead-code = true
48+
memoize-properties = true
49+
check-throws = true
50+
unchecked-exceptions = [
51+
"Error",
52+
"LogicException",
53+
"ReflectionException",
54+
"PHPUnit\\Framework\\Exception",
55+
"PHPUnit\\Framework\\ExpectationFailedException",
56+
"PHPUnit\\Framework\\UnknownClassOrInterfaceException",
57+
]
58+
unchecked-exception-classes = []
59+
check-missing-override = true
60+
find-unused-parameters = true
61+
strict-list-index-checks = true
62+
strict-array-index-existence = true
63+
allow-array-truthy-operand = false
64+
no-boolean-literal-comparison = true
65+
check-missing-type-hints = true
66+
register-super-globals = true

phpcs.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

phpstan.neon

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)