Skip to content

PHPLIB-1386 Add $out stage with object encoding, db/coll fields, and timeseries support - #1903

Merged
GromNaN merged 5 commits into
mongodb:v2.xfrom
GromNaN:PHPLIB-1386
May 26, 2026
Merged

GromNaN merged 5 commits into
mongodb:v2.xfrom
GromNaN:PHPLIB-1386

Conversation

@GromNaN

@GromNaN GromNaN commented May 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Rewrites the $out stage builder with:

  • encode: object (was encode: single with an outCollection type accepting a string or object)
  • Explicit coll (required) and db (optional) named parameters
  • timeseries nested object argument (minVersion 7.0.3) with timeField, metaField, granularity, bucketMaxSpanSeconds, bucketRoundingSeconds

Generated from mql-specifications PR #42 (rebased on upstream main).

Deprecation since 2.4: Passing a non-string first argument to Stage::out() triggers E_USER_DEPRECATED. The old forms still work:

  • Stage::out('authors') → no change, still works
  • Stage::out(object(coll: 'authors')) → deprecated, use Stage::out('authors')
  • Stage::out(object(db: 'reporting', coll: 'authors')) → deprecated, use Stage::out(coll: 'authors', db: 'reporting')

Jira

https://jira.mongodb.org/browse/PHPLIB-1386

Copilot AI review requested due to automatic review settings May 26, 2026 09:32
@GromNaN
GromNaN requested a review from a team as a code owner May 26, 2026 09:32
@GromNaN
GromNaN requested a review from paulinevos May 26, 2026 09: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

Updates the aggregation $out stage builder to always encode as a document and to expose explicit builder parameters for coll, optional db, and optional timeseries configuration, aligning the builder API and fixtures with the newer $out capabilities.

Changes:

  • Switched $out encoding from the string form to the document form (always emitting {"coll": ...} with optional fields).
  • Added optional db and timeseries parameters to the $out stage factory and fluent factory APIs.
  • Updated stage fixtures and tests to cover the new encoding and added a time series $out example.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Builder/Stage/Pipelines.php Updates $out fixtures to object form and adds a time series $out fixture.
tests/Builder/Stage/OutStageTest.php Updates $out stage tests for new API and adds a time series $out test.
src/Builder/Stage/OutStage.php Changes $out stage encoding to object and adds db/timeseries optional properties.
src/Builder/Stage/FluentFactoryTrait.php Updates fluent out() to accept db and timeseries and forward them to Stage::out().
src/Builder/Stage/FactoryTrait.php Updates Stage::out() factory signature to coll, optional db, optional timeseries.

@codecov-commenter

codecov-commenter commented May 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.26087% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.73%. Comparing base (df6a76c) to head (37b98d4).
⚠️ Report is 2 commits behind head on v2.x.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/Builder/Stage/FluentFactoryTrait.php 0.00% 3 Missing ⚠️
src/Builder/Stage/FactoryTrait.php 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               v2.x    #1903   +/-   ##
=========================================
  Coverage     87.72%   87.73%           
- Complexity     3328     3338   +10     
=========================================
  Files           454      454           
  Lines          6658     6675   +17     
=========================================
+ Hits           5841     5856   +15     
- Misses          817      819    +2     
Flag Coverage Δ
6.0-replica_set 86.57% <78.26%> (+<0.01%) ⬆️
6.0-server 82.63% <78.26%> (+0.01%) ⬆️
6.0-sharded_cluster 86.36% <78.26%> (+<0.01%) ⬆️
8.0-replica_set 87.59% <78.26%> (+<0.01%) ⬆️
8.0-server 83.37% <78.26%> (+0.01%) ⬆️
8.0-sharded_cluster 87.43% <78.26%> (?)

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.

Copilot AI review requested due to automatic review settings May 26, 2026 10:02

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 7 out of 7 changed files in this pull request and generated 4 comments.

Comment thread src/Builder/Stage.php Resolved
Comment thread src/Builder/Stage.php Resolved
Comment thread src/Builder/Stage.php Resolved
Comment thread src/Builder/Stage.php Resolved
Copilot AI review requested due to automatic review settings May 26, 2026 10:58
@GromNaN
GromNaN requested review from alcaeus and removed request for paulinevos May 26, 2026 10:58

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@GromNaN
GromNaN enabled auto-merge (squash) May 26, 2026 12:54
Copilot AI review requested due to automatic review settings May 26, 2026 16:17

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 9 out of 9 changed files in this pull request and generated 2 comments.

Comment on lines +112 to +129
private function assertDeprecated(callable $callable): mixed
{
$messages = [];
set_error_handler(static function (int $errno, string $errstr) use (&$messages): bool {
$messages[] = $errstr;

return true;
}, E_USER_DEPRECATED);

try {
$result = $callable();
} finally {
restore_error_handler();
}

self::assertCount(1, $messages, 'Expected exactly one deprecation notice');

return $result;
Comment thread src/Builder/Stage.php
}

if (isset($coll['db'])) {
$db = (string) $coll['db'];
@GromNaN
GromNaN merged commit 3c36203 into mongodb:v2.x May 26, 2026
26 of 27 checks passed
@GromNaN
GromNaN deleted the PHPLIB-1386 branch May 26, 2026 16:41
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