Skip to content

PHPLIB-1844: Support range in PHP doc types#1916

Merged
paulinevos merged 2 commits into
mongodb:v2.xfrom
paulinevos:range-annotations
Jun 8, 2026
Merged

PHPLIB-1844: Support range in PHP doc types#1916
paulinevos merged 2 commits into
mongodb:v2.xfrom
paulinevos:range-annotations

Conversation

@paulinevos

@paulinevos paulinevos commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings June 5, 2026 11:59
@paulinevos paulinevos requested a review from a team as a code owner June 5, 2026 11:59
@paulinevos paulinevos requested a review from GromNaN June 5, 2026 11:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 $numDocsToRerank to int<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/valueMax metadata fields to ArgumentDefinition to 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.

Comment thread generator/src/Definition/ArgumentDefinition.php Outdated
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@paulinevos paulinevos force-pushed the range-annotations branch from 88f24e9 to b2360ba Compare June 5, 2026 13:46

@GromNaN GromNaN left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

Comment thread generator/src/OperatorGenerator.php Outdated
Comment thread generator/src/Definition/ArgumentDefinition.php
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.
@paulinevos paulinevos force-pushed the range-annotations branch from b2360ba to ce876bb Compare June 8, 2026 10:33
Copilot AI review requested due to automatic review settings June 8, 2026 10:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Comment thread generator/src/Definition/ArgumentDefinition.php
@paulinevos paulinevos merged commit b3e3d1b into mongodb:v2.x Jun 8, 2026
36 checks passed
@paulinevos paulinevos deleted the range-annotations branch June 8, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants