1
0
Fork 0

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

pull/4525/merge
Jordi Boggiano 2016-01-09 18:19:49 +00:00
commit 42cb3dafc4
2 changed files with 17 additions and 4 deletions

View File

@ -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

View File

@ -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,6 +114,7 @@ EOT
foreach ($types as $type) {
/** @var Link $link */
foreach ($package->{'get'.$linkTypes[$type][0]}() as $link) {
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>)';
@ -113,6 +124,7 @@ EOT
}
}
}
}
if ($messages) {
sort($messages);