mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Merge pull request #8009 from kkmuffme/microoptimize-phpversion-check-as-requested
This commit is contained in:
commit
48db4f24c4
@ -18,14 +18,13 @@ use function igbinary_serialize;
|
||||
use function igbinary_unserialize;
|
||||
use function is_dir;
|
||||
use function mkdir;
|
||||
use function phpversion;
|
||||
use function serialize;
|
||||
use function strtolower;
|
||||
use function unlink;
|
||||
use function unserialize;
|
||||
use function version_compare;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -114,7 +113,7 @@ class ClassLikeStorageCacheProvider
|
||||
private function getCacheHash(?string $file_path, ?string $file_contents): string
|
||||
{
|
||||
$data = ($file_path ? $file_contents : '') . $this->modified_timestamps;
|
||||
return version_compare(phpversion(), '8.1', '>=') ? hash('xxh128', $data) : hash('md4', $data);
|
||||
return PHP_VERSION_ID >= 80100 ? hash('xxh128', $data) : hash('md4', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,7 +165,7 @@ class ClassLikeStorageCacheProvider
|
||||
|
||||
$data = $file_path ? strtolower($file_path) . ' ' : '';
|
||||
$data .= $fq_classlike_name_lc;
|
||||
$file_path_sha = version_compare(phpversion(), '8.1', '>=') ? hash('xxh128', $data) : hash('md4', $data);
|
||||
$file_path_sha = PHP_VERSION_ID >= 80100 ? hash('xxh128', $data) : hash('md4', $data);
|
||||
|
||||
return $parser_cache_directory
|
||||
. DIRECTORY_SEPARATOR
|
||||
|
@ -18,14 +18,13 @@ use function igbinary_serialize;
|
||||
use function igbinary_unserialize;
|
||||
use function is_dir;
|
||||
use function mkdir;
|
||||
use function phpversion;
|
||||
use function serialize;
|
||||
use function strtolower;
|
||||
use function unlink;
|
||||
use function unserialize;
|
||||
use function version_compare;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -121,7 +120,7 @@ class FileStorageCacheProvider
|
||||
private function getCacheHash(string $file_path, string $file_contents): string
|
||||
{
|
||||
$data = ($file_path ? $file_contents : '') . $this->modified_timestamps;
|
||||
return version_compare(phpversion(), '8.1', '>=') ? hash('xxh128', $data) : hash('md4', $data);
|
||||
return PHP_VERSION_ID >= 80100 ? hash('xxh128', $data) : hash('md4', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,7 +167,7 @@ class FileStorageCacheProvider
|
||||
mkdir($parser_cache_directory, 0777, true);
|
||||
}
|
||||
|
||||
if (version_compare(phpversion(), '8.1', '>=')) {
|
||||
if (PHP_VERSION_ID >= 80100) {
|
||||
$hash = hash('xxh128', $file_path);
|
||||
} else {
|
||||
$hash = hash('md4', $file_path);
|
||||
|
@ -10,11 +10,10 @@ use function file_put_contents;
|
||||
use function filemtime;
|
||||
use function hash;
|
||||
use function mkdir;
|
||||
use function phpversion;
|
||||
use function touch;
|
||||
use function version_compare;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
/**
|
||||
* Used to determine which files reference other files, necessary for using the --diff
|
||||
@ -93,7 +92,7 @@ class ProjectCacheProvider
|
||||
return true;
|
||||
}
|
||||
|
||||
if (version_compare(phpversion(), '8.1', '>=')) {
|
||||
if (PHP_VERSION_ID >= 80100) {
|
||||
$hash = hash('xxh128', $lockfile_contents);
|
||||
} else {
|
||||
$hash = hash('md4', $lockfile_contents);
|
||||
|
Loading…
Reference in New Issue
Block a user