292 lines
5.1 KiB
PHP
292 lines
5.1 KiB
PHP
|
<?php
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
namespace Composer;
|
||
|
|
||
|
use Composer\Semver\VersionParser;
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
class InstalledVersions
|
||
|
{
|
||
|
private static $installed = array (
|
||
|
'root' =>
|
||
|
array (
|
||
|
'pretty_version' => 'dev-develop',
|
||
|
'version' => 'dev-develop',
|
||
|
'aliases' =>
|
||
|
array (
|
||
|
),
|
||
|
'reference' => '22b33105768561e48c79c283cb2e7d960f89558f',
|
||
|
'name' => 'getgrav/grav-plugin-email',
|
||
|
),
|
||
|
'versions' =>
|
||
|
array (
|
||
|
'doctrine/lexer' =>
|
||
|
array (
|
||
|
'pretty_version' => '1.2.1',
|
||
|
'version' => '1.2.1.0',
|
||
|
'aliases' =>
|
||
|
array (
|
||
|
),
|
||
|
'reference' => 'e864bbf5904cb8f5bb334f99209b48018522f042',
|
||
|
),
|
||
|
'egulias/email-validator' =>
|
||
|
array (
|
||
|
'pretty_version' => '2.1.25',
|
||
|
'version' => '2.1.25.0',
|
||
|
'aliases' =>
|
||
|
array (
|
||
|
),
|
||
|
'reference' => '0dbf5d78455d4d6a41d186da50adc1122ec066f4',
|
||
|
),
|
||
|
'getgrav/grav-plugin-email' =>
|
||
|
array (
|
||
|
'pretty_version' => 'dev-develop',
|
||
|
'version' => 'dev-develop',
|
||
|
'aliases' =>
|
||
|
array (
|
||
|
),
|
||
|
'reference' => '22b33105768561e48c79c283cb2e7d960f89558f',
|
||
|
),
|
||
|
'swiftmailer/swiftmailer' =>
|
||
|
array (
|
||
|
'pretty_version' => 'v6.2.5',
|
||
|
'version' => '6.2.5.0',
|
||
|
'aliases' =>
|
||
|
array (
|
||
|
),
|
||
|
'reference' => '698a6a9f54d7eb321274de3ad19863802c879fb7',
|
||
|
),
|
||
|
'symfony/polyfill-iconv' =>
|
||
|
array (
|
||
|
'pretty_version' => 'v1.22.0',
|
||
|
'version' => '1.22.0.0',
|
||
|
'aliases' =>
|
||
|
array (
|
||
|
),
|
||
|
'reference' => 'b34bfb8c4c22650ac080d2662ae3502e5f2f4ae6',
|
||
|
),
|
||
|
'symfony/polyfill-intl-idn' =>
|
||
|
array (
|
||
|
'pretty_version' => 'v1.22.0',
|
||
|
'version' => '1.22.0.0',
|
||
|
'aliases' =>
|
||
|
array (
|
||
|
),
|
||
|
'reference' => '0eb8293dbbcd6ef6bf81404c9ce7d95bcdf34f44',
|
||
|
),
|
||
|
'symfony/polyfill-intl-normalizer' =>
|
||
|
array (
|
||
|
'pretty_version' => 'v1.22.0',
|
||
|
'version' => '1.22.0.0',
|
||
|
'aliases' =>
|
||
|
array (
|
||
|
),
|
||
|
'reference' => '6e971c891537eb617a00bb07a43d182a6915faba',
|
||
|
),
|
||
|
'symfony/polyfill-mbstring' =>
|
||
|
array (
|
||
|
'pretty_version' => 'v1.22.0',
|
||
|
'version' => '1.22.0.0',
|
||
|
'aliases' =>
|
||
|
array (
|
||
|
),
|
||
|
'reference' => 'f377a3dd1fde44d37b9831d68dc8dea3ffd28e13',
|
||
|
),
|
||
|
'symfony/polyfill-php72' =>
|
||
|
array (
|
||
|
'pretty_version' => 'v1.22.0',
|
||
|
'version' => '1.22.0.0',
|
||
|
'aliases' =>
|
||
|
array (
|
||
|
),
|
||
|
'reference' => 'cc6e6f9b39fe8075b3dabfbaf5b5f645ae1340c9',
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
}
|