diff options
Diffstat (limited to 'plugins/af_readability/vendor/composer/InstalledVersions.php')
-rw-r--r-- | plugins/af_readability/vendor/composer/InstalledVersions.php | 193 |
1 files changed, 91 insertions, 102 deletions
diff --git a/plugins/af_readability/vendor/composer/InstalledVersions.php b/plugins/af_readability/vendor/composer/InstalledVersions.php index d50e0c9fc..ee0c134b0 100644 --- a/plugins/af_readability/vendor/composer/InstalledVersions.php +++ b/plugins/af_readability/vendor/composer/InstalledVersions.php @@ -18,27 +18,90 @@ use Composer\Semver\VersionParser; /** * This class is copied in every Composer installed project and available to all * - * See also https://getcomposer.org/doc/07-runtime.md#installed-versions - * - * To require its presence, you can require `composer-runtime-api ^2.0` + * To require it's presence, you can require `composer-runtime-api ^2.0` */ class InstalledVersions { - /** - * @var mixed[]|null - * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null - */ - private static $installed; - - /** - * @var bool|null - */ + private static $installed = array ( + 'root' => + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + ), + 'reference' => 'f7b3c50828d4604ac5999daf3c3405e65c877e2f', + 'name' => '__root__', + ), + 'versions' => + array ( + '__root__' => + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + ), + 'reference' => 'f7b3c50828d4604ac5999daf3c3405e65c877e2f', + ), + 'fivefilters/readability.php' => + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + 0 => '9999999-dev', + ), + 'reference' => '5ad152c70376002f043bb936d8ae5eed103fb993', + ), + 'league/uri' => + array ( + 'pretty_version' => '6.7.1', + 'version' => '6.7.1.0', + 'aliases' => + array ( + ), + 'reference' => '2d7c87a0860f3126a39f44a8a9bf2fed402dcfea', + ), + 'league/uri-interfaces' => + array ( + 'pretty_version' => '2.3.0', + 'version' => '2.3.0.0', + 'aliases' => + array ( + ), + 'reference' => '00e7e2943f76d8cb50c7dfdc2f6dee356e15e383', + ), + 'masterminds/html5' => + array ( + 'pretty_version' => '2.7.5', + 'version' => '2.7.5.0', + 'aliases' => + array ( + ), + 'reference' => 'f640ac1bdddff06ea333a920c95bbad8872429ab', + ), + 'psr/http-message' => + array ( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'aliases' => + array ( + ), + 'reference' => 'f6561bf28d520154e4b0ec72be95418abe6d9363', + ), + 'psr/log' => + array ( + 'pretty_version' => '1.1.4', + 'version' => '1.1.4.0', + 'aliases' => + array ( + ), + 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11', + ), + ), +); private static $canGetVendors; - - /** - * @var array[] - * @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}> - */ private static $installedByVendor = array(); /** @@ -54,6 +117,7 @@ class InstalledVersions $packages[] = array_keys($installed['versions']); } + if (1 === \count($packages)) { return $packages[0]; } @@ -62,41 +126,18 @@ class InstalledVersions } /** - * Returns a list of all package names with a specific type e.g. 'library' - * - * @param string $type - * @return string[] - * @psalm-return list<string> - */ - public static function getInstalledPackagesByType($type) - { - $packagesByType = array(); - - foreach (self::getInstalled() as $installed) { - foreach ($installed['versions'] as $name => $package) { - if (isset($package['type']) && $package['type'] === $type) { - $packagesByType[] = $name; - } - } - } - - return $packagesByType; - } - - /** * Checks whether the given package is installed * * This also returns true if the package name is provided or replaced by another package * * @param string $packageName - * @param bool $includeDevRequirements * @return bool */ - public static function isInstalled($packageName, $includeDevRequirements = true) + public static function isInstalled($packageName) { foreach (self::getInstalled() as $installed) { if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + return true; } } @@ -110,9 +151,10 @@ class InstalledVersions * * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') * - * @param VersionParser $parser Install composer/semver to have access to this class and functionality - * @param string $packageName - * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * * @return bool */ public static function satisfies(VersionParser $parser, $packageName, $constraint) @@ -223,25 +265,8 @@ class InstalledVersions } /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. - */ - public static function getInstallPath($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** * @return array - * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[]} */ public static function getRootPackage() { @@ -253,39 +278,15 @@ class InstalledVersions /** * Returns the raw installed.php data for custom implementations * - * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. * @return array[] - * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} + * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[]}, versions: list<string, array{pretty_version: ?string, version: ?string, aliases: ?string[], reference: ?string, replaced: ?string[], provided: ?string[]}>} */ public static function getRawData() { - @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = include __DIR__ . '/installed.php'; - } else { - self::$installed = array(); - } - } - return self::$installed; } /** - * Returns the raw data of all installed.php which are currently loaded for custom implementations - * - * @return array[] - * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}> - */ - public static function getAllRawData() - { - return self::getInstalled(); - } - - /** * Lets you reload the static array from another file * * This is only useful for complex integrations in which a project needs to use @@ -301,7 +302,7 @@ class InstalledVersions * @param array[] $data A vendor/composer/installed.php data set * @return void * - * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data + * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[]}, versions: list<string, array{pretty_version: ?string, version: ?string, aliases: ?string[], reference: ?string, replaced: ?string[], provided: ?string[]}>} $data */ public static function reload($data) { @@ -311,7 +312,6 @@ class InstalledVersions /** * @return array[] - * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}> */ private static function getInstalled() { @@ -322,27 +322,16 @@ class InstalledVersions $installed = array(); if (self::$canGetVendors) { + // @phpstan-ignore-next-line 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'; - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { - self::$installed = $installed[count($installed) - 1]; - } } } } - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = require __DIR__ . '/installed.php'; - } else { - self::$installed = array(); - } - } $installed[] = self::$installed; return $installed; |