512 lines
9.9 KiB
PHP
512 lines
9.9 KiB
PHP
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Composer;
|
|
|
|
use Composer\Autoload\ClassLoader;
|
|
use Composer\Semver\VersionParser;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InstalledVersions
|
|
{
|
|
private static $installed = array (
|
|
'root' =>
|
|
array (
|
|
'pretty_version' => 'dev-develop',
|
|
'version' => 'dev-develop',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '18c4d9491c79ef5d08041ecb4a598fdb0c36a9f3',
|
|
'name' => '__root__',
|
|
),
|
|
'versions' =>
|
|
array (
|
|
'__root__' =>
|
|
array (
|
|
'pretty_version' => 'dev-develop',
|
|
'version' => 'dev-develop',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '18c4d9491c79ef5d08041ecb4a598fdb0c36a9f3',
|
|
),
|
|
'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',
|
|
),
|
|
'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.3',
|
|
'version' => '7.4.3.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '74a8602c6faec9ef74b7a9391ac82c5e65b1cdab',
|
|
),
|
|
'guzzlehttp/promises' =>
|
|
array (
|
|
'pretty_version' => '1.5.1',
|
|
'version' => '1.5.1.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'fe752aedc9fd8fcca3fe7ad05d419d32998a06da',
|
|
),
|
|
'guzzlehttp/psr7' =>
|
|
array (
|
|
'pretty_version' => '2.2.1',
|
|
'version' => '2.2.1.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'c94a94f120803a18554c1805ef2e539f8285f9a2',
|
|
),
|
|
'http-interop/http-factory-guzzle' =>
|
|
array (
|
|
'pretty_version' => '1.2.0',
|
|
'version' => '1.2.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '8f06e92b95405216b237521cc64c804dd44c4a81',
|
|
),
|
|
'laminas/laminas-diactoros' =>
|
|
array (
|
|
'pretty_version' => '2.11.0',
|
|
'version' => '2.11.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => 'd1bc565b23c2040fafde398a8a5db083c47928c0',
|
|
),
|
|
'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',
|
|
1 => '^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.6.2',
|
|
'version' => '3.6.2.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '5e4e71592f69da17871dba6e80dd51bce74a351a',
|
|
),
|
|
'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.25.0',
|
|
'version' => '1.25.0.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '4407588e0d3f1f52efb65fbe92babe41f37fe50c',
|
|
),
|
|
'symfony/process' =>
|
|
array (
|
|
'pretty_version' => 'v5.4.8',
|
|
'version' => '5.4.8.0',
|
|
'aliases' =>
|
|
array (
|
|
),
|
|
'reference' => '597f3fff8e3e91836bb0bd38f5718b56ddbde2f3',
|
|
),
|
|
),
|
|
);
|
|
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;
|
|
}
|
|
}
|