Skip to content

Commit 37774e6

Browse files
jayminsiliconnicolas-grekas
authored andcommitted
[Console] Allow false as a $shortcut in InputOption
1 parent dbdf6ad commit 37774e6

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Input/InputOption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function __construct(string $name, $shortcut = null, ?int $mode = null, s
6969
throw new InvalidArgumentException('An option name cannot be empty.');
7070
}
7171

72-
if ('' === $shortcut || [] === $shortcut) {
72+
if ('' === $shortcut || [] === $shortcut || false === $shortcut) {
7373
$shortcut = null;
7474
}
7575

Tests/Input/InputOptionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public function testShortcut()
6969
$this->assertEquals('0|z', $option->getShortcut(), '-0 is an acceptable shortcut value when embedded in an array');
7070
$option = new InputOption('foo', '0|z');
7171
$this->assertEquals('0|z', $option->getShortcut(), '-0 is an acceptable shortcut value when embedded in a string-list');
72+
$option = new InputOption('foo', false);
73+
$this->assertNull($option->getShortcut(), '__construct() makes the shortcut null when given a false as value');
7274
}
7375

7476
public function testModes()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy