@@ -48,7 +48,7 @@ public function processNode(Node $node, Scope $scope): array
|
48 | 48 | $method = $constantString->getValue();
|
49 | 49 | $type = $scope->getType($node->var);
|
50 | 50 |
|
51 |
| -$error = $this->checkCallOnType($type, $method); |
| 51 | +$error = $this->checkCallOnType($scope, $type, $method); |
52 | 52 | if ($error !== null) {
|
53 | 53 | $errors[] = $error;
|
54 | 54 | continue;
|
@@ -67,7 +67,7 @@ public function processNode(Node $node, Scope $scope): array
|
67 | 67 | }
|
68 | 68 |
|
69 | 69 | $varType = $scope->getType($node->var->var);
|
70 |
| -$error = $this->checkCallOnType($varType, $method); |
| 70 | +$error = $this->checkCallOnType($scope, $varType, $method); |
71 | 71 | if ($error === null) {
|
72 | 72 | continue;
|
73 | 73 | }
|
@@ -78,14 +78,16 @@ public function processNode(Node $node, Scope $scope): array
|
78 | 78 | return $errors;
|
79 | 79 | }
|
80 | 80 |
|
81 |
| -private function checkCallOnType(Type $type, string $method): ?IdentifierRuleError |
| 81 | +private function checkCallOnType(Scope $scope, Type $type, string $method): ?IdentifierRuleError |
82 | 82 | {
|
| 83 | +$methodReflection = $scope->getMethodReflection($type, $method); |
| 84 | +if ($methodReflection !== null) { |
| 85 | +return null; |
| 86 | +} |
| 87 | + |
83 | 88 | if (
|
84 |
| -( |
85 |
| -in_array(MockObject::class, $type->getObjectClassNames(), true) |
86 |
| -|| in_array(Stub::class, $type->getObjectClassNames(), true) |
87 |
| -) |
88 |
| -&& !$type->hasMethod($method)->yes() |
| 89 | +in_array(MockObject::class, $type->getObjectClassNames(), true) |
| 90 | +|| in_array(Stub::class, $type->getObjectClassNames(), true) |
89 | 91 | ) {
|
90 | 92 | $mockClasses = array_filter($type->getObjectClassNames(), static fn (string $class): bool => $class !== MockObject::class && $class !== Stub::class);
|
91 | 93 | if (count($mockClasses) === 0) {
|
|
0 commit comments