Commit f46099a
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
- .github/workflows
- src-dev/Commands
- src
- Mixins
- Validators
- tests/inference
- assertions
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | | - | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
48 | | - | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
| |||
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
| 101 | + | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
| |||
0 commit comments