8000 fix · symfony/symfony@a009d4f · GitHub
[go: up one dir, main page]

Skip to content

Commit a009d4f

Browse files
committed
fix
1 parent 11b9599 commit a009d4f

File tree

4 files changed

+20
-25
lines changed

4 files changed

+20
-25
lines changed

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

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function validate(): void
6363
$definition = $this->definition;
6464
$givenArguments = $this->arguments;
6565

66-
$missingArguments = array_filter(\array_keys($definition->getArguments()), fn ($argument) => !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired());
66+
$missingArguments = array_filter(array_keys($definition->getArguments()), fn ($argument) => !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired());
6767

6868
if (\count($missingArguments) > 0) {
6969
throw new RuntimeException(\sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
@@ -90,7 +90,7 @@ public function getArguments(): array
9090
*
9191
* @param bool $strip Whether to return the raw parameters (false) or the values after the command name (true)
9292
*
93-
* @return array<string|bool|int|float|null|array<string|bool|int|float|null>>
93+
* @return array<string|bool|int|float|array<string|bool|int|float|null>|null>
9494
*/
9595
public function getRawArguments(bool $strip = false): array
9696
{
@@ -145,7 +145,7 @@ public function getOptions(): array
145145
/**
146146
* Returns all the given options NOT merged with the default values.
147147
*
148-
* @return array<string|bool|int|float|null|array<string|bool|int|float|null>>
148+
* @return array<string|bool|int|float|array<string|bool|int|float|null>|null>
149149
*/
150150
public function getRawOptions(): array
151151
{
@@ -224,10 +224,10 @@ public function unparse(array $optionNames = []): array
224224
{
225225
$rawOptions = $this->getRawOptions();
226226

227-
$filteredRawOptions = count($optionNames) === 0
227+
$filteredRawOptions = 0 === \count($optionNames)
228228
? $rawOptions
229229
: array_intersect_key($rawOptions, array_fill_keys($optionNames, ''),
230-
);
230+
);
231231

232232
return array_map(
233233
fn (string $optionName) => $this->unparseOption(
@@ -240,27 +240,25 @@ public function unparse(array $optionNames = []): array
240240
}
241241

242242
/**
243-
* @param string|bool|int|float|null|array<string|bool|int|float|null> $value
243+
* @param string|bool|int|float|array<string|bool|int|float|null>|null $value
244244
*/
245245
private function unparseOption(
246246
InputOption $option,
247247
string $name,
248248
array|bool|float|int|string|null $value,
249-
): string
250-
{
251-
return match(true) {
252-
$option->isNegatable() => sprintf('--%s%s', $value ? '' : 'no-', $name),
253-
!$option->acceptValue() => sprintf('--%s', $name),
254-
$option->isArray() => implode('', array_map(fn($item) => $this->unparseOptionWithValue($name, $item), $value,)),
249+
): string {
250+
return match (true) {
251+
$option->isNegatable() => \sprintf('--%s%s', $value ? '' : 'no-', $name),
252+
!$option->acceptValue() => \sprintf('--%s', $name),
253+
$option->isArray() => implode('', array_map(fn ($item) => $this->unparseOptionWithValue($name, $item), $value)),
255254
default => $this->unparseOptionWithValue($name, $value),
256255
};
257256
}
258257

259258
private function unparseOptionWithValue(
260259
string $name,
261260
bool|float|int|string|null $value,
262-
): string
263-
{
264-
return sprintf('--%s=%s', $name, $this->escapeToken($value));
261+
): string {
262+
return \sprintf('--%s=%s', $name, $this->escapeToken($value));
265263
}
266264
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @author Fabien Potencier <fabien@symfony.com>
2121
*
2222
* @method getRawArguments(bool $strip = false): array<string|bool|int|float|null|array<string|bool|int|float|null>> Returns all the given arguments NOT merged with the default values.
23-
* @method getRawOptions(): array<string|bool|int|float|null|array<string|bool|int|float|null>> Returns all the given options NOT merged with the default values.
23+
* @method getRawOptions(): array<string|bool|int|float|array<string|bool|int|float|null>|null> Returns all the given options NOT merged with the default values.
2424
*/
2525
interface InputInterface
2626
{

src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,7 @@ public function testUnparse(
603603
ArgvInput $input,
604604
?array $parsedOptions,
605605
array $expected,
606-
): void
607-
{
606+
) {
608607
if (null !== $inputDefinition) {
609608
$input->bind($inputDefinition);
610609
}
@@ -712,7 +711,7 @@ public static function unparseProvider(): iterable
712711
$createSingleOptionScenario = static fn (
713712
InputOption $option,
714713
array $input,
715-
array $expected
714+
array $expected,
716715
) => [
717716
new InputDefinition([$option]),
718717
new ArgvInput(['appName', ...$input]),
@@ -812,7 +811,7 @@ public static function unparseProvider(): iterable
812811

813812
$createEscapeOptionTokenScenario = static fn (
814813
string $optionValue,
815-
?string $expected
814+
?string $expected,
816815
) => [
817816
new InputDefinition([
818817
new InputOption(

src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Console\Tests\Input;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\Console\Exception\InvalidArgumentException;
1615
use Symfony\Component\Console\Input\ArrayInput;
1716
use Symfony\Component\Console\Input\InputArgument;
1817
use Symfony\Component\Console\Input\InputDefinition;
@@ -180,8 +179,7 @@ public function testUnparse(
180179
ArrayInput $input,
181180
?array $parsedOptions,
182181
array $expected,
183-
): void
184-
{
182+
) {
185183
if (null !== $inputDefinition) {
186184
$input->bind($inputDefinition);
187185
}
@@ -302,7 +300,7 @@ public static function unparseProvider(): iterable
302300
$createSingleOptionScenario = static fn (
303301
InputOption $option,
304302
array $input,
305-
array $expected
303+
array $expected,
306304
) => [
307305
new InputDefinition([$option]),
308306
new ArrayInput($input),
@@ -402,7 +400,7 @@ public static function unparseProvider(): iterable
402400

403401
$createEscapeOptionTokenScenario = static fn (
404402
string $optionValue,
405-
?string $expected
403+
?string $expected,
406404
) => [
407405
new InputDefinition([
408406
new InputOption(

0 commit comments

Comments
 (0)
0