|
10 | 10 | use PHPStan\Broker\AnonymousClassNameHelper; |
11 | 11 | use PHPStan\Cache\Cache; |
12 | 12 | use PHPStan\Parser\Parser; |
| 13 | +use PHPStan\Php\PhpVersion; |
13 | 14 | use PHPStan\PhpDoc\PhpDocNodeResolver; |
14 | 15 | use PHPStan\PhpDoc\PhpDocStringResolver; |
15 | 16 | use PHPStan\PhpDoc\ResolvedPhpDocBlock; |
@@ -72,6 +73,7 @@ public function __construct( |
72 | 73 | private PhpDocNodeResolver $phpDocNodeResolver, |
73 | 74 | private Cache $cache, |
74 | 75 | private AnonymousClassNameHelper $anonymousClassNameHelper, |
| 76 | + private PhpVersion $phpVersion, |
75 | 77 | ) |
76 | 78 | { |
77 | 79 | } |
@@ -187,8 +189,8 @@ private function resolvePhpDocStringToDocNode(string $phpDocString): PhpDocNode |
187 | 189 | private function getNameScopeMap(string $fileName): array |
188 | 190 | { |
189 | 191 | if (!isset($this->memoryCache[$fileName])) { |
190 | | - $cacheKey = sprintf('%s-phpdocstring-v17-require-once', $fileName); |
191 | | - $variableCacheKey = implode(',', array_map(static fn (array $file): string => sprintf('%s-%d', $file['filename'], $file['modifiedTime']), $this->getCachedDependentFilesWithTimestamps($fileName))); |
| 192 | + $cacheKey = sprintf('%s-phpdocstring', $fileName); |
| 193 | + $variableCacheKey = sprintf('%s-%s-v17-require-once', implode(',', array_map(static fn (array $file): string => sprintf('%s-%d', $file['filename'], $file['modifiedTime']), $this->getCachedDependentFilesWithTimestamps($fileName))), $this->phpVersion->getVersionString()); |
192 | 194 | $map = $this->cache->load($cacheKey, $variableCacheKey); |
193 | 195 |
|
194 | 196 | if ($map === null) { |
@@ -631,12 +633,12 @@ private function getNameScopeKey( |
631 | 633 | */ |
632 | 634 | private function getCachedDependentFilesWithTimestamps(string $fileName): array |
633 | 635 | { |
634 | | - $cacheKey = sprintf('dependentFilesTimestamps-%s-v2-enum', $fileName); |
| 636 | + $cacheKey = sprintf('dependentFilesTimestamps-%s', $fileName); |
635 | 637 | $fileModifiedTime = filemtime($fileName); |
636 | 638 | if ($fileModifiedTime === false) { |
637 | 639 | $fileModifiedTime = time(); |
638 | 640 | } |
639 | | - $variableCacheKey = sprintf('%d', $fileModifiedTime); |
| 641 | + $variableCacheKey = sprintf('%d-%s-v2-enum', $fileModifiedTime, $this->phpVersion->getVersionString()); |
640 | 642 | /** @var array<array{filename: string, modifiedTime: int}>|null $cachedFilesTimestamps */ |
641 | 643 | $cachedFilesTimestamps = $this->cache->load($cacheKey, $variableCacheKey); |
642 | 644 | if ($cachedFilesTimestamps !== null) { |
|
0 commit comments