Closed stof closed 4 years ago
I think Versions::ROOT_PACKAGE_NAME
should be overall deprecated (https://github.com/Ocramius/PackageVersions/issues/142, https://github.com/Ocramius/PackageVersions/issues/139)
sure. But in the meantime, it should still work. for now, there is no way to get the info about the root package anymore in this library.
Hmm, wait, so Composer\InstalledVersions::getVersion()
has no root package info at all?
Composer\InstalledVersions::getVersion()
is only about packages installed in vendors (same than Composer\InstalledVersions::isInstalled()
.
The info about the root package are available through a separate Composer\InstalledVersions::getRootPackage()
method.
I see, makes sense. Will indeed need some trickery to work :-\
Well, I think this could look like this:
function getVersion(string $packageName)
{
if ($packageName === self::ROOT_PACKAGE_NAME) {
return \Composer\InstalledVersions::getRootPackage()['version']; // Or whatever is needed to output the right info
}
// existing code stays here
}
This seems to be only affecting the "fallback" version, when 'unknown/root-package@UNKNOWN'
is used for a lookup. Not a massive fix though :-)
Versions::getVersion(Versions::ROOT_PACKAGE_NAME)
is expected to return the version of the root package. But currently, the implementation forwards such call toComposer\InstalledVersions::getVersion()
directly, which does not support the root package as package name. Info about the root package is exposed throughComposer\InstalledVersions::getRootPackage()