Skip to content

Commit b4d8808

Browse files
committed
[Console] unmerge application args when needed
1 parent 55f2000 commit b4d8808

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

src/Symfony/Component/Console/Command/Command.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,19 @@ public function setCode($code)
284284
public function mergeApplicationDefinition($mergeArgs = true)
285285
{
286286
if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
287+
if (!$mergeArgs && $this->applicationDefinitionMergedWithArgs) {
288+
$commandArgs = array_udiff(
289+
$this->definition->getArguments(),
290+
$this->application->getDefinition()->getArguments(),
291+
function ($arg1, $arg2) {
292+
return strcmp($arg1->getName(), $arg2->getName());
293+
}
294+
);
295+
296+
$this->definition->setArguments($commandArgs);
297+
$this->applicationDefinitionMergedWithArgs = false;
298+
}
299+
287300
return;
288301
}
289302

src/Symfony/Component/Console/Tests/Fixtures/application_run2.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ Usage:
22
help [--xml] [--format="..."] [--raw] [command_name]
33

44
Arguments:
5-
command The command to execute
65
command_name The command name (default: "help")
76

87
Options:

src/Symfony/Component/Console/Tests/Fixtures/command_astext.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
namespace:name
33

44
<comment>Aliases:</comment> <info>name</info>
5-
<comment>Arguments:</comment>
6-
<info>command </info> The command to execute
7-
85
<comment>Options:</comment>
96
<info>--help</info> (-h) Display this help message.
107
<info>--quiet</info> (-q) Do not output any message.

src/Symfony/Component/Console/Tests/Fixtures/command_asxml.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
<aliases>
77
<alias>name</alias>
88
</aliases>
9-
<arguments>
10-
<argument name="command" is_required="1" is_array="0">
11-
<description>The command to execute</description>
12-
<defaults/>
13-
</argument>
14-
</arguments>
9+
<arguments/>
1510
<options>
1611
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
1712
<description>Display this help message.</description>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy