PHPLIB-1844: Support range in PHP doc types#1916
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the code generator and generated stage factories to express integer min/max constraints via Psalm-compatible PHPDoc range types (e.g. int<1, 1000>), improving static analysis precision for bounded integer parameters.
Changes:
- Refines generated PHPDoc for
$numDocsToReranktoint<1, 1000>across the rerank stage class and stage factory APIs. - Extends the generator’s accepted-type resolution to emit
int<min,max>in PHPDoc when argument value bounds are present. - Adds
valueMin/valueMaxmetadata fields toArgumentDefinitionto carry value bounds from YAML definitions into generated docs.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Builder/Stage/RerankStage.php | Updates generated property/constructor PHPDoc to use int<1, 1000> for rerank bounds. |
| src/Builder/Stage/FluentFactoryTrait.php | Updates rerank fluent factory PHPDoc to use int<1, 1000>. |
| src/Builder/Stage/FactoryTrait.php | Updates static stage factory PHPDoc to use int<1, 1000>. |
| generator/src/OperatorGenerator.php | Emits ranged int<min,max> PHPDoc types when value bounds are provided in argument definitions. |
| generator/src/Definition/ArgumentDefinition.php | Adds value-bound metadata fields for generator-driven ranged PHPDoc. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
88f24e9 to
b2360ba
Compare
GromNaN
reviewed
Jun 8, 2026
GromNaN
reviewed
Jun 8, 2026
When a `minValue` or `maxValue` for an argument is provided in the spec, the generator should consume those values and apply a ranged doc type (e.g. `@param int <1,10>`) based on those values.
As the generator now supports generating ranged doc types, rerun the generator so that the rerank stage is doc typed with the correct range as defined in the spec.
b2360ba to
ce876bb
Compare
GromNaN
approved these changes
Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix PHPLIB-1844