Skip to content

Commit

Permalink
bug #43609 [Console] Fix array argument completion without input (wou…
Browse files Browse the repository at this point in the history
…terj)

This PR was merged into the 5.4 branch.

Discussion
----------

[Console] Fix array argument completion without input

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #43605
| License       | MIT
| Doc PR        | n/a

Commits
-------

ebd7342 [Console] Fix array argument completion without input
  • Loading branch information
fabpot committed Oct 20, 2021
2 parents 5c675ea + ebd7342 commit 6a6bc7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Symfony/Component/Console/Completion/CompletionInput.php
Expand Up @@ -117,7 +117,11 @@ public function bind(InputDefinition $definition): void
}

$this->completionName = $argumentName;
$this->completionValue = \is_array($argumentValue ?? '') ? $argumentValue[array_key_last($argumentValue)] : $argumentValue;
if (\is_array($argumentValue)) {
$this->completionValue = $argumentValue ? $argumentValue[array_key_last($argumentValue)] : null;
} else {
$this->completionValue = $argumentValue;
}
}

if ($this->currentIndex >= \count($this->tokens)) {
Expand Down
Expand Up @@ -92,6 +92,7 @@ public function testBindWithLastArrayArgument(CompletionInput $input, ?string $e

public function provideBindWithLastArrayArgumentData()
{
yield [CompletionInput::fromTokens(['bin/console'], 1), null];
yield [CompletionInput::fromTokens(['bin/console', 'symfony', 'sensiolabs'], 3), null];
yield [CompletionInput::fromTokens(['bin/console', 'symfony', 'sen'], 2), 'sen'];
}
Expand Down

0 comments on commit 6a6bc7d

Please sign in to comment.