123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568 |
- <?php
- namespace Composer;
- use Composer\Autoload\ClassLoader;
- use Composer\Semver\VersionParser;
- class InstalledVersions
- {
- private static $installed = array (
- 'root' =>
- array (
- 'pretty_version' => 'v2.9.2',
- 'version' => '2.9.2.0',
- 'aliases' =>
- array (
- ),
- 'reference' => NULL,
- 'name' => 'showdoc/showdoc',
- ),
- 'versions' =>
- array (
- 'guzzle/batch' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/cache' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/common' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/guzzle' =>
- array (
- 'pretty_version' => 'v3.9.3',
- 'version' => '3.9.3.0',
- 'aliases' =>
- array (
- ),
- 'reference' => '0645b70d953bc1c067bbc8d5bc53194706b628d9',
- ),
- 'guzzle/http' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/inflection' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/iterator' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/log' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/parser' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/plugin' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/plugin-async' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/plugin-backoff' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/plugin-cache' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/plugin-cookie' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/plugin-curlauth' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/plugin-error-response' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/plugin-history' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/plugin-log' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/plugin-md5' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/plugin-mock' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/plugin-oauth' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/service' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzle/stream' =>
- array (
- 'replaced' =>
- array (
- 0 => 'v3.9.3',
- ),
- ),
- 'guzzlehttp/guzzle' =>
- array (
- 'pretty_version' => '7.3.0',
- 'version' => '7.3.0.0',
- 'aliases' =>
- array (
- ),
- 'reference' => '7008573787b430c1c1f650e3722d9bba59967628',
- ),
- 'guzzlehttp/promises' =>
- array (
- 'pretty_version' => '1.4.1',
- 'version' => '1.4.1.0',
- 'aliases' =>
- array (
- ),
- 'reference' => '8e7d04f1f6450fef59366c399cfad4b9383aa30d',
- ),
- 'guzzlehttp/psr7' =>
- array (
- 'pretty_version' => '1.8.2',
- 'version' => '1.8.2.0',
- 'aliases' =>
- array (
- ),
- 'reference' => 'dc960a912984efb74d0a90222870c72c87f10c91',
- ),
- 'jasig/phpcas' =>
- array (
- 'pretty_version' => '1.3.9',
- 'version' => '1.3.9.0',
- 'aliases' =>
- array (
- ),
- 'reference' => '7325865c4cfb5005ed4e4c5cf01823be1726a2a0',
- ),
- 'league/oauth2-client' =>
- array (
- 'pretty_version' => '2.6.0',
- 'version' => '2.6.0.0',
- 'aliases' =>
- array (
- ),
- 'reference' => 'badb01e62383430706433191b82506b6df24ad98',
- ),
- 'paragonie/random_compat' =>
- array (
- 'pretty_version' => 'v9.99.100',
- 'version' => '9.99.100.0',
- 'aliases' =>
- array (
- ),
- 'reference' => '996434e5492cb4c3edcb9168db6fbb1359ef965a',
- ),
- 'psr/http-client' =>
- array (
- 'pretty_version' => '1.0.1',
- 'version' => '1.0.1.0',
- 'aliases' =>
- array (
- ),
- 'reference' => '2dfb5f6c5eff0e91e20e913f8c5452ed95b86621',
- ),
- 'psr/http-client-implementation' =>
- array (
- 'provided' =>
- array (
- 0 => '1.0',
- ),
- ),
- 'psr/http-message' =>
- array (
- 'pretty_version' => '1.0.1',
- 'version' => '1.0.1.0',
- 'aliases' =>
- array (
- ),
- 'reference' => 'f6561bf28d520154e4b0ec72be95418abe6d9363',
- ),
- 'psr/http-message-implementation' =>
- array (
- 'provided' =>
- array (
- 0 => '1.0',
- ),
- ),
- 'psr/log' =>
- array (
- 'pretty_version' => '1.1.4',
- 'version' => '1.1.4.0',
- 'aliases' =>
- array (
- ),
- 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
- ),
- 'qcloud/cos-sdk-v5' =>
- array (
- 'pretty_version' => 'v1.3.4',
- 'version' => '1.3.4.0',
- 'aliases' =>
- array (
- ),
- 'reference' => '1b32aa422f6dffe4ea411e5095e4b0da9135551b',
- ),
- 'ralouphie/getallheaders' =>
- array (
- 'pretty_version' => '3.0.3',
- 'version' => '3.0.3.0',
- 'aliases' =>
- array (
- ),
- 'reference' => '120b605dfeb996808c31b6477290a714d356e822',
- ),
- 'showdoc/showdoc' =>
- array (
- 'pretty_version' => 'v2.9.2',
- 'version' => '2.9.2.0',
- 'aliases' =>
- array (
- ),
- 'reference' => NULL,
- ),
- 'symfony/event-dispatcher' =>
- array (
- 'pretty_version' => 'v2.8.52',
- 'version' => '2.8.52.0',
- 'aliases' =>
- array (
- ),
- 'reference' => 'a77e974a5fecb4398833b0709210e3d5e334ffb0',
- ),
- ),
- );
- private static $canGetVendors;
- private static $installedByVendor = array();
- public static function getInstalledPackages()
- {
- $packages = array();
- foreach (self::getInstalled() as $installed) {
- $packages[] = array_keys($installed['versions']);
- }
- if (1 === \count($packages)) {
- return $packages[0];
- }
- return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
- }
- public static function isInstalled($packageName)
- {
- foreach (self::getInstalled() as $installed) {
- if (isset($installed['versions'][$packageName])) {
- return true;
- }
- }
- return false;
- }
- public static function satisfies(VersionParser $parser, $packageName, $constraint)
- {
- $constraint = $parser->parseConstraints($constraint);
- $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
- return $provided->matches($constraint);
- }
- public static function getVersionRanges($packageName)
- {
- foreach (self::getInstalled() as $installed) {
- if (!isset($installed['versions'][$packageName])) {
- continue;
- }
- $ranges = array();
- if (isset($installed['versions'][$packageName]['pretty_version'])) {
- $ranges[] = $installed['versions'][$packageName]['pretty_version'];
- }
- if (array_key_exists('aliases', $installed['versions'][$packageName])) {
- $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
- }
- if (array_key_exists('replaced', $installed['versions'][$packageName])) {
- $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
- }
- if (array_key_exists('provided', $installed['versions'][$packageName])) {
- $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
- }
- return implode(' || ', $ranges);
- }
- throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
- }
- public static function getVersion($packageName)
- {
- foreach (self::getInstalled() as $installed) {
- if (!isset($installed['versions'][$packageName])) {
- continue;
- }
- if (!isset($installed['versions'][$packageName]['version'])) {
- return null;
- }
- return $installed['versions'][$packageName]['version'];
- }
- throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
- }
- public static function getPrettyVersion($packageName)
- {
- foreach (self::getInstalled() as $installed) {
- if (!isset($installed['versions'][$packageName])) {
- continue;
- }
- if (!isset($installed['versions'][$packageName]['pretty_version'])) {
- return null;
- }
- return $installed['versions'][$packageName]['pretty_version'];
- }
- throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
- }
- public static function getReference($packageName)
- {
- foreach (self::getInstalled() as $installed) {
- if (!isset($installed['versions'][$packageName])) {
- continue;
- }
- if (!isset($installed['versions'][$packageName]['reference'])) {
- return null;
- }
- return $installed['versions'][$packageName]['reference'];
- }
- throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
- }
- public static function getRootPackage()
- {
- $installed = self::getInstalled();
- return $installed[0]['root'];
- }
- public static function getRawData()
- {
- return self::$installed;
- }
- public static function reload($data)
- {
- self::$installed = $data;
- self::$installedByVendor = array();
- }
- private static function getInstalled()
- {
- if (null === self::$canGetVendors) {
- self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
- }
- $installed = array();
- if (self::$canGetVendors) {
- foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
- if (isset(self::$installedByVendor[$vendorDir])) {
- $installed[] = self::$installedByVendor[$vendorDir];
- } elseif (is_file($vendorDir.'/composer/installed.php')) {
- $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
- }
- }
- }
- $installed[] = self::$installed;
- return $installed;
- }
- }
|