From 0c60add111607565cbbd5e2254feacc56709f81d Mon Sep 17 00:00:00 2001 From: Bilal Amarni Date: Sat, 25 Jun 2016 12:34:50 +0200 Subject: [PATCH] [Console] unmerge application args when needed --- src/Symfony/Component/Console/Command/Command.php | 13 +++++++++++++ .../Console/Tests/Fixtures/application_run2.txt | 1 - .../Console/Tests/Fixtures/command_astext.txt | 3 --- .../Console/Tests/Fixtures/command_asxml.txt | 7 +------ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index e38002b6d8b39..c30090098a08f 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -294,6 +294,19 @@ public function setCode($code) public function mergeApplicationDefinition($mergeArgs = true) { if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) { + if (!$mergeArgs && $this->applicationDefinitionMergedWithArgs) { + $commandArgs = array_udiff( + $this->definition->getArguments(), + $this->application->getDefinition()->getArguments(), + function ($arg1, $arg2) { + return strcmp($arg1->getName(), $arg2->getName()); + } + ); + + $this->definition->setArguments($commandArgs); + $this->applicationDefinitionMergedWithArgs = false; + } + return; } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_run2.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_run2.txt index d28b928ec3830..11b1c82a259fc 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_run2.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_run2.txt @@ -2,7 +2,6 @@ Usage: help [options] [--] [] Arguments: - command The command to execute command_name The command name [default: "help"] Options: diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_astext.txt b/src/Symfony/Component/Console/Tests/Fixtures/command_astext.txt index 7e206388078db..0f70c513190ce 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/command_astext.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_astext.txt @@ -2,9 +2,6 @@ namespace:name name -Arguments: - command The command to execute - Options: -h, --help Display this help message -q, --quiet Do not output any message diff --git a/src/Symfony/Component/Console/Tests/Fixtures/command_asxml.txt b/src/Symfony/Component/Console/Tests/Fixtures/command_asxml.txt index 5e776238aa0a1..2863bdb29f6cb 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/command_asxml.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/command_asxml.txt @@ -6,12 +6,7 @@ description help - - - The command to execute - - - +