|
4 | 4 |
|
5 | 5 | use PHPStan\Analyser\ResultCache\ResultCacheMetaExtension; |
6 | 6 | use function array_map; |
| 7 | +use function basename; |
7 | 8 | use function file_get_contents; |
8 | 9 | use function file_put_contents; |
9 | 10 | use function hash; |
@@ -44,23 +45,27 @@ public function getHash(): string |
44 | 45 | if ($xmlHash === false) { |
45 | 46 | throw new XmlContainerNotExistsException(sprintf('Container %s does not exist', $this->containerXmlPath)); |
46 | 47 | } |
47 | | - $hashFile = sprintf('%s/%s-%s.hash', $this->tmpDir, $this->getKey(), $xmlHash); |
48 | | - $hash = @file_get_contents($hashFile); |
49 | | - if ($hash !== false) { |
50 | | - return $hash; |
| 48 | + $xmlHashFile = sprintf('%s/%s-%s.hash', $this->tmpDir, $this->getKey(), basename($this->containerXmlPath)); |
| 49 | + $storedXmlHash = @file_get_contents($xmlHashFile); |
| 50 | + |
| 51 | + $hashForResultCacheFile = sprintf('%s/%s-%s-result-cache-meta.hash', $this->tmpDir, $this->getKey(), basename($this->containerXmlPath)); |
| 52 | + $storedHashForResultCache = @file_get_contents($hashForResultCacheFile); |
| 53 | + if ($storedXmlHash === $xmlHash && $storedHashForResultCache !== false) { |
| 54 | + return $storedHashForResultCache; |
51 | 55 | } |
52 | 56 | } |
53 | 57 |
|
54 | | - $hash = $this->calculateHash(); |
| 58 | + $hashForResultCache = $this->calculateHash(); |
55 | 59 |
|
56 | 60 | if ($this->containerXmlPath !== null) { |
57 | | - file_put_contents($hashFile, $hash); |
| 61 | + file_put_contents($hashForResultCacheFile, $hashForResultCache); |
| 62 | + file_put_contents($xmlHashFile, $xmlHash); |
58 | 63 | } |
59 | 64 |
|
60 | | - return $hash; |
| 65 | + return $hashForResultCache; |
61 | 66 | } |
62 | 67 |
|
63 | | - public function calculateHash(): string |
| 68 | + private function calculateHash(): string |
64 | 69 | { |
65 | 70 | $services = $parameters = []; |
66 | 71 |
|
|
0 commit comments