From c0997634efa44d534c3fb47c5d52014f248b7cd1 Mon Sep 17 00:00:00 2001 From: Arnaud Kleinpeter Date: Sun, 17 Jun 2012 19:22:36 +0200 Subject: [PATCH 1/2] InputDefinition: corrected grammar mistakes and added a @throws declaration --- src/Symfony/Component/Console/Input/InputDefinition.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Input/InputDefinition.php b/src/Symfony/Component/Console/Input/InputDefinition.php index ffae4fe971..9551e968c4 100644 --- a/src/Symfony/Component/Console/Input/InputDefinition.php +++ b/src/Symfony/Component/Console/Input/InputDefinition.php @@ -113,7 +113,7 @@ class InputDefinition public function addArgument(InputArgument $argument) { if (isset($this->arguments[$argument->getName()])) { - throw new \LogicException(sprintf('An argument with name "%s" already exist.', $argument->getName())); + throw new \LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName())); } if ($this->hasAnArrayArgument) { @@ -262,9 +262,9 @@ class InputDefinition public function addOption(InputOption $option) { if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) { - throw new \LogicException(sprintf('An option named "%s" already exist.', $option->getName())); + throw new \LogicException(sprintf('An option named "%s" already exists.', $option->getName())); } elseif (isset($this->shortcuts[$option->getShortcut()]) && !$option->equals($this->options[$this->shortcuts[$option->getShortcut()]])) { - throw new \LogicException(sprintf('An option with shortcut "%s" already exist.', $option->getShortcut())); + throw new \LogicException(sprintf('An option with shortcut "%s" already exists.', $option->getShortcut())); } $this->options[$option->getName()] = $option; @@ -280,6 +280,8 @@ class InputDefinition * * @return InputOption A InputOption object * + * @throws \InvalidArgumentException When option given doesn't exist + * * @api */ public function getOption($name) From 60d371bc357799e677a430dd23e31fd97472da7c Mon Sep 17 00:00:00 2001 From: Arnaud Kleinpeter Date: Tue, 19 Jun 2012 00:08:25 +0200 Subject: [PATCH 2/2] InputDefinition: Fixed unit tests --- .../Component/Console/Tests/Input/InputDefinitionTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php index 0c50b3fd43..2b339f0906 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php @@ -84,7 +84,7 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase $this->fail('->addArgument() throws a Exception if another argument is already registered with the same name'); } catch (\Exception $e) { $this->assertInstanceOf('\Exception', $e, '->addArgument() throws a Exception if another argument is already registered with the same name'); - $this->assertEquals('An argument with name "foo" already exist.', $e->getMessage()); + $this->assertEquals('An argument with name "foo" already exists.', $e->getMessage()); } // cannot add a parameter after an array parameter @@ -215,14 +215,14 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase $this->fail('->addOption() throws a Exception if the another option is already registered with the same name'); } catch (\Exception $e) { $this->assertInstanceOf('\Exception', $e, '->addOption() throws a Exception if the another option is already registered with the same name'); - $this->assertEquals('An option named "foo" already exist.', $e->getMessage()); + $this->assertEquals('An option named "foo" already exists.', $e->getMessage()); } try { $definition->addOption($this->foo1); $this->fail('->addOption() throws a Exception if the another option is already registered with the same shortcut'); } catch (\Exception $e) { $this->assertInstanceOf('\Exception', $e, '->addOption() throws a Exception if the another option is already registered with the same shortcut'); - $this->assertEquals('An option with shortcut "f" already exist.', $e->getMessage()); + $this->assertEquals('An option with shortcut "f" already exists.', $e->getMessage()); } }