Skip to content

Commit

Permalink
minor #29023 [Console] Remove duplicate condition (xuanquynh)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.8 branch.

Discussion
----------

[Console] Remove duplicate condition

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Inside the Command::mergeApplicationDefinition() method, the condition of $mergeArgs is checked twice now. Let's remove the second duplicate one.

See the capture below to review quickly!

```php
public function mergeApplicationDefinition($mergeArgs = true)
{
    if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
        return;
    }

    $this->definition->addOptions($this->application->getDefinition()->getOptions());

    if ($mergeArgs) {
        $currentArguments = $this->definition->getArguments();
        $this->definition->setArguments($this->application->getDefinition()->getArguments());
        $this->definition->addArguments($currentArguments);
    }

    $this->applicationDefinitionMerged = true;
    if ($mergeArgs) {
        $this->applicationDefinitionMergedWithArgs = true;
    }
}
```

Commits
-------

925842a Remove duplicate condition
  • Loading branch information
nicolas-grekas committed Oct 30, 2018
2 parents 9075d2e + 925842a commit 36e2983
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Symfony/Component/Console/Command/Command.php
Expand Up @@ -303,14 +303,13 @@ public function mergeApplicationDefinition($mergeArgs = true)

$this->definition->addOptions($this->application->getDefinition()->getOptions());

$this->applicationDefinitionMerged = true;

if ($mergeArgs) {
$currentArguments = $this->definition->getArguments();
$this->definition->setArguments($this->application->getDefinition()->getArguments());
$this->definition->addArguments($currentArguments);
}

$this->applicationDefinitionMerged = true;
if ($mergeArgs) {
$this->applicationDefinitionMergedWithArgs = true;
}
}
Expand Down

0 comments on commit 36e2983

Please sign in to comment.