1
0
Fork 0

Changed PlatformRepository to handle libraries as well now

pull/822/head
Christian Riesen 2012-06-22 14:54:03 +02:00
parent 7b49b013ec
commit 8d3c85225f
1 changed files with 57 additions and 38 deletions

View File

@ -38,59 +38,78 @@ class PlatformRepository extends ArrayRepository
$php = new MemoryPackage('php', $version, $prettyVersion); $php = new MemoryPackage('php', $version, $prettyVersion);
$php->setDescription('The PHP interpreter'); $php->setDescription('The PHP interpreter');
parent::addPackage($php); parent::addPackage($php);
foreach (get_loaded_extensions() as $name) { $loadedExtensions = get_loaded_extensions();
// Extensions scanning
foreach ($loadedExtensions as $name) {
switch ($name) { switch ($name) {
// Skipped "extensions" // Skipped "extensions"
case 'standard': case 'standard':
case 'Core': case 'Core':
continue; 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 // All normal cases for standard extensions
default: default:
$reflExt = new \ReflectionExtension($name); $reflExt = new \ReflectionExtension($name);
$prettyVersion = $reflExt->getVersion();
try {
$prettyVersion = $reflExt->getVersion();
$version = $versionParser->normalize($prettyVersion);
} catch (\UnexpectedValueException $e) {
$prettyVersion = '0';
$version = $versionParser->normalize($prettyVersion);
}
break; break;
} }
try {
$version = $versionParser->normalize($prettyVersion);
} catch (\UnexpectedValueException $e) {
$prettyVersion = '0';
$version = $versionParser->normalize($prettyVersion);
}
$ext = new MemoryPackage('ext-'.$name, $version, $prettyVersion); $ext = new MemoryPackage('ext-'.$name, $version, $prettyVersion);
$ext->setDescription('The '.$name.' PHP extension'); $ext->setDescription('The '.$name.' PHP extension');
parent::addPackage($ext); parent::addPackage($ext);
} }
// Another quick loop, just for possible libraries
foreach ($loadedExtensions as $name) {
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'];
break;
case 'libxml':
$prettyVersion = LIBXML_DOTTED_VERSION;
break;
case 'openssl':
$prettyVersion = str_replace('OpenSSL', '', OPENSSL_VERSION_TEXT);
$prettyVersion = trim($prettyVersion);
break;
case 'pcre':
$prettyVersion = PCRE_VERSION;
break;
default:
// None handled extensions have no special cases, skip
continue;
}
try {
$version = $versionParser->normalize($prettyVersion);
} catch (\UnexpectedValueException $e) {
$prettyVersion = '0';
$version = $versionParser->normalize($prettyVersion);
}
$ext = new MemoryPackage('lib-'.$name, $version, $prettyVersion);
$ext->setDescription('The '.$name.' PHP library');
parent::addPackage($ext);
}
} }
} }