1
0
Fork 0

Warn if why-not is used with a version which does not exist/is not found, fixes #11070

pull/11115/head
Jordi Boggiano 2022-10-12 15:31:59 +02:00
parent 5f0aa01428
commit d06796efcf
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 5 additions and 0 deletions

View File

@ -94,6 +94,9 @@ abstract class BaseDependencyCommand extends BaseCommand
2, 2,
$input->hasArgument(self::ARGUMENT_CONSTRAINT) ? $input->getArgument(self::ARGUMENT_CONSTRAINT) : '*' $input->hasArgument(self::ARGUMENT_CONSTRAINT) ? $input->getArgument(self::ARGUMENT_CONSTRAINT) : '*'
); );
if (!$input->hasArgument(self::ARGUMENT_CONSTRAINT)) {
$textConstraint = '*';
}
// Find packages that are or provide the requested package first // Find packages that are or provide the requested package first
$packages = $installedRepo->findPackagesWithReplacersAndProviders($needle); $packages = $installedRepo->findPackagesWithReplacersAndProviders($needle);
@ -107,6 +110,8 @@ abstract class BaseDependencyCommand extends BaseCommand
$defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO(), $composer->getConfig(), $composer->getRepositoryManager())); $defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO(), $composer->getConfig(), $composer->getRepositoryManager()));
if ($match = $defaultRepos->findPackage($needle, $textConstraint)) { if ($match = $defaultRepos->findPackage($needle, $textConstraint)) {
$installedRepo->addRepository(new InstalledArrayRepository([clone $match])); $installedRepo->addRepository(new InstalledArrayRepository([clone $match]));
} else {
$this->getIO()->writeError('<error>Package "'.$needle.'" could not be found with constraint "'.$textConstraint.'", results below will most likely be incomplete.</error>');
} }
} }