640 lines
13 KiB
PHP
640 lines
13 KiB
PHP
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Composer;
|
|
|
|
use Composer\Autoload\ClassLoader;
|
|
use Composer\Semver\VersionParser;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InstalledVersions
|
|
{
|
|
private static $installed = array (
|
|
'root' =>
|
|
array (
|
|
'pretty_version' => '1.0.0+no-version-set',
|
|
'version' => '1.0.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => NULL,
|
|
'name' => 'topthink/think',
|
|
),
|
|
'versions' =>
|
|
array (
|
|
'adbario/php-dot-notation' =>
|
|
array (
|
|
'pretty_version' => '2.2.0',
|
|
'version' => '2.2.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'eee4fc81296531e6aafba4c2bbccfc5adab1676e',
|
|
),
|
|
'alibabacloud/client' =>
|
|
array (
|
|
'pretty_version' => '1.5.31',
|
|
'version' => '1.5.31.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '19224d92fe27ab8ef501d77d4891e7660bc023c1',
|
|
),
|
|
'clagiordano/weblibs-configmanager' =>
|
|
array (
|
|
'pretty_version' => 'v1.4.0',
|
|
'version' => '1.4.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '8ff8bf195d0cbab9fe2ad3199c70920261300834',
|
|
),
|
|
'danielstjules/stringy' =>
|
|
array (
|
|
'pretty_version' => '3.1.0',
|
|
'version' => '3.1.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'df24ab62d2d8213bbbe88cc36fc35a4503b4bd7e',
|
|
),
|
|
'ezyang/htmlpurifier' =>
|
|
array (
|
|
'pretty_version' => 'v4.13.0',
|
|
'version' => '4.13.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '08e27c97e4c6ed02f37c5b2b20488046c8d90d75',
|
|
),
|
|
'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',
|
|
),
|
|
'league/flysystem' =>
|
|
array (
|
|
'pretty_version' => '1.0.70',
|
|
'version' => '1.0.70.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '585824702f534f8d3cf7fab7225e8466cc4b7493',
|
|
),
|
|
'league/flysystem-cached-adapter' =>
|
|
array (
|
|
'pretty_version' => '1.1.0',
|
|
'version' => '1.1.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'd1925efb2207ac4be3ad0c40b8277175f99ffaff',
|
|
),
|
|
'maennchen/zipstream-php' =>
|
|
array (
|
|
'pretty_version' => '2.1.0',
|
|
'version' => '2.1.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'c4c5803cc1f93df3d2448478ef79394a5981cc58',
|
|
),
|
|
'markbaker/complex' =>
|
|
array (
|
|
'pretty_version' => '2.0.3',
|
|
'version' => '2.0.3.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '6f724d7e04606fd8adaa4e3bb381c3e9db09c946',
|
|
),
|
|
'markbaker/matrix' =>
|
|
array (
|
|
'pretty_version' => '2.1.3',
|
|
'version' => '2.1.3.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '174395a901b5ba0925f1d790fa91bab531074b61',
|
|
),
|
|
'mtdowling/jmespath.php' =>
|
|
array (
|
|
'pretty_version' => '2.6.1',
|
|
'version' => '2.6.1.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '9b87907a81b87bc76d19a7fb2d61e61486ee9edb',
|
|
),
|
|
'myclabs/php-enum' =>
|
|
array (
|
|
'pretty_version' => '1.8.3',
|
|
'version' => '1.8.3.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'b942d263c641ddb5190929ff840c68f78713e937',
|
|
),
|
|
'opis/closure' =>
|
|
array (
|
|
'pretty_version' => '3.5.5',
|
|
'version' => '3.5.5.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'dec9fc5ecfca93f45cd6121f8e6f14457dff372c',
|
|
),
|
|
'phpoffice/phpspreadsheet' =>
|
|
array (
|
|
'pretty_version' => '1.18.0',
|
|
'version' => '1.18.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '418cd304e8e6b417ea79c3b29126a25dc4b1170c',
|
|
),
|
|
'psr/cache' =>
|
|
array (
|
|
'pretty_version' => '1.0.1',
|
|
'version' => '1.0.1.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'd11b50ad223250cf17b86e38383413f5a6764bf8',
|
|
),
|
|
'psr/container' =>
|
|
array (
|
|
'pretty_version' => '1.0.0',
|
|
'version' => '1.0.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'b7ce3b176482dbbc1245ebf52b181af44c2cf55f',
|
|
),
|
|
'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-factory' =>
|
|
array (
|
|
'pretty_version' => '1.0.1',
|
|
'version' => '1.0.1.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '12ac7fcd07e5b077433f5f2bee95b3a771bf61be',
|
|
),
|
|
'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.3',
|
|
'version' => '1.1.3.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '0f73288fd15629204f9d42b7055f72dacbe811fc',
|
|
),
|
|
'psr/simple-cache' =>
|
|
array (
|
|
'pretty_version' => '1.0.1',
|
|
'version' => '1.0.1.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '408d5eafb83c57f6365a3ca330ff23aa4a5fa39b',
|
|
),
|
|
'ralouphie/getallheaders' =>
|
|
array (
|
|
'pretty_version' => '3.0.3',
|
|
'version' => '3.0.3.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '120b605dfeb996808c31b6477290a714d356e822',
|
|
),
|
|
'symfony/polyfill-ctype' =>
|
|
array (
|
|
'pretty_version' => 'v1.23.0',
|
|
'version' => '1.23.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '46cd95797e9df938fdd2b03693b5fca5e64b01ce',
|
|
),
|
|
'symfony/polyfill-mbstring' =>
|
|
array (
|
|
'pretty_version' => 'v1.18.1',
|
|
'version' => '1.18.1.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'a6977d63bf9a0ad4c65cd352709e230876f9904a',
|
|
),
|
|
'symfony/polyfill-php72' =>
|
|
array (
|
|
'pretty_version' => 'v1.18.1',
|
|
'version' => '1.18.1.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '639447d008615574653fb3bc60d1986d7172eaae',
|
|
),
|
|
'symfony/polyfill-php80' =>
|
|
array (
|
|
'pretty_version' => 'v1.18.1',
|
|
'version' => '1.18.1.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'd87d5766cbf48d72388a9f6b85f280c8ad51f981',
|
|
),
|
|
'symfony/var-dumper' =>
|
|
array (
|
|
'pretty_version' => 'v4.4.11',
|
|
'version' => '4.4.11.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '2125805a1a4e57f2340bc566c3013ca94d2722dc',
|
|
),
|
|
'symfony/yaml' =>
|
|
array (
|
|
'pretty_version' => 'v2.8.52',
|
|
'version' => '2.8.52.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '02c1859112aa779d9ab394ae4f3381911d84052b',
|
|
),
|
|
'topthink/framework' =>
|
|
array (
|
|
'pretty_version' => 'v6.0.3',
|
|
'version' => '6.0.3.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'b4046fb21e6163ba23a792b694162693dbe71b4b',
|
|
),
|
|
'topthink/think' =>
|
|
array (
|
|
'pretty_version' => '1.0.0+no-version-set',
|
|
'version' => '1.0.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => NULL,
|
|
),
|
|
'topthink/think-helper' =>
|
|
array (
|
|
'pretty_version' => 'v3.1.4',
|
|
'version' => '3.1.4.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'c28d37743bda4a0455286ca85b17b5791d626e10',
|
|
),
|
|
'topthink/think-image' =>
|
|
array (
|
|
'pretty_version' => 'v1.0.7',
|
|
'version' => '1.0.7.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '8586cf47f117481c6d415b20f7dedf62e79d5512',
|
|
),
|
|
'topthink/think-orm' =>
|
|
array (
|
|
'pretty_version' => 'v2.0.33',
|
|
'version' => '2.0.33.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '35ca511a1e4d671b39f7afb4c887703c16ef6957',
|
|
),
|
|
'topthink/think-template' =>
|
|
array (
|
|
'pretty_version' => 'v2.0.7',
|
|
'version' => '2.0.7.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'e98bdbb4a4c94b442f17dfceba81e0134d4fbd19',
|
|
),
|
|
'topthink/think-trace' =>
|
|
array (
|
|
'pretty_version' => 'v1.3',
|
|
'version' => '1.3.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'd8da2e39df268ab8775013de699f0c3012e51318',
|
|
),
|
|
'topthink/think-view' =>
|
|
array (
|
|
'pretty_version' => 'v1.0.14',
|
|
'version' => '1.0.14.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'edce0ae2c9551ab65f9e94a222604b0dead3576d',
|
|
),
|
|
),
|
|
);
|
|
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;
|
|
}
|
|
}
|