diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 833c82c20..1082c5404 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -146,8 +146,18 @@ class PlatformRepository extends ArrayRepository break; case 'openssl': - $prettyVersion = preg_replace_callback('{^(?:OpenSSL\s*)?([0-9.]+)([a-z]?).*}', function ($match) { - return $match[1] . (empty($match[2]) ? '' : '.'.(ord($match[2]) - 96)); + $prettyVersion = preg_replace_callback('{^(?:OpenSSL\s*)?([0-9.]+)([a-z]+).*}', function ($match) { + if (empty($match[2])) { + return $match[1]; + } + + // OpenSSL versions add another letter when they reach Z. + // e.g. OpenSSL 0.9.8zh 3 Dec 2015 + $patchVersion = array_sum(array_map(function ($letter) { + return ord($letter) - 96; + }, str_split($match[2]))); + + return $match[1].'.'.$patchVersion; }, OPENSSL_VERSION_TEXT); break;