8000 Rename to & restrict type · symfony/symfony@c4d65b3 · GitHub
[go: up one dir, main page]

Skip to content

Commit c4d65b3

Browse files
committed
Rename to & restrict type
1 parent a098ff8 commit c4d65b3

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
322322
$definition = $this->getDefinition();
323323
$values = null;
324324
if (CompletionInput::TYPE_OPTION_VALUE === $input->getCompletionType() && $definition->hasOption($input->getCompletionName())) {
325-
$values = $definition->getOption($input->getCompletionName())->getValues();
325+
$values = $definition->getOption($input->getCompletionName())->getCompletionValues();
326326
} elseif (CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType() && $definition->hasArgument($input->getCompletionName())) {
327-
$values = $definition->getArgument($input->getCompletionName())->getValues();
327+
$values = $definition->getArgument($input->getCompletionName())->getCompletionValues();
328328
}
329329
if (null === $values) {
330330
return;
@@ -334,12 +334,12 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
334334
if (null === $values) {
335335
return;
336336
}
337-
if (!is_iterable($values)) {
338-
throw new LogicException(sprintf('Callable for "%s" "%s" must return an iterable or null. Got "%s".', $input->getCompletionType(), $input->getCompletionName(), get_debug_type($values)));
337+
if (!\is_array($values)) {
338+
throw new LogicException(sprintf('Closure for "%s" "%s" must return an array or null. Got "%s".', $input->getCompletionType(), $input->getCompletionName(), get_debug_type($values)));
339339
}
340340
}
341341

342-
$suggestions->suggestValues(\is_array($values) ? $values : iterator_to_array($values));
342+
$suggestions->suggestValues($values);
343343
}
344344

345345
/**
@@ -472,8 +472,8 @@ public function addArgument(string $name, int $mode = null, string $description
472472
*/
473473
public function setArgumentValues(string $name, \Closure|iterable|null $values): static
474474
{
475-
$this->definition->getArgument($name)->setValues($values);
476-
$this->fullDefinition?->getArgument($name)->setValues($values);
475+
$this->definition->getArgument($name)->setCompletionValues($values);
476+
$this->fullDefinition?->getArgument($name)->setCompletionValues($values);
477477

478478
return $this;
479479
}

src/Symfony/Component/Console/Input/InputArgument.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class InputArgument
2828
private string $name;
2929
private int $mode;
3030
private string|int|bool|array|null|float $default;
31-
private \Closure|iterable|null $values;
31+
private array|\Closure|null $completionValues;
3232
private string $description;
3333

3434
/**
@@ -39,7 +39,7 @@ class InputArgument
3939
*
4040
* @throws InvalidArgumentException When argument mode is not valid
4141
*/
42-
public function __construct(string $name, int $mode = null, string $description = '', string|bool|int|float|array $default = null, \Closure|iterable|null $values = null)
42+
public function __construct(string $name, int $mode = null, string $description = '', string|bool|int|float|array $default = null, \Closure|array $completionValues = null)
4343
{
4444
if (null === $mode) {
4545
$mode = self::OPTIONAL;
@@ -52,7 +52,7 @@ public function __construct(string $name, int $mode = null, string $description
5252
$this->description = $description;
5353

5454
$this->setDefault($default);
55-
$this->setValues($values);
55+
$this->setCompletionValues($completionValues);
5656
}
5757

5858
/**
@@ -113,17 +113,17 @@ public function getDefault(): string|bool|int|float|array|null
113113
return $this->default;
114114
}
115115

116-
public function setValues(\Closure|iterable|null $values = null)
116+
public function setCompletionValues(array|\Closure $completionValues = null)
117117
{
118-
$this->values = $values;
118+
$this->completionValues = $completionValues;
119119
}
120120

121121
/**
122-
* Returns suggestion values for input completion.
122+
* Returns suggestions for input completion.
123123
*/
124-
public function getValues(): \Closure|iterable|null
124+
public function getCompletionValues(): array|\Closure|null
125125
{
126-
return $this->values;
126+
return $this->completionValues;
127127
}
128128

129129
/**

src/Symfony/Component/Console/Input/InputOption.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class InputOption
5050
private string|array|null $shortcut;
5151
private int $mode;
5252
private string|int|bool|array|null|float $default;
53-
private \Closure|iterable|null $values;
53+
private \Closure|iterable|null $completionValues;
5454
private string $description;
5555

5656
/**
@@ -60,7 +60,7 F438 @@ class InputOption
6060
*
6161
* @throws InvalidArgumentException If option mode is invalid or incompatible
6262
*/
63-
public function __construct(string $name, string|array $shortcut = null, int $mode = null, string $description = '', string|bool|int|float|array $default = null, \Closure|iterable|null $values = null)
63+
public function __construct(string $name, string|array $shortcut = null, int $mode = null, string $description = '', string|bool|int|float|array $default = null, array|\Closure $completionValues = null)
6464
{
6565
if (str_starts_with($name, '--')) {
6666
$name = substr($name, 2);
@@ -106,7 +106,7 @@ public function __construct(string $name, string|array $shortcut = null, int $mo
106106
}
107107

108108
$this->setDefault($default);
109-
$this->setValues($values);
109+
$this->setCompletionValues($completionValues);
110110
}
111111

112112
/**
@@ -195,21 +195,21 @@ public function getDefault(): string|bool|int|float|array|null
195195
return $this->default;
196196
}
197197

198-
public function setValues(\Closure|iterable|null $values = null)
198+
public function setCompletionValues(array|\Closure $completionValues = null): void
199199
{
200-
if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $values) {
200+
if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $completionValues) {
201201
throw new LogicException('Cannot set a completion when using InputOption::VALUE_NONE mode.');
202202
}
203203

204-
$this->values = $values;
204+
$this->completionValues = $completionValues;
205205
}
206206

207207
/**
208208
* Returns suggestions for input completion.
209209
*/
210-
public function getValues(): \Closure|iterable|null
210+
public function getCompletionValues(): array|\Closure|null
211211
{
212-
return $this->values;
212+
return $this->completionValues;
213213
}
214214

215215
/**

0 commit comments

Comments
 (0)
0