diff --git a/src/Psalm/Internal/Provider/ClassLikeStorageCacheProvider.php b/src/Psalm/Internal/Provider/ClassLikeStorageCacheProvider.php index 0c79452a647..9581702f0ed 100644 --- a/src/Psalm/Internal/Provider/ClassLikeStorageCacheProvider.php +++ b/src/Psalm/Internal/Provider/ClassLikeStorageCacheProvider.php @@ -110,9 +110,9 @@ public function getLatestFromCache( return $cached_value; } - private function getCacheHash(?string $file_path, ?string $file_contents): string + private function getCacheHash(?string $_unused_file_path, ?string $file_contents): string { - $data = ($file_path ? $file_contents : '') . $this->modified_timestamps; + $data = $file_contents ? $file_contents : $this->modified_timestamps; return PHP_VERSION_ID >= 80100 ? hash('xxh128', $data) : hash('md4', $data); } diff --git a/src/Psalm/Internal/Provider/FileStorageCacheProvider.php b/src/Psalm/Internal/Provider/FileStorageCacheProvider.php index 5d4a5b29b0d..d52b4165acf 100644 --- a/src/Psalm/Internal/Provider/FileStorageCacheProvider.php +++ b/src/Psalm/Internal/Provider/FileStorageCacheProvider.php @@ -117,9 +117,12 @@ public function removeCacheForFile(string $file_path): void } } - private function getCacheHash(string $file_path, string $file_contents): string + private function getCacheHash(string $_unused_file_path, string $file_contents): string { - $data = ($file_path ? $file_contents : '') . $this->modified_timestamps; + // do not concatenate, as $file_contents can be big and performance will be bad + // the timestamp is only needed if we don't have file contents + // as same contents should give same results, independent of when file was modified + $data = $file_contents ? $file_contents : $this->modified_timestamps; return PHP_VERSION_ID >= 80100 ? hash('xxh128', $data) : hash('md4', $data); }