[PR #12319] Unify memberOf method signature in Criteria class #13687

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

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/12319
Author: @vlastv
Created: 12/3/2025
Status: 🔄 Open

Base: 3.7.xHead: uniform-memberof


📝 Commits (1)

  • d0c0525 Uniform memberOf expression builder

📊 Changes

2 files changed (+9 additions, -1 deletions)

View changed files

📝 src/Query/QueryExpressionVisitor.php (+7 -1)
📝 tests/Tests/ORM/Query/QueryExpressionVisitorTest.php (+2 -0)

📄 Description

Standardized the memberOf method in Criteria class to match the signature pattern of other methods.

Changed memberOf parameter order to ('field', 'value') like other Criteria methods. Previously it used (':parameter', 'alias.field') which was inconsistent.

Consistency across the Criteria API. Better developer experience when using QueryBuilder. Follows principle of least surprise.

Fully backward compatible.

Example:

use Doctrine\ORM\QueryBuilder;

$group = 1;

$qb = new QueryBuilder();
$qb
   ->from(User::class, 'u0')
    ->where($qb->expr->eq('name', 'Test'))
    // Old approach
    ->andWhere($qb->expr->memberOf(':group', 'u0.groups'))
    ->setParameter('group', $group)
    // New approach
    ->andWhere($qb->expr->memberOf('groups', $group))
;

Reopening: previous PR https://github.com/doctrine/orm/pull/11981 closed due to branch deletion


🔄 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/12319 **Author:** [@vlastv](https://github.com/vlastv) **Created:** 12/3/2025 **Status:** 🔄 Open **Base:** `3.7.x` ← **Head:** `uniform-memberof` --- ### 📝 Commits (1) - [`d0c0525`](https://github.com/doctrine/orm/commit/d0c05251d3eb3357f47a11c00b8eecdf23aa4bdf) Uniform memberOf expression builder ### 📊 Changes **2 files changed** (+9 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/Query/QueryExpressionVisitor.php` (+7 -1) 📝 `tests/Tests/ORM/Query/QueryExpressionVisitorTest.php` (+2 -0) </details> ### 📄 Description Standardized the `memberOf` method in `Criteria` class to match the signature pattern of other methods. Changed `memberOf` parameter order to `('field', 'value')` like other `Criteria` methods. Previously it used `(':parameter', 'alias.field')` which was inconsistent. Consistency across the `Criteria` API. Better developer experience when using `QueryBuilder`. Follows principle of least surprise. Fully backward compatible. Example: ```php use Doctrine\ORM\QueryBuilder; $group = 1; $qb = new QueryBuilder(); $qb ->from(User::class, 'u0') ->where($qb->expr->eq('name', 'Test')) // Old approach ->andWhere($qb->expr->memberOf(':group', 'u0.groups')) ->setParameter('group', $group) // New approach ->andWhere($qb->expr->memberOf('groups', $group)) ; ``` Reopening: previous PR https://github.com/doctrine/orm/pull/11981 closed due to branch deletion --- <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:18:08 +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#13687