8000 [Console] Allow false as a $shortcut in InputOption by jayminsilicon · Pull Request #53711 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Input/InputOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(string $name, $shortcut = null, ?int $mode = null, s
throw new InvalidArgumentException('An option name cannot be empty.');
}

if ('' === $shortcut || [] === $shortcut) {
if ('' === $shortcut || [] === $shortcut || false === $shortcut) {
$shortcut = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public function testShortcut()
$this->assertEquals('0|z', $option->getShortcut(), '-0 is an acceptable shortcut value when embedded in an array');
$option = new InputOption('foo', '0|z');
$this->assertEquals('0|z', $option->getShortcut(), '-0 is an acceptable shortcut value when embedded in a string-list');
$option = new InputOption('foo', false);
$this->assertNull($option->getShortcut(), '__construct() makes the shortcut null when given a false as value');
}

public function testModes()
Expand Down
0