2021-11-16 20:36:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Composer;
|
|
|
|
|
|
|
|
use Composer\Semver\VersionParser;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InstalledVersions
|
|
|
|
{
|
|
|
|
private static $installed = array (
|
|
|
|
'root' =>
|
|
|
|
array (
|
2022-11-23 17:25:10 +00:00
|
|
|
'pretty_version' => '1.0.0+no-version-set',
|
|
|
|
'version' => '1.0.0.0',
|
2021-11-16 20:36:33 +00:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2022-11-23 17:25:10 +00:00
|
|
|
'reference' => NULL,
|
2021-11-16 20:36:33 +00:00
|
|
|
'name' => 'friendica-addons/securemail',
|
|
|
|
),
|
|
|
|
'versions' =>
|
|
|
|
array (
|
|
|
|
'friendica-addons/securemail' =>
|
|
|
|
array (
|
2022-11-23 17:25:10 +00:00
|
|
|
'pretty_version' => '1.0.0+no-version-set',
|
|
|
|
'version' => '1.0.0.0',
|
2021-11-16 20:36:33 +00:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2022-11-23 17:25:10 +00:00
|
|
|
'reference' => NULL,
|
|
|
|
),
|
|
|
|
'paragonie/constant_time_encoding' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => 'v2.6.3',
|
|
|
|
'version' => '2.6.3.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => '58c3f47f650c94ec05a151692652a868995d2938',
|
|
|
|
),
|
|
|
|
'paragonie/random_compat' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => 'v9.99.100',
|
|
|
|
'version' => '9.99.100.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => '996434e5492cb4c3edcb9168db6fbb1359ef965a',
|
2021-11-16 20:36:33 +00:00
|
|
|
),
|
|
|
|
'phpseclib/phpseclib' =>
|
|
|
|
array (
|
2022-11-23 17:25:10 +00:00
|
|
|
'pretty_version' => '3.0.17',
|
|
|
|
'version' => '3.0.17.0',
|
2021-11-16 20:36:33 +00:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2022-11-23 17:25:10 +00:00
|
|
|
'reference' => 'dbc2307d5c69aeb22db136c52e91130d7f2ca761',
|
2021-11-16 20:36:33 +00:00
|
|
|
),
|
|
|
|
'singpolyma/openpgp-php' =>
|
|
|
|
array (
|
2022-11-23 17:25:10 +00:00
|
|
|
'pretty_version' => '0.6.0',
|
|
|
|
'version' => '0.6.0.0',
|
2021-11-16 20:36:33 +00:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2022-11-23 17:25:10 +00:00
|
|
|
'reference' => '1c3bdcd2d9c6113c2d6b768e208e7432a48d3a1e',
|
2021-11-16 20:36:33 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|