Skip to content

PHPLIB-1798 Extract MQL definition into a submodule for builder generator#1851

Merged
GromNaN merged 22 commits intomongodb:v2.xfrom
GromNaN:PHPLIB-1798
Mar 12, 2026
Merged

PHPLIB-1798 Extract MQL definition into a submodule for builder generator#1851
GromNaN merged 22 commits intomongodb:v2.xfrom
GromNaN:PHPLIB-1798

Conversation

@GromNaN
Copy link
Copy Markdown
Member

@GromNaN GromNaN commented Feb 26, 2026

Note

This PR stay in draft while we work on the instable mongodb/mql-specifications project.

@GromNaN GromNaN requested a review from alcaeus February 26, 2026 11:20
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.75%. Comparing base (bce941a) to head (6010dd8).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               v2.x    #1851      +/-   ##
============================================
- Coverage     87.94%   87.75%   -0.19%     
- Complexity     3216     3308      +92     
============================================
  Files           428      447      +19     
  Lines          6410     6607     +197     
============================================
+ Hits           5637     5798     +161     
- Misses          773      809      +36     
Flag Coverage Δ
6.0-replica_set 86.58% <ø> (-0.15%) ⬇️
6.0-server 82.60% <ø> (-0.03%) ⬇️
6.0-sharded_cluster 86.37% <ø> (-0.15%) ⬇️
8.0-replica_set 87.61% <ø> (-0.19%) ⬇️
8.0-server 83.35% <ø> (-0.05%) ⬇️
8.0-sharded_cluster 87.45% <ø> (-0.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

Psalm found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Comment on lines +21 to +28
/*
$update = new Update(
Update::currentDate('lastModified'),
Update::currentDate('cancellation.date', type: 'timestamp'),
Update::set('cancellation.reason', 'user request'),
Update::set('status', 'D'),
);
*/
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is a different API design that would make sense for update operators.
It moves the field path as an argument instead of an array key. That enables using a FieldPath classes.

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.

I removed this example, we can always return to this later.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is a design decision that we can't change later.
I feel the current API not usable as you have to use ...['field.path' => ] everywhere.

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.

I pushed a new commit that allows for this kind of API for $currentDate, $set, and $setOnInsert. I'll double-check to see where else we may want to leverage this kind of API.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, I'm still concerned by keeping the variadic API.

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.

Created PHPLIB-1809 to track the separate API, so we can discuss potential issues with offering two APIs, as well as potentially applying the same change to pipeline builders.

@alcaeus alcaeus marked this pull request as ready for review March 11, 2026 12:35
@alcaeus alcaeus requested a review from a team as a code owner March 11, 2026 12:35
Copilot AI review requested due to automatic review settings March 11, 2026 12:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Extracts the MQL operator/stage definitions out of the generator repository into a Git submodule, and updates the generator entrypoints/CI to expect that new source of truth.

Changes:

  • Adds generator/mql-specifications as a Git submodule and ensures CI checks it out.
  • Updates the generator script to hard-fail when the submodule is missing and adjusts generator paths.
  • Removes in-repo YAML definitions that are now expected to come from the submodule.

Reviewed changes

Copilot reviewed 300 out of 502 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
generator/mql-specifications Adds the mql-specifications submodule pointer.
generator/generate Fails early if the submodule is missing; updates generator base paths/command defaults.
generator/composer.json Updates dependency constraints for generator dependencies.
.gitmodules Registers the new generator/mql-specifications submodule.
.github/workflows/generator.yml Ensures the CI checkout initializes submodules.
generator/config/stage/unset.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/sortByCount.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/sort.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/skip.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/shardedDataDistribution.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/set.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/sample.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/redact.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/planCacheStats.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/out.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/match.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/listSessions.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/listSearchIndexes.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/listSampledQueries.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/listLocalSessions.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/limit.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/indexStats.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/facet.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/documents.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/densify.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/currentOp.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/count.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/collStats.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/changeStreamSplitLargeEvent.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/bucketAuto.yaml Removes local MQL definition (now expected from submodule).
generator/config/stage/addFields.yaml Removes local MQL definition (now expected from submodule).
generator/config/search/wildcard.yaml Removes local MQL definition (now expected from submodule).
generator/config/search/regex.yaml Removes local MQL definition (now expected from submodule).
generator/config/search/queryString.yaml Removes local MQL definition (now expected from submodule).
generator/config/search/facet.yaml Removes local MQL definition (now expected from submodule).
generator/config/search/exists.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/where.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/size.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/sampleRate.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/regex.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/rand.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/polygon.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/or.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/not.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/nor.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/nin.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/nearSphere.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/near.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/ne.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/mod.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/minDistance.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/maxDistance.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/lte.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/lt.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/jsonSchema.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/in.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/gte.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/gt.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/geometry.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/geoWithin.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/geoIntersects.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/expr.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/exists.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/eq.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/elemMatch.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/comment.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/centerSphere.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/center.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/box.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/bitsAnySet.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/bitsAnyClear.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/bitsAllSet.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/bitsAllClear.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/and.yaml Removes local MQL definition (now expected from submodule).
generator/config/query/all.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/year.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/week.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/unsetField.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/type.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/tsSecond.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/tsIncrement.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/trunc.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/trim.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/toUpper.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/toString.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/toObjectId.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/toLower.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/toLong.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/toInt.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/toHashedIndexKey.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/toDouble.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/toDecimal.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/toDate.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/toBool.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/tanh.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/tan.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/switch.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/sum.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/subtract.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/substrCP.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/substrBytes.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/substr.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/strcasecmp.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/strLenCP.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/strLenBytes.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/stdDevSamp.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/stdDevPop.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/sqrt.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/split.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/slice.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/size.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/sinh.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/sin.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/setUnion.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/setIsSubset.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/setIntersection.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/setEquals.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/setDifference.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/second.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/rtrim.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/round.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/reverseArray.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/replaceOne.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/replaceAll.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/regexFind.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/range.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/rand.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/radiansToDegrees.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/pow.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/percentile.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/or.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/objectToArray.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/not.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/ne.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/multiply.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/month.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/mod.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/minute.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/minN.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/min.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/millisecond.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/meta.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/mergeObjects.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/median.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/maxN.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/max.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/ltrim.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/lte.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/lt.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/log10.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/log.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/ln.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/literal.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/let.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/lastN.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/last.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/isoWeekYear.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/isoWeek.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/isoDayOfWeek.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/isNumber.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/isArray.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/indexOfCP.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/indexOfBytes.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/indexOfArray.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/in.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/ifNull.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/hour.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/gte.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/gt.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/function.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/floor.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/firstN.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/first.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/exp.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/eq.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/divide.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/degreesToRadians.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/dayOfYear.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/dayOfWeek.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/dayOfMonth.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/dateToParts.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/createObjectId.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/cosh.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/cos.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/cond.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/concatArrays.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/concat.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/cmp.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/ceil.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/case.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/bsonSize.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/bitXor.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/bitOr.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/bitNot.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/bitAnd.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/binarySize.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/avg.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/atanh.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/atan2.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/atan.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/asinh.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/asin.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/arrayToObject.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/arrayElemAt.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/anyElementTrue.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/and.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/allElementsTrue.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/add.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/acosh.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/acos.yaml Removes local MQL definition (now expected from submodule).
generator/config/expression/abs.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/top.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/sum.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/stdDevSamp.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/stdDevPop.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/shift.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/setUnion.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/rank.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/push.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/min.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/mergeObjects.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/median.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/max.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/locf.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/linearFill.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/last.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/integral.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/first.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/expMovingAvg.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/documentNumber.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/derivative.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/denseRank.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/covarianceSamp.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/covariancePop.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/count.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/concatArrays.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/bottom.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/avg.yaml Removes local MQL definition (now expected from submodule).
generator/config/accumulator/addToSet.yaml Removes local MQL definition (now expected from submodule).

{
public function testIncrementFields(): void
{
$update = Update::inc(...['quantity' => -2, 'metrics.orders' => 1]);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Using variadics does not make sense.

Suggested change
$update = Update::inc(...['quantity' => -2, 'metrics.orders' => 1]);
$update = Update::inc(['quantity' => -2, 'metrics.orders' => 1]);

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.

I'd leave this as is for consistency with other builders, and handle this as part of PHPLIB-1809.

*/
public static function set(string|bool|int|stdClass|array|DateTimeInterface|Type|float|null ...$field): SetOperator
{
if (count($field) === 2 && array_is_list($field) && is_string($field[0])) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

$field[0] should also accept a FieldPathInterface.

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.

This API was removed, but we discussed that any field names should always be treated as unprefixed field paths. Not sure how we would handle this, as we're technically accepting array<UnprefixedFieldPath|string, mixed> and would ideally want to represent this in the MQL definitions.

Comment on lines +21 to +28
/*
$update = new Update(
Update::currentDate('lastModified'),
Update::currentDate('cancellation.date', type: 'timestamp'),
Update::set('cancellation.reason', 'user request'),
Update::set('status', 'D'),
);
*/
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, I'm still concerned by keeping the variadic API.

@GromNaN GromNaN merged commit f36676f into mongodb:v2.x Mar 12, 2026
35 checks passed
@GromNaN GromNaN deleted the PHPLIB-1798 branch March 12, 2026 10:29
@alcaeus alcaeus mentioned this pull request Mar 13, 2026
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.

5 participants