Skip to content

Commit 3eb18bc

Browse files
committed
chore: require PHP 8.2, adopt Mago for quality checks, and refactor codebase
1 parent b4c96f0 commit 3eb18bc

39 files changed

Lines changed: 2978 additions & 1962 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: Install fonts
5153
run: cd util && composer install --no-dev --no-interaction && ./bulk_convert.php && cd ..

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 & 21 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
# List of fonts to process
9996
FONTLIST=core pdfa cid0 freefont unifont dejavu noto
10097

@@ -123,7 +120,7 @@ x: buildall
123120

124121
## Full build and test sequence
125122
.PHONY: buildall
126-
buildall: deps codefix fonts qa bz2 rpm deb
123+
buildall: deps format fonts qa bz2 rpm deb
127124

128125
## Package the library in a compressed bz2 archive
129126
.PHONY: bz2
@@ -138,15 +135,6 @@ clean:
138135
rm -rf ./vendor $(TARGETDIR)
139136
cd util && make clean
140137

141-
## Fix code style violations
142-
.PHONY: codefix
143-
codefix:
144-
./vendor/bin/phpcbf --config-set ignore_non_auto_fixable_on_exit 1
145-
./vendor/bin/phpcbf \
146-
--ignore="\./vendor/" \
147-
--standard=psr12 \
148-
src test
149-
150138
## Build a DEB package for Debian-like Linux distributions
151139
.PHONY: deb
152140
deb:
@@ -179,8 +167,7 @@ endif
179167
deps: ensuretarget
180168
rm -rf ./vendor/* $(TARGETDIR)/fonts
181169
($(COMPOSER) install -vvv --no-interaction)
182-
curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/${PHPSTANVER}/phpstan.phar \
183-
&& chmod +x ./vendor/phpstan.phar
170+
curl --proto '=https' --tlsv1.2 --silent --show-error --fail --location https://carthage.software/mago.sh | bash -s -- --install-dir=./vendor/bin
184171
cd util && make deps
185172

186173
## Generate source code documentation
@@ -219,14 +206,18 @@ ifneq ($(strip $(CONFIGPATH)),)
219206
find $(PATHINSTCFG) -type f -exec chmod 644 {} \;
220207
endif
221208

222-
## Test source code for coding standard violations
209+
## Format the source code
210+
.PHONY: format
211+
format:
212+
./vendor/bin/mago fmt src test
213+
214+
## Analyze and Lint the source code
223215
.PHONY: lint
224216
lint:
225-
#./vendor/bin/phpcbf --config-set ignore_non_auto_fixable_on_exit 1
226-
./vendor/bin/phpcs --standard=phpcs.xml
227-
./vendor/bin/phpmd src text codesize,unusedcode,naming,design --exclude vendor
228-
./vendor/bin/phpmd test text unusedcode,naming,design --exclude vendor
229-
php -r 'exit((int)version_compare(PHP_MAJOR_VERSION, "7", ">"));' || ./vendor/phpstan.phar analyse
217+
./vendor/bin/mago --config ./mago.src.toml analyze src
218+
./vendor/bin/mago --config ./mago.test.toml analyze test
219+
./vendor/bin/mago --config ./mago.src.toml lint src
220+
./vendor/bin/mago --config ./mago.test.toml lint test
230221

231222
## Run all tests and reports
232223
.PHONY: qa

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ It bridges static font assets and runtime document composition by handling metri
4646

4747
## Requirements
4848

49-
- PHP 8.1 or later
49+
- PHP 8.2 or later
5050
- Extensions: `json`, `pcre`, `zlib`
5151
- Composer
5252

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.12.0
1+
2.13.0

composer.json

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

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 = false }
27+
halstead = { enabled = false, 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 = false
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 = false
52+
strict-array-index-existence = false
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: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
inline-variable-return = { enabled = false }
31+
kan-defect = { enabled = false }
32+
no-boolean-flag-parameter = { enabled = false }
33+
no-else-clause = { enabled = false }
34+
no-empty = { enabled = false }
35+
no-empty-catch-clause = { enabled = false }
36+
no-isset = { enabled = false }
37+
readable-literal = { enabled = false }
38+
str-contains = { enabled = false }
39+
strict-assertions = { enabled = false }
40+
strict-behavior = { enabled = false }
41+
strict-types = { enabled = false }
42+
too-many-methods = { enabled = false }
43+
44+
[analyzer]
45+
plugins = []
46+
find-unused-definitions = true
47+
find-unused-expressions = true
48+
analyze-dead-code = true
49+
memoize-properties = true
50+
check-throws = true
51+
unchecked-exceptions = [
52+
"Error",
53+
"LogicException",
54+
"ReflectionException",
55+
"PHPUnit\\Framework\\Exception",
56+
"PHPUnit\\Framework\\ExpectationFailedException",
57+
"PHPUnit\\Framework\\UnknownClassOrInterfaceException",
58+
]
59+
unchecked-exception-classes = []
60+
check-missing-override = true
61+
find-unused-parameters = true
62+
strict-list-index-checks = true
63+
strict-array-index-existence = true
64+
allow-array-truthy-operand = false
65+
no-boolean-literal-comparison = true
66+
check-missing-type-hints = true
67+
register-super-globals = true

0 commit comments

Comments
 (0)