1
0
Fork 0

Process feedback, code cleanup.

pull/4917/head
Niels Keurentjes 2016-02-18 22:26:44 +01:00
parent 53b6417707
commit 9bc2ee02e4
1 changed files with 11 additions and 10 deletions

View File

@ -15,7 +15,7 @@ namespace Composer\Command;
use Composer\DependencyResolver\Pool; use Composer\DependencyResolver\Pool;
use Composer\Package\Link; use Composer\Package\Link;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Package\RootPackage; use Composer\Package\RootPackageInterface;
use Composer\Repository\ArrayRepository; use Composer\Repository\ArrayRepository;
use Composer\Repository\CompositeRepository; use Composer\Repository\CompositeRepository;
use Composer\Repository\PlatformRepository; use Composer\Repository\PlatformRepository;
@ -90,13 +90,15 @@ EOT
$constraint = null; $constraint = null;
} }
$matchInvert = $input->getOption('invert-match-constraint'); $matchInvert = $input->getOption('invert-match-constraint');
// Parse rendering options
$renderTree = $input->getOption('tree'); $renderTree = $input->getOption('tree');
$recursive = $renderTree || $input->getOption('recursive'); $recursive = $renderTree || $input->getOption('recursive');
// Resolve dependencies // Resolve dependencies
$results = $this->getDependents($needle, $repository->getPackages(), $constraint, $matchInvert, $recursive); $results = $this->getDependents($needle, $repository->getPackages(), $constraint, $matchInvert, $recursive);
if (empty($results)) { if (empty($results)) {
$extra = isset($constraint) ? sprintf(' in versions %smatching %s', $matchInvert ? 'not ' : '', $textConstraint) : ''; $extra = (null !== $constraint) ? sprintf(' in versions %smatching %s', $matchInvert ? 'not ' : '', $textConstraint) : '';
$this->getIO()->writeError(sprintf('<info>There is no installed package depending on "%s"%s</info>', $this->getIO()->writeError(sprintf('<info>There is no installed package depending on "%s"%s</info>',
$needle, $extra)); $needle, $extra));
} elseif ($renderTree) { } elseif ($renderTree) {
@ -172,7 +174,7 @@ EOT
} }
/** /**
* @param string $needle The package to inspect. * @param string|string[] $needle The package(s) to inspect.
* @param PackageInterface[] $packages List of installed packages. * @param PackageInterface[] $packages List of installed packages.
* @param ConstraintInterface|null $constraint Optional constraint to filter by. * @param ConstraintInterface|null $constraint Optional constraint to filter by.
* @param bool $invert Whether to invert matches on the previous constraint. * @param bool $invert Whether to invert matches on the previous constraint.
@ -184,14 +186,13 @@ EOT
$needles = is_array($needle) ? $needle : array($needle); $needles = is_array($needle) ? $needle : array($needle);
$results = array(); $results = array();
/** // Loop over all currently installed packages.
* Loop over all currently installed packages.
*/
foreach ($packages as $package) { foreach ($packages as $package) {
// Retrieve all requirements, but dev only for the root package // Requirements and replaces are both considered valid reasons for a package to be installed
$links = $package->getRequires(); $links = $package->getRequires() + $package->getReplaces();
$links += $package->getReplaces();
if ($package instanceof RootPackage) { // Require-dev is only relevant for the root package
if ($package instanceof RootPackageInterface) {
$links += $package->getDevRequires(); $links += $package->getDevRequires();
} }