Skip to content

Commit 7110a08

Browse files
committed
OptimizedDirectorySourceLocator - fix bug with uppercase Enum keyword
See composer/composer@f808e49
1 parent 0e5d586 commit 7110a08

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/Reflection/BetterReflection/SourceLocator/OptimizedDirectorySourceLocator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private function findSymbols(string $file): array
228228
if ($matches['type'][$i] === 'function') {
229229
$functions[] = $namespacedName;
230230
} else {
231-
if ($matches['type'][$i] === 'enum') {
231+
if (strtolower($matches['type'][$i]) === 'enum') {
232232
$colonPos = strrpos($namespacedName, ':');
233233
if (false !== $colonPos) {
234234
$namespacedName = substr($namespacedName, 0, $colonPos);

tests/PHPStan/Reflection/BetterReflection/SourceLocator/OptimizedDirectorySourceLocatorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public function dataClass(): iterable
5353
'OptimizedDirectory\\BackedByStringWithoutSpace',
5454
'enum.php',
5555
];
56+
57+
yield [
58+
'OptimizedDirectory\\UppercaseEnum',
59+
'OptimizedDirectory\\UppercaseEnum',
60+
'enum.php',
61+
];
5662
}
5763

5864
/**

tests/PHPStan/Reflection/BetterReflection/SourceLocator/data/directory/enum.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ enum BackedByStringWithoutSpace:string
1313
{
1414
// cases
1515
}
16+
17+
Enum UppercaseEnum:string
18+
{
19+
20+
}

0 commit comments

Comments
 (0)