Skip to content

Commit f22c92d

Browse files
committed
Fix attempt
1 parent 3653b97 commit f22c92d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Reflection/BetterReflection/SourceLocator/AutoloadFunctionsSourceLocator.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
use PHPStan\BetterReflection\Reflection\Reflection;
88
use PHPStan\BetterReflection\Reflector\Reflector;
99
use PHPStan\BetterReflection\SourceLocator\Type\SourceLocator;
10+
use function class_exists;
11+
use function interface_exists;
1012
use function PHPStan\autoloadFunctions;
13+
use function trait_exists;
1114

1215
class AutoloadFunctionsSourceLocator implements SourceLocator
1316
{
@@ -18,9 +21,14 @@ public function locateIdentifier(Reflector $reflector, Identifier $identifier):
1821
return null;
1922
}
2023

24+
$className = $identifier->getName();
25+
if (class_exists($className, false) || interface_exists($className, false) || trait_exists($className, false)) {
26+
return null;
27+
}
28+
2129
$autoloadFunctions = autoloadFunctions();
2230
foreach ($autoloadFunctions as $autoloadFunction) {
23-
$autoloadFunction($identifier->getName());
31+
$autoloadFunction($className);
2432
}
2533

2634
return null;

0 commit comments

Comments
 (0)