1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Make config warn about missing cache related functions

This commit is contained in:
Yannick Gottschalk 2023-06-20 12:33:37 +02:00
parent 8e636086b3
commit dbc4f48e2b

View File

@ -1192,18 +1192,38 @@ class Config
if (isset($config_xml['serializer'])) { if (isset($config_xml['serializer'])) {
$attribute_text = (string) $config_xml['serializer']; $attribute_text = (string) $config_xml['serializer'];
$config->use_igbinary = $attribute_text === 'igbinary'; $config->use_igbinary = $attribute_text === 'igbinary';
if ($config->use_igbinary
&& (
!function_exists('igbinary_serialize')
|| !function_exists('igbinary_unserialize')
)
) {
$config->use_igbinary = false;
$config->config_warnings[] = '"serializer" set to "igbinary" but ext-igbinary seems to be missing on ' .
'the system. Using php\'s build-in serializer.';
}
} elseif ($igbinary_version = phpversion('igbinary')) { } elseif ($igbinary_version = phpversion('igbinary')) {
$config->use_igbinary = version_compare($igbinary_version, '2.0.5') >= 0; $config->use_igbinary = version_compare($igbinary_version, '2.0.5') >= 0;
} }
if (isset($config_xml['compressor'])) { if (isset($config_xml['compressor'])) {
$compressor = (string) $config_xml['compressor']; $compressor = (string) $config_xml['compressor'];
if ($compressor === 'lz4' && function_exists('lz4_uncompress')) { if ($compressor === 'lz4') {
$config->compressor = 'lz4'; if (function_exists('lz4_compress') && function_exists('lz4_uncompress')) {
} elseif ($compressor !== 'off' && function_exists('gzdeflate')) { $config->compressor = 'lz4';
$config->compressor = 'deflate'; } else {
$config->config_warnings[] = '"compressor" set to "lz4" but ext-lz4 seems to be missing on the ' .
'system. Disabling cache compressor.';
}
} elseif ($compressor === 'deflate') {
if (function_exists('gzinflate') && function_exists('gzdeflate')) {
$config->compressor = 'deflate';
} else {
$config->config_warnings[] = '"compressor" set to "deflate" but zlib seems to be missing on the ' .
'system. Disabling cache compressor.';
}
} }
} elseif (function_exists('gzdeflate')) { } elseif (function_exists('gzinflate') && function_exists('gzdeflate')) {
$config->compressor = 'deflate'; $config->compressor = 'deflate';
} }