Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Dec 22, 2024
1 parent d8cf9ca commit fe2c014
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/Rules/Doctrine/NoEntityMockingRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 [];
}

Expand All @@ -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';
}
}

0 comments on commit fe2c014

Please sign in to comment.