Repository navigation
Support patchlevel/hydrator 2 - #29
Merged
Merged
Conversation
1 task
This was referenced Nov 6, 2026
PHPStan 2.2 types variadic parameters as arrays that may have string keys, so the objects passed on to insertMany() and bulkWrite() no longer satisfied the list types and the baseline entries stopped matching. Normalizing the objects with array_values() also makes the $objects[0] access safe when a repository is called with named arguments. The mapping methods now declare that they throw UnknownPropertyPath, which PHPStan needs to accept a call whose result is unused in the tests.
MongoDB 8.x refuses to start on the current GitHub runners because their kernel is 6.19 or newer (SERVER-121912). 9.0 starts fine.
Hydrator 2 merged HydratorWithContext and NormalizerWithContext into the Hydrator and Normalizer interfaces, so the repositories now take a plain Hydrator and the normalizers in the docs and fixtures get the context argument. 2.1.1 is the first release that keeps array shape keys without a normalizer, which 2.1.0 dropped. DocumentHydrator no longer implements the Hydrator interface. In v2 that interface works on mixed data, while documents are always arrays and the class is only used inside the repositories. It is now internal and throws DocumentNotExtractable if the hydrator does not return an array.
Covers the switch to hydrator 2 for custom normalizers, custom hydrators and the DocumentHydrator.
DavidBadura
force-pushed
the
hydrator-2
branch
from
November 7, 2026 11:05
8291358 to
d0aebdd
Compare
DavidBadura
marked this pull request as ready for review
November 7, 2026 11:22
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.
Moves the library to hydrator 2.1.1 and drops support for 1.x, since
HydratorWithContextandNormalizerWithContextare gone in v2 and the plainHydratorin v1 has no context. The repositories and managers now take aHydrator, and custom normalizers in the docs and fixtures get the context argument. 2.1.1 is needed because 2.1.0 drops array shape keys without a normalizer.DocumentHydratorno longer implements theHydratorinterface. In v2 that interface works on mixed data, but documents are always arrays and the class is only used inside the repositories, so it is internal now and throwsDocumentNotExtractableif the hydrator does not return an array.The new
docs/UPGRADE-2.0.mdcovers these changes. Builds on #31, which fixes CI on 2.0.x, so please merge that first. Further fixes found along the way follow as separate PRs.Replaces #21.