2021-01-04 11:11:04 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Composer;
|
|
|
|
|
2021-03-01 10:21:26 +01:00
|
|
|
use Composer\Autoload\ClassLoader;
|
2021-01-04 11:11:04 +01:00
|
|
|
use Composer\Semver\VersionParser;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-23 13:20:53 +02:00
|
|
|
|
|
|
|
|
2021-01-04 11:11:04 +01:00
|
|
|
class InstalledVersions
|
|
|
|
{
|
|
|
|
private static $installed = array (
|
|
|
|
'root' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => '1.0.0+no-version-set',
|
|
|
|
'version' => '1.0.0.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => NULL,
|
|
|
|
'name' => '__root__',
|
|
|
|
),
|
|
|
|
'versions' =>
|
|
|
|
array (
|
|
|
|
'__root__' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => '1.0.0+no-version-set',
|
|
|
|
'version' => '1.0.0.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => NULL,
|
|
|
|
),
|
|
|
|
'bshaffer/oauth2-server-php' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => 'v1.11.1',
|
|
|
|
'version' => '1.11.1.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => '5a0c8000d4763b276919e2106f54eddda6bc50fa',
|
|
|
|
),
|
|
|
|
'ddeboer/imap' =>
|
|
|
|
array (
|
2021-05-04 20:46:05 +02:00
|
|
|
'pretty_version' => '1.12.1',
|
|
|
|
'version' => '1.12.1.0',
|
2021-01-04 11:11:04 +01:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2021-05-04 20:46:05 +02:00
|
|
|
'reference' => 'dbed05ca67b93509345a820b2859de10c48948fb',
|
2021-04-13 21:34:47 +02:00
|
|
|
),
|
|
|
|
'directorytree/ldaprecord' =>
|
|
|
|
array (
|
2021-05-23 13:20:53 +02:00
|
|
|
'pretty_version' => 'v2.4.6',
|
|
|
|
'version' => '2.4.6.0',
|
2021-04-13 21:34:47 +02:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2021-05-23 13:20:53 +02:00
|
|
|
'reference' => '824a49feae4da52a522b3ec60ecad508b8f4ed23',
|
2021-01-04 11:11:04 +01:00
|
|
|
),
|
|
|
|
'exorus/php-mime-mail-parser' =>
|
|
|
|
array (
|
|
|
|
'replaced' =>
|
|
|
|
array (
|
|
|
|
0 => '*',
|
|
|
|
),
|
|
|
|
),
|
2021-04-13 21:34:47 +02:00
|
|
|
'illuminate/contracts' =>
|
|
|
|
array (
|
2021-05-23 13:20:53 +02:00
|
|
|
'pretty_version' => 'v8.42.1',
|
|
|
|
'version' => '8.42.1.0',
|
2021-04-13 21:34:47 +02:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2021-05-23 13:20:53 +02:00
|
|
|
'reference' => '68036b4fb17ad40a599323bda3f2c0845c8100d8',
|
2021-04-13 21:34:47 +02:00
|
|
|
),
|
2021-01-04 11:11:04 +01:00
|
|
|
'matthiasmullie/minify' =>
|
|
|
|
array (
|
2021-03-01 10:21:26 +01:00
|
|
|
'pretty_version' => '1.3.66',
|
|
|
|
'version' => '1.3.66.0',
|
2021-01-04 11:11:04 +01:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2021-03-01 10:21:26 +01:00
|
|
|
'reference' => '45fd3b0f1dfa2c965857c6d4a470bea52adc31a6',
|
2021-01-04 11:11:04 +01:00
|
|
|
),
|
|
|
|
'matthiasmullie/path-converter' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => '1.1.3',
|
|
|
|
'version' => '1.1.3.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => 'e7d13b2c7e2f2268e1424aaed02085518afa02d9',
|
|
|
|
),
|
|
|
|
'messaged/php-mime-mail-parser' =>
|
|
|
|
array (
|
|
|
|
'replaced' =>
|
|
|
|
array (
|
|
|
|
0 => '*',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'mustangostang/spyc' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => '0.6.3',
|
|
|
|
'version' => '0.6.3.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => '4627c838b16550b666d15aeae1e5289dd5b77da0',
|
|
|
|
),
|
2021-04-13 21:34:47 +02:00
|
|
|
'nesbot/carbon' =>
|
|
|
|
array (
|
2021-05-23 13:20:53 +02:00
|
|
|
'pretty_version' => '2.48.0',
|
|
|
|
'version' => '2.48.0.0',
|
2021-04-13 21:34:47 +02:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2021-05-23 13:20:53 +02:00
|
|
|
'reference' => 'd3c447f21072766cddec3522f9468a5849a76147',
|
2021-04-13 21:34:47 +02:00
|
|
|
),
|
2021-01-04 11:11:04 +01:00
|
|
|
'paragonie/random_compat' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => 'v9.99.100',
|
|
|
|
'version' => '9.99.100.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => '996434e5492cb4c3edcb9168db6fbb1359ef965a',
|
|
|
|
),
|
|
|
|
'php-mime-mail-parser/php-mime-mail-parser' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => '5.0.5',
|
|
|
|
'version' => '5.0.5.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => '27983433aabeccee832573c3c56e6a4855e57745',
|
|
|
|
),
|
|
|
|
'phpmailer/phpmailer' =>
|
|
|
|
array (
|
2021-05-04 20:46:05 +02:00
|
|
|
'pretty_version' => 'v6.4.1',
|
|
|
|
'version' => '6.4.1.0',
|
2021-04-13 21:34:47 +02:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2021-05-04 20:46:05 +02:00
|
|
|
'reference' => '9256f12d8fb0cd0500f93b19e18c356906cbed3d',
|
2021-04-13 21:34:47 +02:00
|
|
|
),
|
|
|
|
'psr/container' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => '1.1.1',
|
|
|
|
'version' => '1.1.1.0',
|
2021-01-04 11:11:04 +01:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2021-04-13 21:34:47 +02:00
|
|
|
'reference' => '8622567409010282b7aeebe4bb841fe98b58dcaf',
|
|
|
|
),
|
|
|
|
'psr/log' =>
|
|
|
|
array (
|
2021-05-04 20:46:05 +02:00
|
|
|
'pretty_version' => '1.1.4',
|
|
|
|
'version' => '1.1.4.0',
|
2021-04-13 21:34:47 +02:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2021-05-04 20:46:05 +02:00
|
|
|
'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
|
2021-04-13 21:34:47 +02:00
|
|
|
),
|
|
|
|
'psr/simple-cache' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => '1.0.1',
|
|
|
|
'version' => '1.0.1.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => '408d5eafb83c57f6365a3ca330ff23aa4a5fa39b',
|
2021-01-04 11:11:04 +01:00
|
|
|
),
|
|
|
|
'robthree/twofactorauth' =>
|
|
|
|
array (
|
2021-04-13 21:34:47 +02:00
|
|
|
'pretty_version' => '1.8.0',
|
|
|
|
'version' => '1.8.0.0',
|
2021-01-04 11:11:04 +01:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2021-04-13 21:34:47 +02:00
|
|
|
'reference' => '30a38627ae1e7c9399dae67e265063cd6ec5276c',
|
2021-01-04 11:11:04 +01:00
|
|
|
),
|
|
|
|
'soundasleep/html2text' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => '0.5.0',
|
|
|
|
'version' => '0.5.0.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => 'cdb89f6ffa2c4cc78f8ed9ea6ee0594a9133ccad',
|
|
|
|
),
|
2021-04-13 21:34:47 +02:00
|
|
|
'symfony/polyfill-mbstring' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => 'v1.22.1',
|
|
|
|
'version' => '1.22.1.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => '5232de97ee3b75b0360528dae24e73db49566ab1',
|
|
|
|
),
|
|
|
|
'symfony/polyfill-php80' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => 'v1.22.1',
|
|
|
|
'version' => '1.22.1.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => 'dc3063ba22c2a1fd2f45ed856374d79114998f91',
|
|
|
|
),
|
|
|
|
'symfony/translation' =>
|
|
|
|
array (
|
2021-05-23 13:20:53 +02:00
|
|
|
'pretty_version' => 'v5.2.9',
|
|
|
|
'version' => '5.2.9.0',
|
2021-04-13 21:34:47 +02:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2021-05-23 13:20:53 +02:00
|
|
|
'reference' => '61af68dba333e2d376a325a29c2a3f2a605b4876',
|
2021-04-13 21:34:47 +02:00
|
|
|
),
|
|
|
|
'symfony/translation-contracts' =>
|
|
|
|
array (
|
2021-05-04 20:46:05 +02:00
|
|
|
'pretty_version' => 'v2.4.0',
|
|
|
|
'version' => '2.4.0.0',
|
2021-04-13 21:34:47 +02:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2021-05-04 20:46:05 +02:00
|
|
|
'reference' => '95c812666f3e91db75385749fe219c5e494c7f95',
|
2021-04-13 21:34:47 +02:00
|
|
|
),
|
|
|
|
'symfony/translation-implementation' =>
|
|
|
|
array (
|
|
|
|
'provided' =>
|
|
|
|
array (
|
|
|
|
0 => '2.3',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'symfony/var-dumper' =>
|
|
|
|
array (
|
2021-05-23 13:20:53 +02:00
|
|
|
'pretty_version' => 'v5.2.8',
|
|
|
|
'version' => '5.2.8.0',
|
2021-04-13 21:34:47 +02:00
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
2021-05-23 13:20:53 +02:00
|
|
|
'reference' => 'd693200a73fae179d27f8f1b16b4faf3e8569eba',
|
2021-04-13 21:34:47 +02:00
|
|
|
),
|
|
|
|
'tightenco/collect' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => 'v8.34.0',
|
|
|
|
'version' => '8.34.0.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => 'b069783ab0c547bb894ebcf8e7f6024bb401f9d2',
|
|
|
|
),
|
2021-01-04 11:11:04 +01:00
|
|
|
'yubico/u2flib-server' =>
|
|
|
|
array (
|
|
|
|
'pretty_version' => '1.0.2',
|
|
|
|
'version' => '1.0.2.0',
|
|
|
|
'aliases' =>
|
|
|
|
array (
|
|
|
|
),
|
|
|
|
'reference' => '55d813acf68212ad2cadecde07551600d6971939',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2021-03-01 10:21:26 +01:00
|
|
|
private static $canGetVendors;
|
|
|
|
private static $installedByVendor = array();
|
2021-01-04 11:11:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function getInstalledPackages()
|
|
|
|
{
|
2021-03-01 10:21:26 +01:00
|
|
|
$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)));
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function isInstalled($packageName)
|
|
|
|
{
|
2021-03-01 10:21:26 +01:00
|
|
|
foreach (self::getInstalled() as $installed) {
|
|
|
|
if (isset($installed['versions'][$packageName])) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2021-03-01 10:21:26 +01:00
|
|
|
foreach (self::getInstalled() as $installed) {
|
|
|
|
if (!isset($installed['versions'][$packageName])) {
|
|
|
|
continue;
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$ranges = array();
|
2021-03-01 10:21:26 +01:00
|
|
|
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
|
|
|
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
2021-03-01 10:21:26 +01:00
|
|
|
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
|
|
|
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
2021-03-01 10:21:26 +01:00
|
|
|
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
|
|
|
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
2021-03-01 10:21:26 +01:00
|
|
|
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
|
|
|
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return implode(' || ', $ranges);
|
|
|
|
}
|
|
|
|
|
2021-03-01 10:21:26 +01:00
|
|
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
|
|
}
|
|
|
|
|
2021-01-04 11:11:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function getVersion($packageName)
|
|
|
|
{
|
2021-03-01 10:21:26 +01:00
|
|
|
foreach (self::getInstalled() as $installed) {
|
|
|
|
if (!isset($installed['versions'][$packageName])) {
|
|
|
|
continue;
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
|
|
|
|
2021-03-01 10:21:26 +01:00
|
|
|
if (!isset($installed['versions'][$packageName]['version'])) {
|
2021-01-04 11:11:04 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-03-01 10:21:26 +01:00
|
|
|
return $installed['versions'][$packageName]['version'];
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function getPrettyVersion($packageName)
|
|
|
|
{
|
2021-03-01 10:21:26 +01:00
|
|
|
foreach (self::getInstalled() as $installed) {
|
|
|
|
if (!isset($installed['versions'][$packageName])) {
|
|
|
|
continue;
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
|
|
|
|
2021-03-01 10:21:26 +01:00
|
|
|
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
2021-01-04 11:11:04 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-03-01 10:21:26 +01:00
|
|
|
return $installed['versions'][$packageName]['pretty_version'];
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function getReference($packageName)
|
|
|
|
{
|
2021-03-01 10:21:26 +01:00
|
|
|
foreach (self::getInstalled() as $installed) {
|
|
|
|
if (!isset($installed['versions'][$packageName])) {
|
|
|
|
continue;
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
|
|
|
|
2021-03-01 10:21:26 +01:00
|
|
|
if (!isset($installed['versions'][$packageName]['reference'])) {
|
2021-01-04 11:11:04 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-03-01 10:21:26 +01:00
|
|
|
return $installed['versions'][$packageName]['reference'];
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function getRootPackage()
|
|
|
|
{
|
2021-03-01 10:21:26 +01:00
|
|
|
$installed = self::getInstalled();
|
|
|
|
|
|
|
|
return $installed[0]['root'];
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function getRawData()
|
|
|
|
{
|
|
|
|
return self::$installed;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function reload($data)
|
|
|
|
{
|
|
|
|
self::$installed = $data;
|
2021-03-01 10:21:26 +01:00
|
|
|
self::$installedByVendor = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-23 13:20:53 +02:00
|
|
|
|
2021-03-01 10:21:26 +01:00
|
|
|
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;
|
2021-01-04 11:11:04 +01:00
|
|
|
}
|
|
|
|
}
|