diff --git a/src/Rules/Doctrine/NoEntityMockingRule.php b/src/Rules/Doctrine/NoEntityMockingRule.php index 2ac35889..a3de40c7 100644 --- a/src/Rules/Doctrine/NoEntityMockingRule.php +++ b/src/Rules/Doctrine/NoEntityMockingRule.php @@ -13,6 +13,7 @@ use PHPStan\Rules\RuleErrorBuilder; use Symplify\PHPStanRules\Doctrine\DoctrineEntityDocumentAnalyser; use Symplify\PHPStanRules\Enum\RuleIdentifier; +use Symplify\PHPStanRules\NodeAnalyzer\MethodCallNameAnalyzer; /** * The ORM entities and ODM documents should never be mocked, as it leads to typeless code. @@ -44,7 +45,7 @@ public function getNodeType(): string */ public function processNode(Node $node, Scope $scope): array { - if (! $this->isCreateMockMethod($node)) { + if (! MethodCallNameAnalyzer::isThisMethodCall($node, 'createMock')) { return []; } @@ -70,18 +71,4 @@ public function processNode(Node $node, Scope $scope): array return []; } - - private function isCreateMockMethod(MethodCall $methodCall): bool - { - if ($methodCall->isFirstClassCallable()) { - return false; - } - - if (! $methodCall->name instanceof Identifier) { - return false; - } - - $methodName = $methodCall->name->toString(); - return $methodName === 'createMock'; - } }