Skip to content

Commit fbc2247

Browse files
committed
Integrate Fluent, FluentGen and FluentAnalysis
Replace the internal code generation and builder infrastructure with Respect/Fluent for runtime method resolution, Respect/FluentGen for mixin interface generation, and Respect/FluentAnalysis for PHPStan type narrowing. ValidatorBuilder now extends Fluent's Append builder with ComposableMap for prefix composition at runtime. Each validator is annotated with: - #[Assurance] declaring the type it narrows to (100+ validators) - #[AssuranceParameter] on constructor params used for dynamic type resolution (Instance) - #[Composable] with class-string references for prefix composition constraints (Not, All, Key, Property, NullOr, UndefOr, Min, Max, Length, and 29 validators with with/without constraints) - #[ComposableParameter] on promoted prefix parameters (Key, Property) Removes the internal CodeGen infrastructure (MethodBuilder, MixinGenerator, PrefixMapGenerator, etc.) in favor of FluentGen. Adds type inference tests validating PHPStan narrowing for type validators, val variants, composites (allOf, anyOf, oneOf, noneOf, when), modifiers (not, nullOr, undefOr), element narrowing (each, all), value/member narrowing (identical, in), parameter narrowing (instance), and chain intersection.
1 parent ab992b4 commit fbc2247

186 files changed

Lines changed: 1332 additions & 1542 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
@@ -56,4 +56,5 @@ jobs:
5656

5757
- run: composer phpcs
5858
- run: composer phpstan
59+
- run: composer inference
5960
- run: bin/console lint:mixin

REUSE.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version = 1
22

33
[[annotations]]
4-
path = [ "*.yml", "*.yaml", ".git*", "*.dist", "docs/.pages", "docs/validators/.pages", "composer.json", "composer.lock", "tests/fixtures/*", ".github/*.yml", ".github/actions/**.yml", ".github/workflows/**.yml", ".github/PULL_REQUEST_TEMPLATE.md", ".github/ISSUE_TEMPLATE/**" ]
4+
path = [ "fluent.neon", "*.yml", "*.yaml", ".git*", "*.dist", "docs/.pages", "docs/validators/.pages", "composer.json", "composer.lock", "tests/fixtures/*", ".github/*.yml", ".github/actions/**.yml", ".github/workflows/**.yml", ".github/PULL_REQUEST_TEMPLATE.md", ".github/ISSUE_TEMPLATE/**" ]
55
SPDX-FileCopyrightText = "Respect Project Contributors"
66
SPDX-License-Identifier = "MIT"

composer.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"php": ">=8.5",
2424
"php-di/php-di": "^7.1",
2525
"psr/container": "^2.0",
26+
"respect/fluent": "^2.0",
2627
"respect/string-formatter": "^1.7",
2728
"respect/stringifier": "^3.0",
2829
"symfony/polyfill-intl-idn": "^1.33",
@@ -36,13 +37,15 @@
3637
"pestphp/pest": "^4.2",
3738
"phpbench/phpbench": "^1.4",
3839
"phpstan/extension-installer": "^1.4",
39-
"phpstan/phpstan": "^2.0",
40+
"phpstan/phpstan": "^2.1",
4041
"phpstan/phpstan-deprecation-rules": "^2.0",
4142
"phpstan/phpstan-phpunit": "^2.0",
4243
"phpunit/phpunit": "^12.5",
4344
"psr/http-message": "^1.0 || ^2.0",
4445
"ramsey/uuid": "^4",
4546
"respect/coding-standard": "^5.0",
47+
"respect/fluent-analysis": "^2.0",
48+
"respect/fluentgen": "^2.0",
4649
"sebastian/diff": "^7.0",
4750
"sokil/php-isocodes": "^4.2.1",
4851
"sokil/php-isocodes-db-only": "^4.0",
@@ -61,6 +64,11 @@
6164
"sokil/php-isocodes": "Enable rules that validate ISO codes",
6265
"sokil/php-isocodes-db-only": "Enable rules that validate ISO codes"
6366
},
67+
"extra": {
68+
"phpstan": {
69+
"includes": ["fluent.neon"]
70+
}
71+
},
6472
"autoload": {
6573
"psr-4": {
6674
"Respect\\Validation\\": "src/"
@@ -71,7 +79,8 @@
7179
"psr-4": {
7280
"Respect\\Dev\\": "src-dev/",
7381
"Respect\\Validation\\": "tests/unit/",
74-
"Respect\\Validation\\Test\\": "tests/src/"
82+
"Respect\\Validation\\Test\\": "tests/src/",
83+
"Respect\\Validation\\Test\\Inference\\": "tests/inference/"
7584
}
7685
},
7786
"scripts": {
@@ -84,6 +93,7 @@
8493
"phpcs": "vendor/bin/phpcs",
8594
"phpstan": "vendor/bin/phpstan analyze",
8695
"phpunit": "vendor/bin/phpunit --testsuite=unit",
96+
"inference": "vendor/bin/phpunit --testsuite=inference",
8797
"smoke-complete": "bin/console smoke-tests:check-complete",
8898
"spdx-lint": "bin/console lint:spdx",
8999
"qa": [
@@ -92,6 +102,7 @@
92102
"@phpstan",
93103
"@phpunit",
94104
"@pest",
105+
"@inference",
95106
"@docs",
96107
"@smoke-complete"
97108
]

0 commit comments

Comments
 (0)