From 7b49b013ec85c8a0d5cfe8b71ec2f720bc6048a4 Mon Sep 17 00:00:00 2001 From: Christian Riesen Date: Fri, 22 Jun 2012 13:51:26 +0200 Subject: [PATCH] PlatformRepository now knows curl and libxml versions --- .../Repository/PlatformRepository.php | 57 +++++++++++++++---- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 495155276..32380eff2 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -40,17 +40,52 @@ class PlatformRepository extends ArrayRepository parent::addPackage($php); foreach (get_loaded_extensions() as $name) { - if (in_array($name, array('standard', 'Core'))) { - continue; - } - - $reflExt = new \ReflectionExtension($name); - try { - $prettyVersion = $reflExt->getVersion(); - $version = $versionParser->normalize($prettyVersion); - } catch (\UnexpectedValueException $e) { - $prettyVersion = '0'; - $version = $versionParser->normalize($prettyVersion); + switch ($name) { + // Skipped "extensions" + case 'standard': + case 'Core': + continue; + + // Curl exposes its version by the curl_version function + case 'curl': + $curlversion = curl_version(); + $prettyVersion = $curlversion['version']; + + try { + $version = $versionParser->normalize($prettyVersion); + } catch (\UnexpectedValueException $e) { + $prettyVersion = '0'; + $version = $versionParser->normalize($prettyVersion); + } + + break; + + + case 'libxml': + $prettyVersion = LIBXML_DOTTED_VERSION; + + try { + $version = $versionParser->normalize($prettyVersion); + } catch (\UnexpectedValueException $e) { + $prettyVersion = '0'; + $version = $versionParser->normalize($prettyVersion); + } + + break; + + // All normal cases for standard extensions + default: + $reflExt = new \ReflectionExtension($name); + + try { + $prettyVersion = $reflExt->getVersion(); + $version = $versionParser->normalize($prettyVersion); + } catch (\UnexpectedValueException $e) { + $prettyVersion = '0'; + $version = $versionParser->normalize($prettyVersion); + } + + break; } $ext = new MemoryPackage('ext-'.$name, $version, $prettyVersion);