Skip to content

Commit 08f3a7e

Browse files
committed
Update BetterReflectionSourceLocatorFactory.php
1 parent d3f5f86 commit 08f3a7e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/Reflection/BetterReflection/BetterReflectionSourceLocatorFactory.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
use PHPStan\Cache\Cache;
1717
use PHPStan\DependencyInjection\AutowiredParameter;
1818
use PHPStan\DependencyInjection\AutowiredService;
19+
use PHPStan\Internal\ComposerHelper;
1920
use PHPStan\Php\PhpVersion;
2021
use PHPStan\Reflection\BetterReflection\SourceLocator\AutoloadFunctionsSourceLocator;
2122
use PHPStan\Reflection\BetterReflection\SourceLocator\AutoloadSourceLocator;
2223
use PHPStan\Reflection\BetterReflection\SourceLocator\ComposerJsonAndInstalledJsonSourceLocatorMaker;
24+
use PHPStan\Reflection\BetterReflection\SourceLocator\FileCachedSourceLocator;
2325
use PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher;
2426
use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedDirectorySourceLocatorRepository;
2527
use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedPsrAutoloaderLocatorFactory;
@@ -163,14 +165,18 @@ public function create(): SourceLocator
163165
);
164166
}
165167
}
166-
$cachedPhpstormSourceStubber = new CachedPhpStormStubsSourceStubber(
167-
$this->phpstormStubsSourceStubber,
168-
$this->cache,
169-
$this->phpVersion,
170-
);
168+
169+
$phpstormStubsVersion = ComposerHelper::getPhpStormStubsVersion();
171170

172171
$locators[] = new RewriteClassAliasSourceLocator(new AggregateSourceLocator($fileLocators));
173-
$locators[] = new SkipClassAliasSourceLocator(new PhpInternalSourceLocator($astPhp8Locator, $cachedPhpstormSourceStubber));
172+
$locators[] = new SkipClassAliasSourceLocator(
173+
new FileCachedSourceLocator(
174+
new PhpInternalSourceLocator($astPhp8Locator, $this->phpstormStubsSourceStubber),
175+
$this->cache,
176+
$this->phpVersion,
177+
sprintf('phpstorm-stubs-php8-%s', $phpstormStubsVersion)
178+
)
179+
);
174180

175181
$locators[] = new AutoloadSourceLocator($this->fileNodesFetcher, true);
176182
$locators[] = new PhpVersionBlacklistSourceLocator(new PhpInternalSourceLocator($astLocator, $this->reflectionSourceStubber), $cachedPhpstormSourceStubber);

0 commit comments

Comments
 (0)