Skip to content

Commit 0d0fbba

Browse files
authored
Merge pull request #95 from WalterWoshid/chore/mago-quality
Add Mago 1.47.4 quality checks without a baseline
2 parents 0c32b5a + cad5cb8 commit 0d0fbba

226 files changed

Lines changed: 2811 additions & 2439 deletions

File tree

Some content is hidden

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

‎.github/workflows/tests.yml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ permissions:
1919
contents: read
2020

2121
jobs:
22+
quality:
23+
name: Mago formatter, linter and analyzer
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 10
26+
steps:
27+
- uses: actions/checkout@v3
28+
- uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: '8.2'
31+
coverage: none
32+
- name: Install development dependencies
33+
run: composer install --prefer-dist --no-progress --no-interaction
34+
- name: Run formatter, linter and analyzer without a baseline
35+
run: composer check
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
2239
run:
2340
runs-on: ${{ matrix.operating-system }}
2441

‎MAGO.md‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Mago checks
2+
3+
Install development dependencies with `composer install`, then run:
4+
5+
```sh
6+
composer check # formatting, linter, analyzer for source and tests
7+
composer format # apply formatting
8+
composer lint
9+
composer analyze
10+
```
11+
12+
Mago is pinned to **1.47.4**, the newest published version verified for this upgrade.
13+
Update the pin deliberately and run the full checks before upgrading. Composer installs the
14+
platform-specific launcher; its first invocation downloads the matching binary.
15+
CI provides `GITHUB_TOKEN` for that download. Scripts invoke the project-local PHP
16+
launcher explicitly so an older system-wide binary cannot be used accidentally.
17+
There is no baseline.
18+
19+
The formatter, linter, and analyzer have been run successfully with 1.47.4 against
20+
both configurations. On Windows, the Composer launcher needs PHP's ZIP extension
21+
and a configured trusted CA certificate bundle to download and extract its binary.
22+
23+
`mago.toml` targets PHP 8.1 for library code. `mago-tests.toml` targets PHP 8.2 because
24+
some fixtures intentionally exercise readonly classes and traits; PHPUnit skips
25+
the applicable tests on PHP 8.1. Both configurations read dependency declarations
26+
without checking vendor code. Generated AOP cache and coverage files are excluded.
27+
28+
The linter uses its default correctness, consistency, and maintainability checks.
29+
Exceptions in configuration are explicit design choices: mandatory strict types
30+
would change coercion behavior; named arguments and boolean flags are existing API
31+
choices; `isset` intentionally distinguishes null; aggregate complexity metrics
32+
are left to review. Analyzer missing-type checks are enabled. CI fails on all
33+
reported severities. No analyzer issue codes are ignored globally.
34+
35+
The vendor type patch in `tools/mago/patches/CodeTransformerKernel.php` models its
36+
dependency injection callback as a generic extension point. The default remains
37+
the original one-argument callback returning a Transformer. AopKernel specializes
38+
it to its established two-argument callback returning an aspect or transformer.
39+
This replaces the previous callback suppression without changing runtime code or
40+
loosening TransformerManager's contract. `composer check-mago-types` checks valid
41+
callbacks and rejects scalar returns and incorrect default transformer callbacks.
42+
It runs as part of `composer check`, including in CI. Its deliberately invalid
43+
fixtures live in `tools/mago/tests` and are checked separately from library code.
44+
45+
Two narrow `@mago-expect` annotations still cover four property-access diagnostics.
46+
These are explicit analyzer exceptions, not fixes to the analyzer's limitations:
47+
48+
- Two property-access closures operate on a declaration validated through reflection.
49+
Mago cannot prove a runtime property name exists on the subject. Reference, scope,
50+
uninitialized-property, and unset behavior have runtime regression tests.
51+
52+
These expectations name individual diagnostics at the affected operations. Mago
53+
reports an unfulfilled expectation if a future release stops producing a diagnostic,
54+
so stale exceptions fail CI. No baseline, file exclusions for these operations, or
55+
global analyzer diagnostic suppressions are used.
56+
57+
An extension experiment confirmed that Mago 1.47.4 does not dispatch property type
58+
providers for these unresolved runtime operations. The experiment was discarded;
59+
no custom extension or issue filter is installed.
60+
61+
Performance fixture generation now uses a shared service interface and validates
62+
generated service instantiation through reflection. Its construction work is part
63+
of the class-loading measurement; compare loading results only against runs using
64+
the same harness. The timed method-execution loop is unchanged.

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,8 @@ $firstLog = $logs[0];
759759

760760

761761
## Testing
762+
763+
Development quality checks: see [Mago setup and commands](MAGO.md).
762764
- Run `composer run-script test`<br>
763765
or
764766
- Run `composer run-script test-coverage`

‎composer.json‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
"scripts": {
2121
"test": "phpunit --testsuite=Tests --display-notices",
2222
"test-performance": "phpunit --testsuite=Performance --display-notices",
23-
"test-coverage": "phpunit --testsuite=Tests --coverage-html tests/coverage --display-notices"
23+
"test-coverage": "phpunit --testsuite=Tests --coverage-html tests/coverage --display-notices",
24+
"format": ["@php vendor/bin/mago format", "@php vendor/bin/mago --config mago-tests.toml format"],
25+
"format-check": ["@php vendor/bin/mago format --check", "@php vendor/bin/mago --config mago-tests.toml format --check"],
26+
"lint": ["@php vendor/bin/mago lint --minimum-fail-level note", "@php vendor/bin/mago --config mago-tests.toml lint --minimum-fail-level note"],
27+
"analyze": ["@php vendor/bin/mago analyze --minimum-fail-level note", "@php vendor/bin/mago --config mago-tests.toml analyze --minimum-fail-level note"],
28+
"check-mago-types": "@php tools/mago/check.php",
29+
"check": ["@format-check", "@lint", "@analyze", "@check-mago-types"]
2430
},
2531
"require": {
2632
"php": ">=8.1",
@@ -30,7 +36,8 @@
3036
"okapi/singleton": "^1.0",
3137
"php-di/php-di": "^7.0"
3238
},
33-
"require-dev": {
39+
"require-dev": {
40+
"carthage-software/mago": "1.47.4",
3441
"phpunit/phpunit": "^10.3",
3542
"symfony/var-dumper": "^6.3",
3643
"symfony/console": "^6.3"

‎mago-tests.toml‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
php-version = "8.2"
2+
3+
[source]
4+
paths = ["tests"]
5+
includes = ["src", "vendor"]
6+
patches = ["tools/mago/patches"]
7+
excludes = ["tests/cache", "tests/coverage"]
8+
9+
[linter]
10+
integrations = ["phpunit"]
11+
12+
# Preserve the library's coercion contract and existing public call signatures.
13+
[linter.rules.strict-types]
14+
enabled = false
15+
[linter.rules.literal-named-argument]
16+
enabled = false
17+
[linter.rules.no-boolean-flag-parameter]
18+
enabled = false
19+
# isset intentionally distinguishes null from a usable value throughout this code.
20+
[linter.rules.no-isset]
21+
enabled = false
22+
# Complexity metrics are review aids, not correctness gates for a weaving engine.
23+
[linter.rules.halstead]
24+
enabled = false
25+
[linter.rules.kan-defect]
26+
enabled = false
27+
[linter.rules.cyclomatic-complexity]
28+
enabled = false
29+
[linter.rules.too-many-methods]
30+
enabled = false
31+
[linter.rules.excessive-parameter-list]
32+
threshold = 10
33+
34+
[analyzer]
35+
check-missing-type-hints = true

‎mago.toml‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
php-version = "8.1"
2+
3+
[source]
4+
paths = ["src", "tools/mago/check.php"]
5+
includes = ["vendor"]
6+
patches = ["tools/mago/patches"]
7+
excludes = ["tests/cache", "tests/coverage"]
8+
9+
[linter]
10+
integrations = ["phpunit"]
11+
12+
# Preserve the library's coercion contract and existing public call signatures.
13+
[linter.rules.strict-types]
14+
enabled = false
15+
[linter.rules.literal-named-argument]
16+
enabled = false
17+
[linter.rules.no-boolean-flag-parameter]
18+
enabled = false
19+
# isset intentionally distinguishes null from a usable value throughout this code.
20+
[linter.rules.no-isset]
21+
enabled = false
22+
# Complexity metrics are review aids, not correctness gates for a weaving engine.
23+
[linter.rules.halstead]
24+
enabled = false
25+
[linter.rules.kan-defect]
26+
enabled = false
27+
[linter.rules.cyclomatic-complexity]
28+
enabled = false
29+
[linter.rules.too-many-methods]
30+
enabled = false
31+
[linter.rules.excessive-parameter-list]
32+
threshold = 10
33+
34+
[analyzer]
35+
check-missing-type-hints = true

‎src/Advice/AdviceType.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ enum AdviceType
1212
case Before;
1313
case Around;
1414
case After;
15-
// TODO: implement
15+
// Reserved for future after-returning advice support.
1616
case AfterReturning;
17-
// TODO: implement
17+
// Reserved for future after-throwing advice support.
1818
case AfterThrowing;
1919
}

0 commit comments

Comments
 (0)