mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #12215] Experiment: Use comparator functions from a global registry for changeset detection #13589
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/doctrine/orm/pull/12215
Author: @mpdude
Created: 10/9/2025
Status: 🔄 Open
Base:
3.7.x← Head:comparators📝 Commits (2)
9aa8d55Experiment: Use comparator functions from a global registry for changeset detectionea87484Add a test where a mutable object is mutated📊 Changes
4 files changed (+196 additions, -0 deletions)
View changed files
➕
src/ComparatorRegistry.php(+46 -0)📝
src/UnitOfWork.php(+5 -0)➕
tests/Tests/ORM/ComparatorRegistryTest.php(+52 -0)➕
tests/Tests/ORM/Functional/ComparatorRegistryBasedChangeDetectionTest.php(+93 -0)📄 Description
This is an experiment towards #5542. Can we have something to do comparison of objects to get away from
===checks in changeset computation, but also in Criteria comparisons and sorting (inClosureExpressionVisitor)?We cannot expect users to implement interfaces for this in their objects. For example, users might be bringing their own subclasses of
DateTime(like Carbon or Chronos libraries) or get theirDateTimeobjects e. g. from clock mocking libraries. So, these objects might be coming from very differnet places and the classes used or created cannot all implement Doctrine interfaces.Thus, the mechanism for bringing in the comparisons has to be attached or brought to the objects from the outside.
A global-state registry is not nice, but a very simple approach to start the discussion.
In this PR, comparators are registered based on class or interface names. Registration happens in order, and the first one matching an object at hand that returns a result different from
nullwill win.X-Ref https://github.com/doctrine/collections/pull/454
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.