array ( 'pretty_version' => 'dev-master', 'version' => 'dev-master', 'aliases' => array ( ), 'reference' => '614b390342771c50886f51d18321295bcb06eb6a', 'name' => '__root__', ), 'versions' => array ( '__root__' => array ( 'pretty_version' => 'dev-master', 'version' => 'dev-master', 'aliases' => array ( ), 'reference' => '614b390342771c50886f51d18321295bcb06eb6a', ), 'firebase/php-jwt' => array ( 'pretty_version' => 'v6.1.2', 'version' => '6.1.2.0', 'aliases' => array ( ), 'reference' => 'c297139da7c6873dbd67cbd1093f09ec0bbd0c50', ), 'google/apiclient' => array ( 'pretty_version' => 'v2.12.4', 'version' => '2.12.4.0', 'aliases' => array ( ), 'reference' => '702eed9ae7022ba20dc7118c8161060cb50ee9f8', ), 'google/apiclient-services' => array ( 'pretty_version' => 'v0.246.0', 'version' => '0.246.0.0', 'aliases' => array ( ), 'reference' => '33aef1ccce34799a1124c39951fed8ad0b16aced', ), 'google/auth' => array ( 'pretty_version' => 'v1.21.0', 'version' => '1.21.0.0', 'aliases' => array ( ), 'reference' => '73392bad2eb6852eea9084b6bbdec752515cb849', ), 'guzzlehttp/guzzle' => array ( 'pretty_version' => '6.5.5', 'version' => '6.5.5.0', 'aliases' => array ( ), 'reference' => '9d4290de1cfd701f38099ef7e183b64b4b7b0c5e', ), 'guzzlehttp/promises' => array ( 'pretty_version' => '1.5.1', 'version' => '1.5.1.0', 'aliases' => array ( ), 'reference' => 'fe752aedc9fd8fcca3fe7ad05d419d32998a06da', ), 'guzzlehttp/psr7' => array ( 'pretty_version' => '1.8.5', 'version' => '1.8.5.0', 'aliases' => array ( ), 'reference' => '337e3ad8e5716c15f9657bd214d16cc5e69df268', ), 'monolog/monolog' => array ( 'pretty_version' => '2.5.0', 'version' => '2.5.0.0', 'aliases' => array ( ), 'reference' => '4192345e260f1d51b365536199744b987e160edc', ), 'paragonie/constant_time_encoding' => array ( 'pretty_version' => 'v2.5.0', 'version' => '2.5.0.0', 'aliases' => array ( ), 'reference' => '9229e15f2e6ba772f0c55dd6986c563b937170a8', ), 'paragonie/random_compat' => array ( 'pretty_version' => 'v9.99.100', 'version' => '9.99.100.0', 'aliases' => array ( ), 'reference' => '996434e5492cb4c3edcb9168db6fbb1359ef965a', ), 'phpseclib/phpseclib' => array ( 'pretty_version' => '3.0.14', 'version' => '3.0.14.0', 'aliases' => array ( ), 'reference' => '2f0b7af658cbea265cbb4a791d6c29a6613f98ef', ), 'psr/cache' => array ( 'pretty_version' => '1.0.1', 'version' => '1.0.1.0', 'aliases' => array ( ), 'reference' => 'd11b50ad223250cf17b86e38383413f5a6764bf8', ), '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', ), 'psr/log-implementation' => array ( 'provided' => array ( 0 => '1.0.0 || 2.0.0 || 3.0.0', ), ), 'ralouphie/getallheaders' => array ( 'pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'aliases' => array ( ), 'reference' => '120b605dfeb996808c31b6477290a714d356e822', ), 'symfony/polyfill-intl-idn' => array ( 'pretty_version' => 'v1.25.0', 'version' => '1.25.0.0', 'aliases' => array ( ), 'reference' => '749045c69efb97c70d25d7463abba812e91f3a44', ), 'symfony/polyfill-intl-normalizer' => array ( 'pretty_version' => 'v1.25.0', 'version' => '1.25.0.0', 'aliases' => array ( ), 'reference' => '8590a5f561694770bdcd3f9b5c69dde6945028e8', ), 'symfony/polyfill-php72' => array ( 'pretty_version' => 'v1.25.0', 'version' => '1.25.0.0', 'aliases' => array ( ), 'reference' => '9a142215a36a3888e30d0a9eeea9766764e96976', ), ), ); 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; } }