408 lines
8.0 KiB
PHP
408 lines
8.0 KiB
PHP
<?php
|
|
|
|
namespace Composer;
|
|
|
|
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 (
|
|
'league/flysystem' =>
|
|
array (
|
|
'pretty_version' => '1.1.3',
|
|
'version' => '1.1.3.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '9be3b16c877d477357c015cec057548cf9b2a14a',
|
|
),
|
|
'league/flysystem-cached-adapter' =>
|
|
array (
|
|
'pretty_version' => '1.1.0',
|
|
'version' => '1.1.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'd1925efb2207ac4be3ad0c40b8277175f99ffaff',
|
|
),
|
|
'league/mime-type-detection' =>
|
|
array (
|
|
'pretty_version' => '1.5.1',
|
|
'version' => '1.5.1.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '353f66d7555d8a90781f6f5e7091932f9a4250aa',
|
|
),
|
|
'phpmailer/phpmailer' =>
|
|
array (
|
|
'pretty_version' => 'v6.1.7',
|
|
'version' => '6.1.7.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '2c2370ba3df7034f9eb7b8f387c97b52b2ba5ad0',
|
|
),
|
|
'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/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',
|
|
),
|
|
'symfony/polyfill-mbstring' =>
|
|
array (
|
|
'pretty_version' => 'v1.20.0',
|
|
'version' => '1.20.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '39d483bdf39be819deabf04ec872eb0b2410b531',
|
|
),
|
|
'symfony/polyfill-php72' =>
|
|
array (
|
|
'pretty_version' => 'v1.20.0',
|
|
'version' => '1.20.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'cede45fcdfabdd6043b3592e83678e42ec69e930',
|
|
),
|
|
'symfony/polyfill-php80' =>
|
|
array (
|
|
'pretty_version' => 'v1.20.0',
|
|
'version' => '1.20.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'e70aa8b064c5b72d3df2abd5ab1e90464ad009de',
|
|
),
|
|
'symfony/var-dumper' =>
|
|
array (
|
|
'pretty_version' => 'v4.4.16',
|
|
'version' => '4.4.16.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '3718e18b68d955348ad860e505991802c09f5f73',
|
|
),
|
|
'taoser/think-auth' =>
|
|
array (
|
|
'pretty_version' => 'v1.0.0',
|
|
'version' => '1.0.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '19bb04e4fb957a95ff3fdc142939922c19167b43',
|
|
),
|
|
'topthink/framework' =>
|
|
array (
|
|
'pretty_version' => 'v6.0.5',
|
|
'version' => '6.0.5.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '85625d984f5c96699dc27d384869f206c3aec1cc',
|
|
),
|
|
'topthink/think' =>
|
|
array (
|
|
'pretty_version' => '1.0.0+no-version-set',
|
|
'version' => '1.0.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => NULL,
|
|
),
|
|
'topthink/think-captcha' =>
|
|
array (
|
|
'pretty_version' => 'v3.0.3',
|
|
'version' => '3.0.3.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '1eef3717c1bcf4f5bbe2d1a1c704011d330a8b55',
|
|
),
|
|
'topthink/think-helper' =>
|
|
array (
|
|
'pretty_version' => 'v3.1.4',
|
|
'version' => '3.1.4.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'c28d37743bda4a0455286ca85b17b5791d626e10',
|
|
),
|
|
'topthink/think-multi-app' =>
|
|
array (
|
|
'pretty_version' => 'v1.0.14',
|
|
'version' => '1.0.14.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'ccaad7c2d33f42cb1cc2a78d6610aaec02cea4c3',
|
|
),
|
|
'topthink/think-orm' =>
|
|
array (
|
|
'pretty_version' => 'v2.0.34',
|
|
'version' => '2.0.34.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '57f9b98895b0ff4ae7b7b75e51456fd8cb8fb629',
|
|
),
|
|
'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.4',
|
|
'version' => '1.4.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '9a9fa8f767b6c66c5a133ad21ca1bc96ad329444',
|
|
),
|
|
'topthink/think-view' =>
|
|
array (
|
|
'pretty_version' => 'v1.0.14',
|
|
'version' => '1.0.14.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'edce0ae2c9551ab65f9e94a222604b0dead3576d',
|
|
),
|
|
'zzstudio/think-addons' =>
|
|
array (
|
|
'pretty_version' => '2.0.5',
|
|
'version' => '2.0.5.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '7eb740cb219a111d593a05ad88248a74f640fe5c',
|
|
),
|
|
),
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function getInstalledPackages()
|
|
{
|
|
return array_keys(self::$installed['versions']);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function isInstalled($packageName)
|
|
{
|
|
return isset(self::$installed['versions'][$packageName]);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
{
|
|
if (!isset(self::$installed['versions'][$packageName])) {
|
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
}
|
|
|
|
$ranges = array();
|
|
if (isset(self::$installed['versions'][$packageName]['pretty_version'])) {
|
|
$ranges[] = self::$installed['versions'][$packageName]['pretty_version'];
|
|
}
|
|
if (array_key_exists('aliases', self::$installed['versions'][$packageName])) {
|
|
$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']);
|
|
}
|
|
if (array_key_exists('replaced', self::$installed['versions'][$packageName])) {
|
|
$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']);
|
|
}
|
|
if (array_key_exists('provided', self::$installed['versions'][$packageName])) {
|
|
$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']);
|
|
}
|
|
|
|
return implode(' || ', $ranges);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function getVersion($packageName)
|
|
{
|
|
if (!isset(self::$installed['versions'][$packageName])) {
|
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
}
|
|
|
|
if (!isset(self::$installed['versions'][$packageName]['version'])) {
|
|
return null;
|
|
}
|
|
|
|
return self::$installed['versions'][$packageName]['version'];
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function getPrettyVersion($packageName)
|
|
{
|
|
if (!isset(self::$installed['versions'][$packageName])) {
|
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
}
|
|
|
|
if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) {
|
|
return null;
|
|
}
|
|
|
|
return self::$installed['versions'][$packageName]['pretty_version'];
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function getReference($packageName)
|
|
{
|
|
if (!isset(self::$installed['versions'][$packageName])) {
|
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
}
|
|
|
|
if (!isset(self::$installed['versions'][$packageName]['reference'])) {
|
|
return null;
|
|
}
|
|
|
|
return self::$installed['versions'][$packageName]['reference'];
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function getRootPackage()
|
|
{
|
|
return self::$installed['root'];
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function getRawData()
|
|
{
|
|
return self::$installed;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function reload($data)
|
|
{
|
|
self::$installed = $data;
|
|
}
|
|
}
|