diff --git a/src/Composer/Command/BaseCommand.php b/src/Composer/Command/BaseCommand.php
index 2a70b584d..365733d85 100644
--- a/src/Composer/Command/BaseCommand.php
+++ b/src/Composer/Command/BaseCommand.php
@@ -79,6 +79,18 @@ abstract class BaseCommand extends Command
$this->getApplication()->resetComposer();
}
+ /**
+ * Whether or not this command is meant to call another command.
+ *
+ * This is mainly needed to avoid duplicated warnings messages.
+ *
+ * @return bool
+ */
+ public function isProxyCommand()
+ {
+ return false;
+ }
+
/**
* @return IOInterface
*/
diff --git a/src/Composer/Command/GlobalCommand.php b/src/Composer/Command/GlobalCommand.php
index 9aa48706b..beeca5b77 100644
--- a/src/Composer/Command/GlobalCommand.php
+++ b/src/Composer/Command/GlobalCommand.php
@@ -80,4 +80,12 @@ EOT
return $this->getApplication()->run($input, $output);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public function isProxyCommand()
+ {
+ return true;
+ }
}
diff --git a/src/Composer/Command/OutdatedCommand.php b/src/Composer/Command/OutdatedCommand.php
index d89434951..b3cf566df 100644
--- a/src/Composer/Command/OutdatedCommand.php
+++ b/src/Composer/Command/OutdatedCommand.php
@@ -71,4 +71,12 @@ EOT
return $this->getApplication()->run($input, $output);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public function isProxyCommand()
+ {
+ return true;
+ }
}
diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php
index 60ac50508..a03327df3 100644
--- a/src/Composer/Console/Application.php
+++ b/src/Composer/Console/Application.php
@@ -55,6 +55,8 @@ class Application extends BaseApplication
/_/
';
+ private $hasPluginCommands = false;
+
public function __construct()
{
static $shutdownRegistered = false;
@@ -107,17 +109,29 @@ class Application extends BaseApplication
$io = $this->io = new ConsoleIO($input, $output, $this->getHelperSet());
ErrorHandler::register($io);
- // determine command name to be executed
+ if (!$input->hasParameterOption('--no-plugins') && !$this->hasPluginCommands) {
+ foreach ($this->getPluginCommands() as $command) {
+ if ($this->has($command->getName())) {
+ $io->writeError('Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped');
+ } else {
+ $this->add($command);
+ }
+ }
+ $this->hasPluginCommands = true;
+ }
+
+ // determine command name to be executed, and if it's a proxy command
$commandName = '';
+ $isProxyCommand = false;
if ($name = $this->getCommandName($input)) {
try {
- $commandName = $this->find($name)->getName();
+ $command = $this->find($name);
+ $commandName = $command->getName();
+ $isProxyCommand = ($command instanceof Command\BaseCommand && $command->isProxyCommand());
} catch (\InvalidArgumentException $e) {
}
}
- $isProxyCommand = $commandName === 'global' || $commandName === 'outdated';
-
if (!$isProxyCommand) {
$io->writeError(sprintf(
'Running %s (%s) with %s on %s',
@@ -196,16 +210,6 @@ class Application extends BaseApplication
$this->io->enableDebugging($startTime);
}
- if (!$input->hasParameterOption('--no-plugins') && !$isProxyCommand) {
- foreach ($this->getPluginCommands() as $command) {
- if ($this->has($command->getName())) {
- $io->writeError('Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped');
- } else {
- $this->add($command);
- }
- }
- }
-
$result = parent::doRun($input, $output);
if (isset($oldWorkingDir)) {
diff --git a/tests/Composer/Test/ApplicationTest.php b/tests/Composer/Test/ApplicationTest.php
index 4e843bfa6..823c2b4d1 100644
--- a/tests/Composer/Test/ApplicationTest.php
+++ b/tests/Composer/Test/ApplicationTest.php
@@ -25,6 +25,11 @@ class ApplicationTest extends TestCase
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
+ $inputMock->expects($this->once())
+ ->method('hasParameterOption')
+ ->with($this->equalTo('--no-plugins'))
+ ->will($this->returnValue(true));
+
$inputMock->expects($this->once())
->method('getFirstArgument')
->will($this->returnValue('list'));