function InstalledVersions::getVersion
Same name in this branch
- 11.1.x vendor/composer/composer/src/Composer/InstalledVersions.php \Composer\InstalledVersions::getVersion()
Parameters
string $packageName:
Return value
string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
File
-
vendor/
composer/ InstalledVersions.php, line 173
Class
- InstalledVersions
- This class is copied in every Composer installed project and available to all
Namespace
ComposerCode
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');
}