From a92b9a3cdb2941b4f5866587a30476306d36939f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Mar 2020 08:32:23 +0100 Subject: [PATCH] Fix quotes in exception messages --- Descriptor/ApplicationDescription.php | 2 +- Formatter/OutputFormatter.php | 2 +- Helper/Table.php | 2 +- Question/ChoiceQuestion.php | 2 +- Tests/Helper/QuestionHelperTest.php | 4 ++-- Tests/Helper/TableTest.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Descriptor/ApplicationDescription.php b/Descriptor/ApplicationDescription.php index 7e214712d..65b53084f 100644 --- a/Descriptor/ApplicationDescription.php +++ b/Descriptor/ApplicationDescription.php @@ -88,7 +88,7 @@ public function getCommands() public function getCommand($name) { if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { - throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name)); + throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name)); } return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name]; diff --git a/Formatter/OutputFormatter.php b/Formatter/OutputFormatter.php index 99e0ac1e9..3202fc176 100644 --- a/Formatter/OutputFormatter.php +++ b/Formatter/OutputFormatter.php @@ -119,7 +119,7 @@ public function hasStyle($name) public function getStyle($name) { if (!$this->hasStyle($name)) { - throw new InvalidArgumentException(sprintf('Undefined style: %s.', $name)); + throw new InvalidArgumentException(sprintf('Undefined style: "%s".', $name)); } return $this->styles[strtolower($name)]; diff --git a/Helper/Table.php b/Helper/Table.php index 0f3d67358..e6dc6a8a5 100644 --- a/Helper/Table.php +++ b/Helper/Table.php @@ -460,7 +460,7 @@ private function fillNextRows(array $rows, $line) $unmergedRows = []; foreach ($rows[$line] as $column => $cell) { if (null !== $cell && !$cell instanceof TableCell && !is_scalar($cell) && !(\is_object($cell) && method_exists($cell, '__toString'))) { - throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing __toString, %s given.', \gettype($cell))); + throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', \gettype($cell))); } if ($cell instanceof TableCell && $cell->getRowspan() > 1) { $nbLines = $cell->getRowspan() - 1; diff --git a/Question/ChoiceQuestion.php b/Question/ChoiceQuestion.php index 3dca16004..62532844b 100644 --- a/Question/ChoiceQuestion.php +++ b/Question/ChoiceQuestion.php @@ -155,7 +155,7 @@ private function getDefaultValidator() } if (\count($results) > 1) { - throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results))); + throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of "%s".', implode('" or "', $results))); } $result = array_search($value, $choices); diff --git a/Tests/Helper/QuestionHelperTest.php b/Tests/Helper/QuestionHelperTest.php index d2afee42f..4303c020a 100644 --- a/Tests/Helper/QuestionHelperTest.php +++ b/Tests/Helper/QuestionHelperTest.php @@ -524,7 +524,7 @@ public function testSelectChoiceFromChoiceList($providedAnswer, $expectedValue) public function testAmbiguousChoiceFromChoicelist() { $this->expectException('InvalidArgumentException'); - $this->expectExceptionMessage('The provided answer is ambiguous. Value should be one of env_2 or env_3.'); + $this->expectExceptionMessage('The provided answer is ambiguous. Value should be one of "env_2" or "env_3".'); $possibleChoices = [ 'env_1' => 'My first environment', 'env_2' => 'My environment', @@ -891,7 +891,7 @@ public function testLegacySelectChoiceFromChoiceList($providedAnswer, $expectedV public function testLegacyAmbiguousChoiceFromChoicelist() { $this->expectException('InvalidArgumentException'); - $this->expectExceptionMessage('The provided answer is ambiguous. Value should be one of env_2 or env_3.'); + $this->expectExceptionMessage('The provided answer is ambiguous. Value should be one of "env_2" or "env_3".'); $possibleChoices = [ 'env_1' => 'My first environment', 'env_2' => 'My environment', diff --git a/Tests/Helper/TableTest.php b/Tests/Helper/TableTest.php index 571cf0a6c..7e2bd8101 100644 --- a/Tests/Helper/TableTest.php +++ b/Tests/Helper/TableTest.php @@ -729,7 +729,7 @@ public function testColumnStyle() public function testThrowsWhenTheCellInAnArray() { $this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException'); - $this->expectExceptionMessage('A cell must be a TableCell, a scalar or an object implementing __toString, array given.'); + $this->expectExceptionMessage('A cell must be a TableCell, a scalar or an object implementing "__toString()", "array" given.'); $table = new Table($output = $this->getOutputStream()); $table ->setHeaders(['ISBN', 'Title', 'Author', 'Price'])