Skip to content

PHPLIB-1760: Support EJSON serialization/deserialization#1928

Merged
paulinevos merged 2 commits into
mongodb:v2.xfrom
paulinevos:ejson
Jun 17, 2026
Merged

PHPLIB-1760: Support EJSON serialization/deserialization#1928
paulinevos merged 2 commits into
mongodb:v2.xfrom
paulinevos:ejson

Conversation

@paulinevos

Copy link
Copy Markdown
Contributor

Part of DRIVERS-3354

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

Adds support in the aggregation expression builder for MongoDB’s $serializeEJSON and $deserializeEJSON operators (MongoDB 8.3), including factory methods and pipeline serialization tests to ensure the generated pipelines match the documented examples.

Changes:

  • Introduces new operator classes: SerializeEJSONOperator and DeserializeEJSONOperator.
  • Exposes new expression factory methods: Expression::serializeEJSON() and Expression::deserializeEJSON().
  • Adds/updates tests and expected JSON pipeline fixtures for canonical/relaxed serialization, string conversion, parsing-and-deserializing, and onError behavior.

Reviewed changes

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

Show a summary per file
File Description
tests/Builder/Expression/SerializeEJSONOperatorTest.php Adds pipeline builder tests covering $serializeEJSON usage patterns.
tests/Builder/Expression/DeserializeEJSONOperatorTest.php Adds pipeline builder tests covering $deserializeEJSON usage patterns.
tests/Builder/Expression/Pipelines.php Adds expected JSON fixtures for the new serialize/deserialize EJSON examples.
src/Builder/Expression/SerializeEJSONOperator.php Implements the $serializeEJSON operator object and argument validation.
src/Builder/Expression/DeserializeEJSONOperator.php Implements the $deserializeEJSON operator object and argument validation.
src/Builder/Expression/FactoryTrait.php Adds factory methods to construct the new operator instances.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...rc/Builder/Expression/DeserializeEJSONOperator.php 80.00% 1 Missing ⚠️
src/Builder/Expression/SerializeEJSONOperator.php 83.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI review requested due to automatic review settings June 17, 2026 09:43

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 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread generator/src/OperatorTestGenerator.php

@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.

LGTM after rebase and this small refactor.

Comment thread generator/src/OperatorTestGenerator.php Outdated
Copilot AI review requested due to automatic review settings June 17, 2026 12:17
Comment thread tests/Builder/Expression/SerializeEJSONOperatorTest.php
Comment thread generator/src/OperatorTestGenerator.php Outdated

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 12 out of 13 changed files in this pull request and generated 1 comment.

Comment on lines 989 to +990
]
JSON;
EXTENDED_JSON;

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.

That's a rebase issue. The generator needs to be rerun.

If `JSON` is present in the actual string content, using `<<< JSON` as
the multiline string label is considered unsafe and rector will scream
about it (`SensitiveHereNowDocRector`)

Seeing as `EXTENDED_JSON` is not and probably will never be present in
the strings, use that for the heredoc/nowdoc to circumvent
`SensitiveHereNowDocRector`
@paulinevos paulinevos merged commit 67f2847 into mongodb:v2.x Jun 17, 2026
35 of 36 checks passed
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