From fad498a5027fe0ccbcf63b674f2a546adc98328c Mon Sep 17 00:00:00 2001 From: kkmuffme <11071985+kkmuffme@users.noreply.github.com> Date: Tue, 16 Aug 2022 15:53:28 +0200 Subject: [PATCH] update leftover md5 in provider to commonly used hash --- src/Psalm/Internal/Provider/StatementsProvider.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Psalm/Internal/Provider/StatementsProvider.php b/src/Psalm/Internal/Provider/StatementsProvider.php index 431cb1585d4..14b306e4749 100644 --- a/src/Psalm/Internal/Provider/StatementsProvider.php +++ b/src/Psalm/Internal/Provider/StatementsProvider.php @@ -26,7 +26,7 @@ use function array_merge; use function count; use function filemtime; -use function md5; +use function hash; use function strlen; use function strpos; @@ -132,7 +132,11 @@ public function getStatementsForFile(string $file_path, string $php_version, ?Pr $config = Config::getInstance(); - $file_content_hash = md5($version . $file_contents); + if (PHP_VERSION_ID >= 80100) { + $file_content_hash = hash('xxh128', $version . $file_contents); + } else { + $file_content_hash = hash('md4', $version . $file_contents); + } if (!$this->parser_cache_provider || (!$config->isInProjectDirs($file_path) && strpos($file_path, 'vendor')) @@ -239,7 +243,11 @@ function (int $_): bool { array_flip($unchanged_signature_members) ); - $file_path_hash = md5($file_path); + if (PHP_VERSION_ID >= 80100) { + $file_path_hash = hash('xxh128', $file_path); + } else { + $file_path_hash = hash('md4', $file_path); + } $changed_members = array_map( function (string $key) use ($file_path_hash): string {