From cf9039e88bc5b1ef8ae17c8b7767b358040c39d6 Mon Sep 17 00:00:00 2001 From: Arnaud Kleinpeter Date: Wed, 2 May 2012 00:44:56 +0300 Subject: [PATCH 1/2] Added a unit test for the shortcut name of the InputOption class --- src/Symfony/Component/Console/Tests/Input/InputOptionTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php index 0b0639ff3d..125629fac0 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php @@ -35,6 +35,10 @@ class InputOptionTest extends \PHPUnit_Framework_TestCase $this->assertEquals('f', $option->getShortcut(), '__construct() can take a shortcut as its second argument'); $option = new InputOption('foo', '-f'); $this->assertEquals('f', $option->getShortcut(), '__construct() removes the leading - of the shortcut'); + $option = new InputOption('foo'); + $this->assertNull($option->getShortcut(), '__construct() makes the shortcut null by default'); + $option = new InputOption('foo', '-'); + $this->assertNull($option->getShortcut(), '__construct() makes the shortcut null if a single dash is specified as its name'); // mode argument $option = new InputOption('foo', 'f'); From 2c19b3c7e52e6268e6dea6eb48c5c5a04fc0b6fe Mon Sep 17 00:00:00 2001 From: Arnaud Kleinpeter Date: Sun, 20 May 2012 14:59:46 +0200 Subject: [PATCH 2/2] Empty shortcut check in the constructor --- src/Symfony/Component/Console/Input/InputOption.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index 0f2604556c..dbfcb216ad 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -58,6 +58,10 @@ class InputOption if ('-' === $shortcut[0]) { $shortcut = substr($shortcut, 1); } + + if (empty($shortcut)) { + $shortcut = null; + } } if (null === $mode) {