diff --git a/src/Rules/FunctionDefinitionCheck.php b/src/Rules/FunctionDefinitionCheck.php index c888ed886f..6ef8f74b15 100644 --- a/src/Rules/FunctionDefinitionCheck.php +++ b/src/Rules/FunctionDefinitionCheck.php @@ -866,6 +866,11 @@ private function getOriginalClassNamePairsFromTypeNode(Identifier|Name|ComplexTy $originalCaseClassName = $originalName->toString(); } + if (strtolower($originalCaseClassName) !== strtolower($resolvedName)) { + // use alias, not just a case difference + return []; + } + if ($originalCaseClassName === $resolvedName) { return []; } diff --git a/tests/PHPStan/Rules/Methods/ExistingClassesInTypehintsRuleTest.php b/tests/PHPStan/Rules/Methods/ExistingClassesInTypehintsRuleTest.php index 929b3bdfd4..dd9f891c4a 100644 --- a/tests/PHPStan/Rules/Methods/ExistingClassesInTypehintsRuleTest.php +++ b/tests/PHPStan/Rules/Methods/ExistingClassesInTypehintsRuleTest.php @@ -657,4 +657,9 @@ public function testBug11470(): void ]); } + public function testBug14205(): void + { + $this->analyse([__DIR__ . '/data/bug-14205.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Methods/data/bug-14205.php b/tests/PHPStan/Rules/Methods/data/bug-14205.php new file mode 100644 index 0000000000..35ab5741a0 --- /dev/null +++ b/tests/PHPStan/Rules/Methods/data/bug-14205.php @@ -0,0 +1,15 @@ +