Composer

InstalledVersions::getVersionRanges()public staticWPSCache 1.0

Returns a version constraint representing all the range(s) which are installed for a given package

It is easier to use this via isInstalled() with the $constraint argument if you need to check whether a given version of a package is installed, and not just whether it exists

Метод класса: InstalledVersions{}

Хуков нет.

Возвращает

Строку. Version constraint usable with composer/semver

Использование

$result = InstalledVersions::getVersionRanges( $packageName );
$packageName(строка) (обязательный)
-

Код InstalledVersions::getVersionRanges() WPSCache 1.9.2

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');
}