1
0
Fork 0

Renamed Composer\Console\Command to BaseCommand for consistency with other abstract base classes.

pull/4917/head
Niels Keurentjes 2016-02-19 23:56:46 +01:00
parent 5c98421ae8
commit 692a3ed300
24 changed files with 26 additions and 65 deletions

View File

@ -18,7 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/** /**
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class AboutCommand extends Command class AboutCommand extends BaseCommand
{ {
protected function configure() protected function configure()
{ {

View File

@ -30,7 +30,7 @@ use Symfony\Component\Console\Output\OutputInterface;
* *
* @author Nils Adermann <naderman@naderman.de> * @author Nils Adermann <naderman@naderman.de>
*/ */
class ArchiveCommand extends Command class ArchiveCommand extends BaseCommand
{ {
protected function configure() protected function configure()
{ {

View File

@ -18,7 +18,7 @@ use Composer\IO\IOInterface;
use Composer\IO\NullIO; use Composer\IO\NullIO;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Command\Command as BaseCommand; use Symfony\Component\Console\Command\Command;
/** /**
* Base class for Composer commands * Base class for Composer commands
@ -26,7 +26,7 @@ use Symfony\Component\Console\Command\Command as BaseCommand;
* @author Ryan Weaver <ryan@knplabs.com> * @author Ryan Weaver <ryan@knplabs.com>
* @author Konstantin Kudryashov <ever.zet@gmail.com> * @author Konstantin Kudryashov <ever.zet@gmail.com>
*/ */
abstract class Command extends BaseCommand abstract class BaseCommand extends Command
{ {
/** /**
* @var Composer * @var Composer

View File

@ -20,7 +20,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/** /**
* @author David Neilsen <petah.p@gmail.com> * @author David Neilsen <petah.p@gmail.com>
*/ */
class ClearCacheCommand extends Command class ClearCacheCommand extends BaseCommand
{ {
protected function configure() protected function configure()
{ {

View File

@ -27,7 +27,7 @@ use Composer\Json\JsonFile;
* @author Joshua Estes <Joshua.Estes@iostudio.com> * @author Joshua Estes <Joshua.Estes@iostudio.com>
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class ConfigCommand extends Command class ConfigCommand extends BaseCommand
{ {
/** /**
* @var Config * @var Config

View File

@ -46,7 +46,7 @@ use Composer\Package\Version\VersionParser;
* @author Tobias Munk <schmunk@usrbin.de> * @author Tobias Munk <schmunk@usrbin.de>
* @author Nils Adermann <naderman@naderman.de> * @author Nils Adermann <naderman@naderman.de>
*/ */
class CreateProjectCommand extends Command class CreateProjectCommand extends BaseCommand
{ {
protected function configure() protected function configure()
{ {

View File

@ -15,13 +15,11 @@ 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\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;
use Composer\Plugin\CommandEvent; use Composer\Plugin\CommandEvent;
use Composer\Plugin\PluginEvents; use Composer\Plugin\PluginEvents;
use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Semver\VersionParser; use Composer\Semver\VersionParser;
use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@ -30,10 +28,9 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
/** /**
* @author Justin Rainbow <justin.rainbow@gmail.com> * @author Niels Keurentjes <niels.keurentjes@omines.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class DependsCommand extends Command class DependsCommand extends BaseCommand
{ {
protected function configure() protected function configure()
{ {
@ -173,41 +170,5 @@ EOT
} }
} }
/**
* @param string|string[] $needle The package(s) to inspect.
* @param PackageInterface[] $packages List of installed packages.
* @param ConstraintInterface|null $constraint Optional constraint to filter by.
* @param bool $invert Whether to invert matches on the previous constraint.
* @param bool $recurse Whether to recursively expand the requirement tree.
* @return array An array with dependers as key, and as values an array containing the source package and the link respectively
*/
private function getDependents($needle, $packages, $constraint = null, $invert = false, $recurse = true)
{
$needles = is_array($needle) ? $needle : array($needle);
$results = array();
// Loop over all currently installed packages.
foreach ($packages as $package) {
// Requirements and replaces are both considered valid reasons for a package to be installed
$links = $package->getRequires() + $package->getReplaces();
// Require-dev is only relevant for the root package
if ($package instanceof RootPackageInterface) {
$links += $package->getDevRequires();
}
// Cross-reference all discovered links to the needles
foreach ($links as $link) {
foreach ($needles as $needle) {
if ($link->getTarget() === $needle) {
if (is_null($constraint) || (($link->getConstraint()->matches($constraint) === !$invert))) {
$results[$link->getSource()] = array($package, $link, $recurse ? $this->getDependents($link->getSource(), $packages, null, false, true) : array());
}
}
}
}
}
ksort($results);
return $results;
}
} }

View File

@ -29,7 +29,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/** /**
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class DiagnoseCommand extends Command class DiagnoseCommand extends BaseCommand
{ {
/** @var RemoteFileSystem */ /** @var RemoteFileSystem */
protected $rfs; protected $rfs;

View File

@ -21,7 +21,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/** /**
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class DumpAutoloadCommand extends Command class DumpAutoloadCommand extends BaseCommand
{ {
protected function configure() protected function configure()
{ {

View File

@ -21,7 +21,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/** /**
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class GlobalCommand extends Command class GlobalCommand extends BaseCommand
{ {
protected function configure() protected function configure()
{ {

View File

@ -26,7 +26,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/** /**
* @author Robert Schönthal <seroscho@googlemail.com> * @author Robert Schönthal <seroscho@googlemail.com>
*/ */
class HomeCommand extends Command class HomeCommand extends BaseCommand
{ {
/** /**
* {@inheritDoc} * {@inheritDoc}

View File

@ -31,7 +31,7 @@ use Symfony\Component\Process\ExecutableFinder;
* @author Justin Rainbow <justin.rainbow@gmail.com> * @author Justin Rainbow <justin.rainbow@gmail.com>
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class InitCommand extends Command class InitCommand extends BaseCommand
{ {
/** @var CompositeRepository */ /** @var CompositeRepository */
protected $repos; protected $repos;

View File

@ -26,7 +26,7 @@ use Symfony\Component\Console\Output\OutputInterface;
* @author Konstantin Kudryashov <ever.zet@gmail.com> * @author Konstantin Kudryashov <ever.zet@gmail.com>
* @author Nils Adermann <naderman@naderman.de> * @author Nils Adermann <naderman@naderman.de>
*/ */
class InstallCommand extends Command class InstallCommand extends BaseCommand
{ {
protected function configure() protected function configure()
{ {

View File

@ -25,7 +25,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/** /**
* @author Benoît Merlet <benoit.merlet@gmail.com> * @author Benoît Merlet <benoit.merlet@gmail.com>
*/ */
class LicensesCommand extends Command class LicensesCommand extends BaseCommand
{ {
protected function configure() protected function configure()
{ {

View File

@ -27,7 +27,7 @@ use Symfony\Component\Console\Output\OutputInterface;
* @author Pierre du Plessis <pdples@gmail.com> * @author Pierre du Plessis <pdples@gmail.com>
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class RemoveCommand extends Command class RemoveCommand extends BaseCommand
{ {
protected function configure() protected function configure()
{ {

View File

@ -22,7 +22,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/** /**
* @author Fabien Potencier <fabien.potencier@gmail.com> * @author Fabien Potencier <fabien.potencier@gmail.com>
*/ */
class RunScriptCommand extends Command class RunScriptCommand extends BaseCommand
{ {
/** /**
* @var array Array with command events * @var array Array with command events

View File

@ -20,7 +20,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/** /**
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class ScriptAliasCommand extends Command class ScriptAliasCommand extends BaseCommand
{ {
private $script; private $script;

View File

@ -26,7 +26,7 @@ use Composer\Plugin\PluginEvents;
/** /**
* @author Robert Schönthal <seroscho@googlemail.com> * @author Robert Schönthal <seroscho@googlemail.com>
*/ */
class SearchCommand extends Command class SearchCommand extends BaseCommand
{ {
protected $matches; protected $matches;
protected $lowMatches = array(); protected $lowMatches = array();

View File

@ -30,7 +30,7 @@ use Symfony\Component\Finder\Finder;
* @author Kevin Ran <kran@adobe.com> * @author Kevin Ran <kran@adobe.com>
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class SelfUpdateCommand extends Command class SelfUpdateCommand extends BaseCommand
{ {
const HOMEPAGE = 'getcomposer.org'; const HOMEPAGE = 'getcomposer.org';
const OLD_INSTALL_EXT = '-old.phar'; const OLD_INSTALL_EXT = '-old.phar';

View File

@ -38,7 +38,7 @@ use Composer\Spdx\SpdxLicenses;
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
* @author Jérémy Romey <jeremyFreeAgent> * @author Jérémy Romey <jeremyFreeAgent>
*/ */
class ShowCommand extends Command class ShowCommand extends BaseCommand
{ {
protected $versionParser; protected $versionParser;
protected $colors; protected $colors;

View File

@ -24,7 +24,7 @@ use Composer\Script\ScriptEvents;
* @author Tiago Ribeiro <tiago.ribeiro@seegno.com> * @author Tiago Ribeiro <tiago.ribeiro@seegno.com>
* @author Rui Marinho <rui.marinho@seegno.com> * @author Rui Marinho <rui.marinho@seegno.com>
*/ */
class StatusCommand extends Command class StatusCommand extends BaseCommand
{ {
protected function configure() protected function configure()
{ {

View File

@ -17,7 +17,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
class SuggestsCommand extends Command class SuggestsCommand extends BaseCommand
{ {
protected function configure() protected function configure()
{ {

View File

@ -28,7 +28,7 @@ use Symfony\Component\Console\Question\Question;
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
* @author Nils Adermann <naderman@naderman.de> * @author Nils Adermann <naderman@naderman.de>
*/ */
class UpdateCommand extends Command class UpdateCommand extends BaseCommand
{ {
protected function configure() protected function configure()
{ {

View File

@ -29,7 +29,7 @@ use Symfony\Component\Console\Output\OutputInterface;
* @author Robert Schönthal <seroscho@googlemail.com> * @author Robert Schönthal <seroscho@googlemail.com>
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class ValidateCommand extends Command class ValidateCommand extends BaseCommand
{ {
/** /**
* configure * configure