PHPLIB-1771: Add arrayIndexAs support for $filter and $reduce operators#1936
Merged
Conversation
…tors Adds the new MongoDB 8.3 parameters to \$filter (arrayIndexAs) and \$reduce (as, valueAs, arrayIndexAs), including tests and generator fix for commas in test names.
arrayIndexAs support for $filter and $reduce operators
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support in the aggregation expression builder for MongoDB 8.3’s new variable customization/index-exposure parameters on $filter and $reduce, and updates the spec-test generator to handle new comma-containing test names.
Changes:
- Added
$filter.arrayIndexAssupport in the expression builder and added a corresponding pipeline test. - Added
$reduce.as,$reduce.valueAs, and$reduce.arrayIndexAssupport in the expression builder and added a corresponding pipeline test. - Updated the operator test generator to strip commas from generated PHPUnit test/case names.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Builder/Expression/ReduceOperatorTest.php | Adds a new reduce test exercising as, valueAs, and arrayIndexAs. |
| tests/Builder/Expression/Pipelines.php | Adds expected Extended JSON pipelines for the new $filter and $reduce examples. |
| tests/Builder/Expression/FilterOperatorTest.php | Adds a new filter test exercising arrayIndexAs. |
| src/Builder/Expression/ReduceOperator.php | Adds new optional properties/constructor params for $reduce (8.3). |
| src/Builder/Expression/FilterOperator.php | Adds new optional arrayIndexAs support for $filter (8.3). |
| src/Builder/Expression/FactoryTrait.php | Exposes new parameters via Expression::filter() and Expression::reduce(). |
| generator/src/OperatorTestGenerator.php | Sanitizes generated test names by stripping commas. |
This was referenced Jul 3, 2026
Open
paulinevos
approved these changes
Jul 7, 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.
Implements the new MongoDB 8.3 parameters added in mongodb/mql-specifications#54, completing the work started in PHPLIB-1771:
$filter: addsarrayIndexAsparameter to expose the current element's index in thecondexpression$reduce: addsas,valueAs, andarrayIndexAsparameters to customize variable names and expose the element index in theinexpressionAlso fixes the test name generator to strip commas from test case names (needed for the new spec test names).