From f2ba7895adf30b124885c06899ae10d23aad05f4 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 5 Nov 2022 11:03:07 +0100 Subject: [PATCH] fix StaticMethodCallCheck --- src/Rules/Methods/StaticMethodCallCheck.php | 5 +++++ tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php | 1 + 2 files changed, 6 insertions(+) diff --git a/src/Rules/Methods/StaticMethodCallCheck.php b/src/Rules/Methods/StaticMethodCallCheck.php index 64fb1adf879..48f50f9dff8 100644 --- a/src/Rules/Methods/StaticMethodCallCheck.php +++ b/src/Rules/Methods/StaticMethodCallCheck.php @@ -109,6 +109,11 @@ public function check( $classType = $scope->resolveTypeByName($class); } else { + $classStringType = $scope->getType(new Expr\ClassConstFetch($class, 'class')); + if ($classStringType->hasMethod($methodName)->yes()) { + return [[], null]; + } + if (!$this->reflectionProvider->hasClass($className)) { if ($scope->isInClassExists($className)) { return [[], null]; diff --git a/tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php b/tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php index f7780a6ce00..5342e72a18e 100644 --- a/tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php +++ b/tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php @@ -537,4 +537,5 @@ public function testHasMethodStaticCall(): void $this->checkExplicitMixed = false; $this->analyse([__DIR__ . '/data/static-has-method.php'], []); } + }