Skip to content

Commit a4834f7

Browse files
committed
Skip the rule for the requirements query builder with a dbal connection
1 parent af9bfec commit a4834f7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Enum/DoctrineClass.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@ final class DoctrineClass
2525
* @var string
2626
*/
2727
public const ENTITY_REPOSITORY = 'Doctrine\ORM\EntityRepository';
28+
29+
/**
30+
* @var string
31+
*/
32+
public const CONNECTION = 'Doctrine\DBAL\Connection';
2833
}

src/Rules/Doctrine/RequireQueryBuilderOnRepositoryRule.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public function processNode(Node $node, Scope $scope): array
5252
return [];
5353
}
5454

55+
if ($callerType->isInstanceOf(DoctrineClass::CONNECTION)->yes()) {
56+
return [];
57+
}
58+
5559
$identifierRuleError = RuleErrorBuilder::message(self::ERROR_MESSAGE)
5660
->identifier(DoctrineRuleIdentifier::REQUIRE_QUERY_BUILDER_ON_REPOSITORY)
5761
->build();

0 commit comments

Comments
 (0)