Skip to content

[doctrine] Skip unconvertible builders in RequireQueryBuilderOnRepositoryRule - #312

Merged
TomasVotruba merged 2 commits into
mainfrom
tv/require-qb-skip-unfixable
Sep 23, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
tv/require-qb-skip-unfixable

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

The rule flagged every $entityManager->createQueryBuilder() call inside a repository, including builders that cannot be swapped for $this->createQueryBuilder():

  • update() / delete() builders - the repository shortcut only produces SELECTs
  • from() on another entity than the repository owns - e.g. cross-entity subqueries; $this->createQueryBuilder() always FROMs the repository entity

Those forced an inline @phpstan-ignore on otherwise-correct code. The rule now inspects what the produced query builder does (both fluent chains and via an intermediate variable) and skips these cases, while still reporting the convertible ones - including a plain builder or from() on the repository entity, and per-builder within a method that mixes a main self query with a cross-entity subquery.

The repository entity is resolved from the EntityRepository<T> / DocumentRepository<T> generic.

Tests cover fluent + assigned variants of each skip case, a self-entity report, and a mixed-builders method.

@TomasVotruba
TomasVotruba merged commit f66d025 into main Sep 23, 2026
8 checks passed
@TomasVotruba
TomasVotruba deleted the tv/require-qb-skip-unfixable branch September 23, 2026 17:43
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