PHPLIB-1760: Support EJSON serialization/deserialization#1928
Merged
Conversation
Contributor
There was a problem hiding this comment.
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:
SerializeEJSONOperatorandDeserializeEJSONOperator. - Exposes new expression factory methods:
Expression::serializeEJSON()andExpression::deserializeEJSON(). - Adds/updates tests and expected JSON pipeline fixtures for canonical/relaxed serialization, string conversion, parsing-and-deserializing, and
onErrorbehavior.
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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
GromNaN
reviewed
Jun 17, 2026
GromNaN
left a comment
Member
There was a problem hiding this comment.
LGTM after rebase and this small refactor.
paulinevos
commented
Jun 17, 2026
Comment on lines
989
to
+990
| ] | ||
| JSON; | ||
| EXTENDED_JSON; |
Member
There was a problem hiding this comment.
That's a rebase issue. The generator needs to be rerun.
GromNaN
approved these changes
Jun 17, 2026
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`
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.
Part of DRIVERS-3354