Skip to content

Commit 0789633

Browse files
committed
chore: require PHP 8.2, adopt Mago for quality checks, and refactor codebase
1 parent 0d21ec8 commit 0789633

26 files changed

Lines changed: 3650 additions & 2166 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 & 17 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,12 +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 --config-set ignore_non_auto_fixable_on_exit 1
141-
./vendor/bin/phpcbf --ignore="\./vendor/" --standard=psr12 src test
142-
143134
## Build a DEB package for Debian-like Linux distributions
144135
.PHONY: deb
145136
deb:
@@ -172,8 +163,7 @@ endif
172163
deps: ensuretarget
173164
rm -rf ./vendor/*
174165
($(COMPOSER) install -vvv --no-interaction)
175-
curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/${PHPSTANVER}/phpstan.phar \
176-
&& 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
177167

178168
## Generate source code documentation
179169
.PHONY: doc
@@ -210,13 +200,18 @@ ifneq ($(strip $(CONFIGPATH)),)
210200
find $(PATHINSTCFG) -type f -exec chmod 644 {} \;
211201
endif
212202

213-
## 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
214209
.PHONY: lint
215210
lint:
216-
./vendor/bin/phpcs --standard=phpcs.xml
217-
./vendor/bin/phpmd src text codesize,unusedcode,naming,design --exclude */vendor/*
218-
./vendor/bin/phpmd test text unusedcode,naming,design --exclude */vendor/*
219-
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
220215

221216
## Run all tests and reports
222217
.PHONY: qa

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ It exposes the primitives needed to compose paths and painting operations while
4646

4747
## Requirements
4848

49-
- PHP 8.1 or later
49+
- PHP 8.2 or later
5050
- Extension: `zlib`
5151
- Composer
5252

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.24
1+
2.5.0

composer.json

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

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 = true, volume-threshold = 2500.0, difficulty-threshold = 30.0, effort-threshold = 42000.0 }
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.

0 commit comments

Comments
 (0)