[PR #12215] Experiment: Use comparator functions from a global registry for changeset detection #13589

Open
opened 2026-01-22 16:17:39 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/12215
Author: @mpdude
Created: 10/9/2025
Status: 🔄 Open

Base: 3.7.xHead: comparators


📝 Commits (2)

  • 9aa8d55 Experiment: Use comparator functions from a global registry for changeset detection
  • ea87484 Add 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 (in ClosureExpressionVisitor)?

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 their DateTime objects 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 null will 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.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/12215 **Author:** [@mpdude](https://github.com/mpdude) **Created:** 10/9/2025 **Status:** 🔄 Open **Base:** `3.7.x` ← **Head:** `comparators` --- ### 📝 Commits (2) - [`9aa8d55`](https://github.com/doctrine/orm/commit/9aa8d556b16112c8df7b99b5f4cb084efdbb3fa0) Experiment: Use comparator functions from a global registry for changeset detection - [`ea87484`](https://github.com/doctrine/orm/commit/ea8748480ea6cd56f65649b20d5a1193c43664bf) Add a test where a mutable object is mutated ### 📊 Changes **4 files changed** (+196 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `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) </details> ### 📄 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 (in `ClosureExpressionVisitor`)? 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 their `DateTime` objects 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 `null` will win. X-Ref https://github.com/doctrine/collections/pull/454 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 16:17:39 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#13589