Merge remote-tracking branch 'Soullivaneuh/depends-replaces'

main
Jordi Boggiano 9 years ago
commit 42cb3dafc4

@ -345,6 +345,7 @@ symfony/symfony requires monolog/monolog (~1)
* **--match-constraint (-m):** Filters the dependencies shown using this constraint.
* **--invert-match-constraint (-i):** Turns --match-constraint around into a blacklist
insteead of a whitelist.
* **--with-replaces:** Search for replaced packages as well.
## validate

@ -47,6 +47,7 @@ class DependsCommand extends Command
new InputOption('link-type', '', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Link types to show (require, require-dev)', array_keys($this->linkTypes)),
new InputOption('match-constraint', 'm', InputOption::VALUE_REQUIRED, 'Filters the dependencies shown using this constraint', '*'),
new InputOption('invert-match-constraint', 'i', InputOption::VALUE_NONE, 'Turns --match-constraint around into a blacklist insteead of whitelist'),
new InputOption('with-replaces', '', InputOption::VALUE_NONE, 'Search for replaced packages as well'),
))
->setHelp(<<<EOT
Displays detailed information about where a package is referenced.
@ -96,6 +97,15 @@ EOT
$constraint = $versionParser->parseConstraints($input->getOption('match-constraint'));
$matchInvert = $input->getOption('invert-match-constraint');
$needles = array($needle);
if (true === $input->getOption('with-replaces')) {
foreach ($packages as $package) {
$needles = array_merge($needles, array_map(function (Link $link) {
return $link->getTarget();
}, $package->getReplaces()));
}
}
$messages = array();
$outputPackages = array();
$io = $this->getIO();
@ -104,10 +114,12 @@ EOT
foreach ($types as $type) {
/** @var Link $link */
foreach ($package->{'get'.$linkTypes[$type][0]}() as $link) {
if ($link->getTarget() === $needle && ($link->getConstraint()->matches($constraint) ? !$matchInvert : $matchInvert)) {
if (!isset($outputPackages[$package->getName()])) {
$messages[] = '<info>'.$package->getPrettyName() . '</info> ' . $linkTypes[$type][1] . ' ' . $needle .' (<info>' . $link->getPrettyConstraint() . '</info>)';
$outputPackages[$package->getName()] = true;
foreach ($needles as $needle) {
if ($link->getTarget() === $needle && ($link->getConstraint()->matches($constraint) ? !$matchInvert : $matchInvert)) {
if (!isset($outputPackages[$package->getName()])) {
$messages[] = '<info>'.$package->getPrettyName() . '</info> ' . $linkTypes[$type][1] . ' ' . $needle .' (<info>' . $link->getPrettyConstraint() . '</info>)';
$outputPackages[$package->getName()] = true;
}
}
}
}

Loading…
Cancel
Save