Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbe4491a

Browse files
committed
[Console] Fix autocompletion of argument with default value
1 parent70d96aa commitbe4491a

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ public function bind(InputDefinition $definition): void
109109
// complete argument value
110110
$this->completionType =self::TYPE_ARGUMENT_VALUE;
111111

112-
$arguments =$this->getArguments();
113-
foreach ($argumentsas$argumentName =>$argumentValue) {
114-
if (null ===$argumentValue) {
112+
foreach ($this->definition->getArguments()as$argumentName =>$argument) {
113+
if (!isset($this->arguments[$argumentName])) {
115114
break;
116115
}
117116

117+
$argumentValue =$this->arguments[$argumentName];
118118
$this->completionName =$argumentName;
119119
if (\is_array($argumentValue)) {
120120
$this->completionValue =$argumentValue ?$argumentValue[array_key_last($argumentValue)] :null;
@@ -124,7 +124,7 @@ public function bind(InputDefinition $definition): void
124124
}
125125

126126
if ($this->currentIndex >=\count($this->tokens)) {
127-
if (null ===$arguments[$argumentName] ||$this->definition->getArgument($argumentName)->isArray()) {
127+
if (!isset($this->arguments[$argumentName]) ||$this->definition->getArgument($argumentName)->isArray()) {
128128
$this->completionName =$argumentName;
129129
$this->completionValue ='';
130130
}else {

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ public function provideBindWithLastArrayArgumentData()
9797
yield [CompletionInput::fromTokens(['bin/console','symfony','sen'],2),'sen'];
9898
}
9999

100+
publicfunctiontestBindArgumentWithDefault()
101+
{
102+
$definition =newInputDefinition([
103+
newInputArgument('arg-with-default', InputArgument::OPTIONAL,'','default'),
104+
]);
105+
106+
$input = CompletionInput::fromTokens(['bin/console'],1);
107+
$input->bind($definition);
108+
109+
$this->assertEquals(CompletionInput::TYPE_ARGUMENT_VALUE,$input->getCompletionType(),'Unexpected type');
110+
$this->assertEquals('arg-with-default',$input->getCompletionName(),'Unexpected name');
111+
$this->assertEquals('',$input->getCompletionValue(),'Unexpected value');
112+
}
113+
100114
/**
101115
* @dataProvider provideFromStringData
102116
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp