Skip to content

Commit 6a6bc7d

Browse files
committed
bug #43609 [Console] Fix array argument completion without input (wouterj)
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
2 parents 5c675ea + ebd7342 commit 6a6bc7d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Symfony/Component/Console/Completion/CompletionInput.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ public function bind(InputDefinition $definition): void
117117
}
118118

119119
$this->completionName = $argumentName;
120-
$this->completionValue = \is_array($argumentValue ?? '') ? $argumentValue[array_key_last($argumentValue)] : $argumentValue;
120+
if (\is_array($argumentValue)) {
121+
$this->completionValue = $argumentValue ? $argumentValue[array_key_last($argumentValue)] : null;
122+
} else {
123+
$this->completionValue = $argumentValue;
124+
}
121125
}
122126

123127
if ($this->currentIndex >= \count($this->tokens)) {

src/Symfony/Component/Console/Tests/Completion/CompletionInputTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function testBindWithLastArrayArgument(CompletionInput $input, ?string $e
9292

9393
public function provideBindWithLastArrayArgumentData()
9494
{
95+
yield [CompletionInput::fromTokens(['bin/console'], 1), null];
9596
yield [CompletionInput::fromTokens(['bin/console', 'symfony', 'sensiolabs'], 3), null];
9697
yield [CompletionInput::fromTokens(['bin/console', 'symfony', 'sen'], 2), 'sen'];
9798
}

0 commit comments

Comments
 (0)