Merge remote-tracking branch 'Soullivaneuh/depends-replaces'
commit
42cb3dafc4
|
@ -345,6 +345,7 @@ symfony/symfony requires monolog/monolog (~1)
|
||||||
* **--match-constraint (-m):** Filters the dependencies shown using this constraint.
|
* **--match-constraint (-m):** Filters the dependencies shown using this constraint.
|
||||||
* **--invert-match-constraint (-i):** Turns --match-constraint around into a blacklist
|
* **--invert-match-constraint (-i):** Turns --match-constraint around into a blacklist
|
||||||
insteead of a whitelist.
|
insteead of a whitelist.
|
||||||
|
* **--with-replaces:** Search for replaced packages as well.
|
||||||
|
|
||||||
## validate
|
## 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('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('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('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
|
->setHelp(<<<EOT
|
||||||
Displays detailed information about where a package is referenced.
|
Displays detailed information about where a package is referenced.
|
||||||
|
@ -96,6 +97,15 @@ EOT
|
||||||
$constraint = $versionParser->parseConstraints($input->getOption('match-constraint'));
|
$constraint = $versionParser->parseConstraints($input->getOption('match-constraint'));
|
||||||
$matchInvert = $input->getOption('invert-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();
|
$messages = array();
|
||||||
$outputPackages = array();
|
$outputPackages = array();
|
||||||
$io = $this->getIO();
|
$io = $this->getIO();
|
||||||
|
@ -104,6 +114,7 @@ EOT
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
/** @var Link $link */
|
/** @var Link $link */
|
||||||
foreach ($package->{'get'.$linkTypes[$type][0]}() as $link) {
|
foreach ($package->{'get'.$linkTypes[$type][0]}() as $link) {
|
||||||
|
foreach ($needles as $needle) {
|
||||||
if ($link->getTarget() === $needle && ($link->getConstraint()->matches($constraint) ? !$matchInvert : $matchInvert)) {
|
if ($link->getTarget() === $needle && ($link->getConstraint()->matches($constraint) ? !$matchInvert : $matchInvert)) {
|
||||||
if (!isset($outputPackages[$package->getName()])) {
|
if (!isset($outputPackages[$package->getName()])) {
|
||||||
$messages[] = '<info>'.$package->getPrettyName() . '</info> ' . $linkTypes[$type][1] . ' ' . $needle .' (<info>' . $link->getPrettyConstraint() . '</info>)';
|
$messages[] = '<info>'.$package->getPrettyName() . '</info> ' . $linkTypes[$type][1] . ' ' . $needle .' (<info>' . $link->getPrettyConstraint() . '</info>)';
|
||||||
|
@ -113,6 +124,7 @@ EOT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($messages) {
|
if ($messages) {
|
||||||
sort($messages);
|
sort($messages);
|
||||||
|
|
Loading…
Reference in New Issue