site-tordv-calculator/vendor/composer/InstalledVersions.php

410 lines
7.5 KiB
PHP

<?php
namespace Composer;
use Composer\Autoload\ClassLoader;
use Composer\Semver\VersionParser;
class InstalledVersions
{
private static $installed = array (
'root' =>
array (
'pretty_version' => 'dev-stable',
'version' => 'dev-stable',
'aliases' =>
array (
),
'reference' => '503e25647cabfd80c98a1ca571a98e4b0595b729',
'name' => 'mirzaev/calculator',
),
'versions' =>
array (
'ezyang/htmlpurifier' =>
array (
'pretty_version' => 'v4.14.0',
'version' => '4.14.0.0',
'aliases' =>
array (
),
'reference' => '12ab42bd6e742c70c0a52f7b82477fcd44e64b75',
),
'maennchen/zipstream-php' =>
array (
'pretty_version' => '2.1.0',
'version' => '2.1.0.0',
'aliases' =>
array (
),
'reference' => 'c4c5803cc1f93df3d2448478ef79394a5981cc58',
),
'markbaker/complex' =>
array (
'pretty_version' => '3.0.1',
'version' => '3.0.1.0',
'aliases' =>
array (
),
'reference' => 'ab8bc271e404909db09ff2d5ffa1e538085c0f22',
),
'markbaker/matrix' =>
array (
'pretty_version' => '3.0.0',
'version' => '3.0.0.0',
'aliases' =>
array (
),
'reference' => 'c66aefcafb4f6c269510e9ac46b82619a904c576',
),
'mirzaev/calculator' =>
array (
'pretty_version' => 'dev-stable',
'version' => 'dev-stable',
'aliases' =>
array (
),
'reference' => '503e25647cabfd80c98a1ca571a98e4b0595b729',
),
'mirzaev/minimal' =>
array (
'pretty_version' => '2.0.x-dev',
'version' => '2.0.9999999.9999999-dev',
'aliases' =>
array (
),
'reference' => 'b6f90b700116f20fe48725166ddfb8f6d27ae52d',
),
'myclabs/php-enum' =>
array (
'pretty_version' => '1.8.3',
'version' => '1.8.3.0',
'aliases' =>
array (
),
'reference' => 'b942d263c641ddb5190929ff840c68f78713e937',
),
'phpoffice/phpspreadsheet' =>
array (
'pretty_version' => '1.20.0',
'version' => '1.20.0.0',
'aliases' =>
array (
),
'reference' => '44436f270bb134b4a94670f3d020a85dfa0a3c02',
),
'psr/http-client' =>
array (
'pretty_version' => '1.0.1',
'version' => '1.0.1.0',
'aliases' =>
array (
),
'reference' => '2dfb5f6c5eff0e91e20e913f8c5452ed95b86621',
),
'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/simple-cache' =>
array (
'pretty_version' => '1.0.1',
'version' => '1.0.1.0',
'aliases' =>
array (
),
'reference' => '408d5eafb83c57f6365a3ca330ff23aa4a5fa39b',
),
'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.23.1',
'version' => '1.23.1.0',
'aliases' =>
array (
),
'reference' => '9174a3d80210dca8daa7f31fec659150bbeabfc6',
),
'twig/twig' =>
array (
'pretty_version' => 'v3.3.3',
'version' => '3.3.3.0',
'aliases' =>
array (
),
'reference' => 'a27fa056df8a6384316288ca8b0fa3a35fdeb569',
),
),
);
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;
}
}