Skip to content

Comments

Unify memberOf method signature in Criteria class#12319

Open
vlastv wants to merge 1 commit intodoctrine:3.7.xfrom
vlastv:uniform-memberof
Open

Unify memberOf method signature in Criteria class#12319
vlastv wants to merge 1 commit intodoctrine:3.7.xfrom
vlastv:uniform-memberof

Conversation

@vlastv
Copy link
Contributor

@vlastv vlastv commented Dec 3, 2025

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 #11981 closed due to branch deletion

@derrabus derrabus changed the base branch from 3.5.x to 3.7.x December 30, 2025 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant