Skip to content

Commit a29b29d

Browse files
staabmondrejmirtes
authored andcommitted
Reduce file-parsing in ResultCacheManager
1 parent 86e604c commit a29b29d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Analyser/ResultCache/ResultCacheManager.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
use PHPStan\Internal\ArrayHelper;
2323
use PHPStan\Internal\ComposerHelper;
2424
use PHPStan\PhpDoc\StubFilesProvider;
25-
use PHPStan\Reflection\ReflectionProvider;
2625
use PHPStan\ShouldNotHappenException;
26+
use ReflectionClass;
27+
use ReflectionException;
2728
use Throwable;
2829
use function array_diff;
2930
use function array_fill_keys;
@@ -82,7 +83,6 @@ public function __construct(
8283
private ExportedNodeFetcher $exportedNodeFetcher,
8384
#[AutowiredParameter(ref: '@fileFinderScan')]
8485
private FileFinder $scanFileFinder,
85-
private ReflectionProvider $reflectionProvider,
8686
private StubFilesProvider $stubFilesProvider,
8787
private FileHelper $fileHelper,
8888
#[AutowiredParameter(ref: '%resultCachePath%')]
@@ -936,13 +936,15 @@ private function getProjectExtensionFiles(?array $projectConfig, array $dependen
936936

937937
$classes = ProjectConfigHelper::getServiceClassNames($projectConfig);
938938
foreach ($classes as $class) {
939-
if (!$this->reflectionProvider->hasClass($class)) {
939+
try {
940+
// does not use static reflection to reduce file-parsing
941+
$classReflection = new ReflectionClass($class); /** @phpstan-ignore argument.type */
942+
} catch (ReflectionException) {
940943
continue;
941944
}
942945

943-
$classReflection = $this->reflectionProvider->getClass($class);
944946
$fileName = $classReflection->getFileName();
945-
if ($fileName === null) {
947+
if ($fileName === false) {
946948
continue;
947949
}
948950

0 commit comments

Comments
 (0)