wishthis/vendor/composer/InstalledVersions.php

512 lines
9.8 KiB
PHP
Raw Normal View History

2022-03-01 09:38:26 +00:00
<?php
2022-06-21 16:04:22 +00:00
2022-03-01 09:38:26 +00:00
namespace Composer;
use Composer\Autoload\ClassLoader;
use Composer\Semver\VersionParser;
2022-06-21 16:04:22 +00:00
2022-03-01 09:38:26 +00:00
class InstalledVersions
{
2022-06-21 16:04:22 +00:00
private static $installed = array (
'root' =>
array (
'pretty_version' => 'dev-develop',
'version' => 'dev-develop',
'aliases' =>
array (
),
'reference' => '03788f71ffb580b6f1b6469fdc74463f381928d8',
'name' => '__root__',
),
'versions' =>
array (
'__root__' =>
array (
'pretty_version' => 'dev-develop',
'version' => 'dev-develop',
'aliases' =>
array (
),
'reference' => '03788f71ffb580b6f1b6469fdc74463f381928d8',
),
'composer/ca-bundle' =>
array (
'pretty_version' => '1.3.2',
'version' => '1.3.2.0',
'aliases' =>
array (
),
'reference' => 'fd5dd441932a7e10ca6e5b490e272d34c8430640',
),
'dealerdirect/phpcodesniffer-composer-installer' =>
array (
'pretty_version' => 'v0.7.2',
'version' => '0.7.2.0',
'aliases' =>
array (
),
'reference' => '1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db',
),
'embed/embed' =>
array (
'pretty_version' => 'v4.4.4',
'version' => '4.4.4.0',
'aliases' =>
array (
),
'reference' => '52c2d77f58672868346ae09b0fa1eecc818bdf42',
),
'gettext/gettext' =>
array (
'pretty_version' => 'v5.6.1',
'version' => '5.6.1.0',
'aliases' =>
array (
),
'reference' => '017e249601d32b9a88c2eb4c10eac89bf582a7d3',
),
'gettext/languages' =>
array (
'pretty_version' => '2.9.0',
'version' => '2.9.0.0',
'aliases' =>
array (
),
'reference' => 'ed56dd2c7f4024cc953ed180d25f02f2640e3ffa',
),
'gettext/translator' =>
array (
'pretty_version' => 'v1.1.1',
'version' => '1.1.1.0',
'aliases' =>
array (
),
'reference' => 'b18ff33e8203de623854561f5e47e992fc5c50bb',
),
'grandel/include-directory' =>
array (
'pretty_version' => 'v0.2.2',
'version' => '0.2.2.0',
'aliases' =>
array (
),
'reference' => 'a5c830e8f1527c818b521ab18f2accecb02f9919',
),
'guzzlehttp/guzzle' =>
array (
'pretty_version' => '7.4.5',
'version' => '7.4.5.0',
'aliases' =>
array (
),
'reference' => '1dd98b0564cb3f6bd16ce683cb755f94c10fbd82',
),
'guzzlehttp/promises' =>
array (
'pretty_version' => '1.5.1',
'version' => '1.5.1.0',
'aliases' =>
array (
),
'reference' => 'fe752aedc9fd8fcca3fe7ad05d419d32998a06da',
),
'guzzlehttp/psr7' =>
array (
'pretty_version' => '2.4.0',
'version' => '2.4.0.0',
'aliases' =>
array (
),
'reference' => '13388f00956b1503577598873fffb5ae994b5737',
),
'ml/iri' =>
array (
'pretty_version' => '1.1.4',
'version' => '1.1.4.0',
'aliases' =>
array (
),
'reference' => 'cbd44fa913e00ea624241b38cefaa99da8d71341',
),
'ml/json-ld' =>
array (
'pretty_version' => '1.2.0',
'version' => '1.2.0.0',
'aliases' =>
array (
),
'reference' => 'c74a1aed5979ed1cfb1be35a55a305fd30e30b93',
),
'oscarotero/html-parser' =>
array (
'pretty_version' => 'v0.1.6',
'version' => '0.1.6.0',
'aliases' =>
array (
),
'reference' => 'b61e92f634d0dc184339d24630a6968d3ac64ded',
),
'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-factory-implementation' =>
array (
'provided' =>
array (
0 => '1.0',
),
),
'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',
),
),
'qferr/mjml-php' =>
array (
'pretty_version' => '1.1.0',
'version' => '1.1.0.0',
'aliases' =>
array (
),
'reference' => 'c6ea36c190e304e399a957f7e03b5a378faf41b9',
),
'ralouphie/getallheaders' =>
array (
'pretty_version' => '3.0.3',
'version' => '3.0.3.0',
'aliases' =>
array (
),
'reference' => '120b605dfeb996808c31b6477290a714d356e822',
),
'squizlabs/php_codesniffer' =>
array (
'pretty_version' => '3.7.1',
'version' => '3.7.1.0',
'aliases' =>
array (
),
'reference' => '1359e176e9307e906dc3d890bcc9603ff6d90619',
),
'symfony/deprecation-contracts' =>
array (
'pretty_version' => 'v3.1.0',
'version' => '3.1.0.0',
'aliases' =>
array (
),
'reference' => '07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918',
),
'symfony/polyfill-php80' =>
array (
'pretty_version' => 'v1.26.0',
'version' => '1.26.0.0',
'aliases' =>
array (
),
'reference' => 'cfa0ae98841b9e461207c13ab093d76b0fa7bace',
),
'symfony/process' =>
array (
'pretty_version' => 'v5.4.8',
'version' => '5.4.8.0',
'aliases' =>
array (
),
'reference' => '597f3fff8e3e91836bb0bd38f5718b56ddbde2f3',
),
'wp-coding-standards/wpcs' =>
array (
'pretty_version' => '2.3.0',
'version' => '2.3.0.0',
'aliases' =>
array (
),
'reference' => '7da1894633f168fe244afc6de00d141f27517b62',
),
),
);
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;
}
2022-03-01 09:38:26 +00:00
}