From 754f2868fbfa8dac2a7542d9132523c9396c87a2 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 7 Feb 2024 22:27:39 +0100 Subject: [PATCH] Add non-zero return codes when why-not finds a reason a package is not installable, or when why finds no reason it is there, fixes #11796 --- src/Composer/Command/BaseDependencyCommand.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/BaseDependencyCommand.php b/src/Composer/Command/BaseDependencyCommand.php index e010c122a..2fb363979 100644 --- a/src/Composer/Command/BaseDependencyCommand.php +++ b/src/Composer/Command/BaseDependencyCommand.php @@ -133,6 +133,8 @@ abstract class BaseDependencyCommand extends BaseCommand $renderTree = $input->getOption(self::OPTION_TREE); $recursive = $renderTree || $input->getOption(self::OPTION_RECURSIVE); + $return = $inverted ? 1 : 0; + // Resolve dependencies $results = $installedRepo->getDependents($needles, $constraint, $inverted, $recursive); if (empty($results)) { @@ -142,6 +144,7 @@ abstract class BaseDependencyCommand extends BaseCommand $needle, $extra )); + $return = $inverted ? 0 : 1; } elseif ($renderTree) { $this->initStyles($output); $root = $packages[0]; @@ -171,7 +174,7 @@ abstract class BaseDependencyCommand extends BaseCommand $this->getIO()->writeError('Not finding what you were looking for? Try calling `composer '.$composerCommand.' "'.$needle.':'.$textConstraint.'" --dry-run` to get another view on the problem.'); } - return 0; + return $return; } /**