Skip to content

Commit f46099a

Browse files
committed
Add IDE type narrowing to generated validator mixins
Make validator chains narrow types for IDEs and PHPStan without the FluentAnalysis extension, driven entirely by the generated src/Mixins PHPDoc. - Annotate src/Validators with #[Assurance] / #[AssuranceSubject] declaring each rule's assured type. - Regenerate src/Mixins: Chain becomes generic (@template-covariant TSure); static entry methods narrow to Chain<concrete>; assert()/check() carry an unconditional @phpstan-assert TSure. Container rules (key/property/length/ max/min) and the concrete prefix forms (nullOrIntType, keyIntType, allIntType) narrow; argument-wrapping and compose forms stay Chain<mixed> so a raw (non-fluent) Validator argument is still accepted. - isValid() intentionally does not narrow: its only conditional form is a two-way guard, unsound for inexact rules on the false branch. - Add the tests/inference static-narrowing suite (no extension config) and run it in CI; scope the phpstan/phpcs accommodations for generated mixins.
1 parent 5eb3734 commit f46099a

156 files changed

Lines changed: 4052 additions & 246 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/ci-code.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727

2828
- run: composer phpunit
2929
- run: composer pest
30+
- run: composer inference
3031

3132
code-coverage:
3233
name: Code Coverage

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"type": "library",
66
"homepage": "http://respect.github.io/",
77
"license": "MIT",
8+
"minimum-stability": "dev",
9+
"prefer-stable": true,
810
"authors": [
911
{
1012
"name": "Respect/Validation Contributors",
@@ -23,7 +25,7 @@
2325
"php": ">=8.5",
2426
"psr/container": "^2.0",
2527
"respect/config": "^3.0",
26-
"respect/fluent": "^2.0",
28+
"respect/fluent": "^3.0",
2729
"respect/parameter": "^3.0",
2830
"respect/string-formatter": "^1.7",
2931
"respect/stringifier": "^3.0",
@@ -45,7 +47,7 @@
4547
"psr/http-message": "^1.0 || ^2.0",
4648
"ramsey/uuid": "^4",
4749
"respect/coding-standard": "^5.0",
48-
"respect/fluentgen": "^2.0",
50+
"respect/fluentgen": "^2.1",
4951
"sebastian/diff": "^7.0",
5052
"sokil/php-isocodes": "^4.2.1",
5153
"sokil/php-isocodes-db-only": "^4.0",
@@ -87,6 +89,7 @@
8789
"phpcs": "vendor/bin/phpcs",
8890
"phpstan": "vendor/bin/phpstan analyze",
8991
"phpunit": "vendor/bin/phpunit --testsuite=unit",
92+
"inference": "vendor/bin/phpunit --testsuite=inference",
9093
"smoke-complete": "bin/console smoke-tests:check-complete",
9194
"spdx-lint": "bin/console lint:spdx",
9295
"qa": [
@@ -95,6 +98,7 @@
9598
"@phpstan",
9699
"@phpunit",
97100
"@pest",
101+
"@inference",
98102
"@docs",
99103
"@smoke-complete"
100104
]

0 commit comments

Comments
 (0)