Skip to content

Commit 75fa7f8

Browse files
Fix #14205: Incorrect: Class referenced with incorrect case, (phpstan#5064)
Co-authored-by: Vincent Langlet <vincentlanglet@hotmail.fr>
1 parent 6fe16fe commit 75fa7f8

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/Rules/FunctionDefinitionCheck.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,11 @@ private function getOriginalClassNamePairsFromTypeNode(Identifier|Name|ComplexTy
866866
$originalCaseClassName = $originalName->toString();
867867
}
868868

869+
if (strtolower($originalCaseClassName) !== strtolower($resolvedName)) {
870+
// use alias, not just a case difference
871+
return [];
872+
}
873+
869874
if ($originalCaseClassName === $resolvedName) {
870875
return [];
871876
}

tests/PHPStan/Rules/Methods/ExistingClassesInTypehintsRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,4 +657,9 @@ public function testBug11470(): void
657657
]);
658658
}
659659

660+
public function testBug14205(): void
661+
{
662+
$this->analyse([__DIR__ . '/data/bug-14205.php'], []);
663+
}
664+
660665
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug14205\Competitie\Team;
4+
5+
class TeamsamenstellingService {}
6+
7+
class SamenstellingService {}
8+
9+
namespace Bug14205\Service;
10+
11+
use Bug14205\Competitie\Team\SamenstellingService as TeamSamenstellingService;
12+
13+
abstract class Foo {
14+
abstract public function test(): TeamSamenstellingService;
15+
}

0 commit comments

Comments
 (0)