From 90ce15bdf0de7d3f500ac77bd278a65d593994c6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 15 Mar 2020 10:01:00 +0100 Subject: [PATCH] Add missing dots at the end of exception messages --- AbstractExtension.php | 2 +- Button.php | 4 ++-- Command/DebugCommand.php | 2 +- .../DataTransformer/ArrayToPartsTransformer.php | 2 +- .../DataTransformer/ChoiceToValueTransformer.php | 2 +- .../ChoicesToValuesTransformer.php | 2 +- .../DateIntervalToArrayTransformer.php | 6 +++--- .../DateIntervalToStringTransformer.php | 2 +- .../DateTimeToArrayTransformer.php | 16 ++++++++-------- .../NumberToLocalizedStringTransformer.php | 6 +++--- .../PercentToLocalizedStringTransformer.php | 2 +- .../ValueToDuplicatesTransformer.php | 4 ++-- .../Validator/ViolationMapper/ViolationPath.php | 8 ++++---- Form.php | 10 +++++----- FormView.php | 2 +- PreloadedExtension.php | 2 +- Test/Traits/ValidatorExtensionTrait.php | 4 ++-- Util/OrderedHashMap.php | 2 +- 18 files changed, 39 insertions(+), 39 deletions(-) diff --git a/AbstractExtension.php b/AbstractExtension.php index 22b8ae3854..1635bf8020 100644 --- a/AbstractExtension.php +++ b/AbstractExtension.php @@ -57,7 +57,7 @@ public function getType($name) } if (!isset($this->types[$name])) { - throw new InvalidArgumentException(sprintf('The type "%s" can not be loaded by this extension', $name)); + throw new InvalidArgumentException(sprintf('The type "%s" can not be loaded by this extension.', $name)); } return $this->types[$name]; diff --git a/Button.php b/Button.php index 50acb8db0c..aa981a0125 100644 --- a/Button.php +++ b/Button.php @@ -105,7 +105,7 @@ public function offsetUnset($offset) public function setParent(FormInterface $parent = null) { if ($this->submitted) { - throw new AlreadySubmittedException('You cannot set the parent of a submitted button'); + throw new AlreadySubmittedException('You cannot set the parent of a submitted button.'); } $this->parent = $parent; @@ -381,7 +381,7 @@ public function handleRequest($request = null) public function submit($submittedData, $clearMissing = true) { if ($this->submitted) { - throw new AlreadySubmittedException('A form can only be submitted once'); + throw new AlreadySubmittedException('A form can only be submitted once.'); } $this->submitted = true; diff --git a/Command/DebugCommand.php b/Command/DebugCommand.php index 49b2f1fe12..43ae1d66de 100644 --- a/Command/DebugCommand.php +++ b/Command/DebugCommand.php @@ -166,7 +166,7 @@ private function getFqcnTypeClass(InputInterface $input, SymfonyStyle $io, $shor return $classes[0]; } if (!$input->isInteractive()) { - throw new InvalidArgumentException(sprintf("The type \"%s\" is ambiguous.\n\nDid you mean one of these?\n %s", $shortClassName, implode("\n ", $classes))); + throw new InvalidArgumentException(sprintf("The type \"%s\" is ambiguous.\n\nDid you mean one of these?\n %s.", $shortClassName, implode("\n ", $classes))); } return $io->choice(sprintf("The type \"%s\" is ambiguous.\n\nSelect one of the following form types to display its information:", $shortClassName), $classes, $classes[0]); diff --git a/Extension/Core/DataTransformer/ArrayToPartsTransformer.php b/Extension/Core/DataTransformer/ArrayToPartsTransformer.php index b073a123cf..f79920971c 100644 --- a/Extension/Core/DataTransformer/ArrayToPartsTransformer.php +++ b/Extension/Core/DataTransformer/ArrayToPartsTransformer.php @@ -76,7 +76,7 @@ public function reverseTransform($array) return null; } - throw new TransformationFailedException(sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys))); + throw new TransformationFailedException(sprintf('The keys "%s" should not be empty.', implode('", "', $emptyKeys))); } return $result; diff --git a/Extension/Core/DataTransformer/ChoiceToValueTransformer.php b/Extension/Core/DataTransformer/ChoiceToValueTransformer.php index cad078285f..e1feafe62e 100644 --- a/Extension/Core/DataTransformer/ChoiceToValueTransformer.php +++ b/Extension/Core/DataTransformer/ChoiceToValueTransformer.php @@ -45,7 +45,7 @@ public function reverseTransform($value) return null; } - throw new TransformationFailedException(sprintf('The choice "%s" does not exist or is not unique', $value)); + throw new TransformationFailedException(sprintf('The choice "%s" does not exist or is not unique.', $value)); } return current($choices); diff --git a/Extension/Core/DataTransformer/ChoicesToValuesTransformer.php b/Extension/Core/DataTransformer/ChoicesToValuesTransformer.php index ac2108f0c4..6c9e4fe9dc 100644 --- a/Extension/Core/DataTransformer/ChoicesToValuesTransformer.php +++ b/Extension/Core/DataTransformer/ChoicesToValuesTransformer.php @@ -65,7 +65,7 @@ public function reverseTransform($array) $choices = $this->choiceList->getChoicesForValues($array); if (\count($choices) !== \count($array)) { - throw new TransformationFailedException('Could not find all matching choices for the given values'); + throw new TransformationFailedException('Could not find all matching choices for the given values.'); } return $choices; diff --git a/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php b/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php index 65e535d979..a910cfdda4 100644 --- a/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php +++ b/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php @@ -129,14 +129,14 @@ public function reverseTransform($value) } } if (\count($emptyFields) > 0) { - throw new TransformationFailedException(sprintf('The fields "%s" should not be empty', implode('", "', $emptyFields))); + throw new TransformationFailedException(sprintf('The fields "%s" should not be empty.', implode('", "', $emptyFields))); } if (isset($value['invert']) && !\is_bool($value['invert'])) { - throw new TransformationFailedException('The value of "invert" must be boolean'); + throw new TransformationFailedException('The value of "invert" must be boolean.'); } foreach (self::$availableFields as $field => $char) { if ('invert' !== $field && isset($value[$field]) && !ctype_digit((string) $value[$field])) { - throw new TransformationFailedException(sprintf('This amount of "%s" is invalid', $field)); + throw new TransformationFailedException(sprintf('This amount of "%s" is invalid.', $field)); } } try { diff --git a/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php b/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php index aaefdfac9d..821761f227 100644 --- a/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php +++ b/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php @@ -79,7 +79,7 @@ public function reverseTransform($value) return null; } if (!$this->isISO8601($value)) { - throw new TransformationFailedException('Non ISO 8601 date strings are not supported yet'); + throw new TransformationFailedException('Non ISO 8601 date strings are not supported yet.'); } $valuePattern = '/^'.preg_replace('/%([yYmMdDhHiIsSwW])(\w)/', '(?P<$1>\d+)$2', $this->format).'$/'; if (!preg_match($valuePattern, $value)) { diff --git a/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php b/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php index ca934614cd..9c061a86dd 100644 --- a/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php +++ b/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php @@ -134,35 +134,35 @@ public function reverseTransform($value) } if (\count($emptyFields) > 0) { - throw new TransformationFailedException(sprintf('The fields "%s" should not be empty', implode('", "', $emptyFields))); + throw new TransformationFailedException(sprintf('The fields "%s" should not be empty.', implode('", "', $emptyFields))); } if (isset($value['month']) && !ctype_digit((string) $value['month'])) { - throw new TransformationFailedException('This month is invalid'); + throw new TransformationFailedException('This month is invalid.'); } if (isset($value['day']) && !ctype_digit((string) $value['day'])) { - throw new TransformationFailedException('This day is invalid'); + throw new TransformationFailedException('This day is invalid.'); } if (isset($value['year']) && !ctype_digit((string) $value['year'])) { - throw new TransformationFailedException('This year is invalid'); + throw new TransformationFailedException('This year is invalid.'); } if (!empty($value['month']) && !empty($value['day']) && !empty($value['year']) && false === checkdate($value['month'], $value['day'], $value['year'])) { - throw new TransformationFailedException('This is an invalid date'); + throw new TransformationFailedException('This is an invalid date.'); } if (isset($value['hour']) && !ctype_digit((string) $value['hour'])) { - throw new TransformationFailedException('This hour is invalid'); + throw new TransformationFailedException('This hour is invalid.'); } if (isset($value['minute']) && !ctype_digit((string) $value['minute'])) { - throw new TransformationFailedException('This minute is invalid'); + throw new TransformationFailedException('This minute is invalid.'); } if (isset($value['second']) && !ctype_digit((string) $value['second'])) { - throw new TransformationFailedException('This second is invalid'); + throw new TransformationFailedException('This second is invalid.'); } try { diff --git a/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php b/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php index fe9002fe47..a480b8312b 100644 --- a/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php +++ b/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php @@ -152,7 +152,7 @@ public function reverseTransform($value) } if (\in_array($value, ['NaN', 'NAN', 'nan'], true)) { - throw new TransformationFailedException('"NaN" is not a valid number'); + throw new TransformationFailedException('"NaN" is not a valid number.'); } $position = 0; @@ -183,7 +183,7 @@ public function reverseTransform($value) } if ($result >= PHP_INT_MAX || $result <= -PHP_INT_MAX) { - throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like'); + throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like.'); } $result = $this->castParsedValue($result); @@ -204,7 +204,7 @@ public function reverseTransform($value) $remainder = trim($remainder, " \t\n\r\0\x0b\xc2\xa0"); if ('' !== $remainder) { - throw new TransformationFailedException(sprintf('The number contains unrecognized characters: "%s"', $remainder)); + throw new TransformationFailedException(sprintf('The number contains unrecognized characters: "%s".', $remainder)); } } diff --git a/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php b/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php index 7aacb29e0d..5de0656164 100644 --- a/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php +++ b/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php @@ -162,7 +162,7 @@ public function reverseTransform($value) $remainder = trim($remainder, " \t\n\r\0\x0b\xc2\xa0"); if ('' !== $remainder) { - throw new TransformationFailedException(sprintf('The number contains unrecognized characters: "%s"', $remainder)); + throw new TransformationFailedException(sprintf('The number contains unrecognized characters: "%s".', $remainder)); } } diff --git a/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php b/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php index c1944cb9bf..4f04645eb7 100644 --- a/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php +++ b/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php @@ -64,7 +64,7 @@ public function reverseTransform($array) foreach ($this->keys as $key) { if (isset($array[$key]) && '' !== $array[$key] && false !== $array[$key] && [] !== $array[$key]) { if ($array[$key] !== $result) { - throw new TransformationFailedException('All values in the array should be the same'); + throw new TransformationFailedException('All values in the array should be the same.'); } } else { $emptyKeys[] = $key; @@ -77,7 +77,7 @@ public function reverseTransform($array) return null; } - throw new TransformationFailedException(sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys))); + throw new TransformationFailedException(sprintf('The keys "%s" should not be empty.', implode('", "', $emptyKeys))); } return $result; diff --git a/Extension/Validator/ViolationMapper/ViolationPath.php b/Extension/Validator/ViolationMapper/ViolationPath.php index 54de667cd1..1b67982788 100644 --- a/Extension/Validator/ViolationMapper/ViolationPath.php +++ b/Extension/Validator/ViolationMapper/ViolationPath.php @@ -163,7 +163,7 @@ public function getElements() public function getElement($index) { if (!isset($this->elements[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the violation path', $index)); + throw new OutOfBoundsException(sprintf('The index %s is not within the violation path.', $index)); } return $this->elements[$index]; @@ -175,7 +175,7 @@ public function getElement($index) public function isProperty($index) { if (!isset($this->isIndex[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the violation path', $index)); + throw new OutOfBoundsException(sprintf('The index %s is not within the violation path.', $index)); } return !$this->isIndex[$index]; @@ -187,7 +187,7 @@ public function isProperty($index) public function isIndex($index) { if (!isset($this->isIndex[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the violation path', $index)); + throw new OutOfBoundsException(sprintf('The index %s is not within the violation path.', $index)); } return $this->isIndex[$index]; @@ -212,7 +212,7 @@ public function isIndex($index) public function mapsForm($index) { if (!isset($this->mapsForm[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the violation path', $index)); + throw new OutOfBoundsException(sprintf('The index %s is not within the violation path.', $index)); } return $this->mapsForm[$index]; diff --git a/Form.php b/Form.php index b25afe3a9e..0403ba1049 100644 --- a/Form.php +++ b/Form.php @@ -163,7 +163,7 @@ public function __construct(FormConfigInterface $config) // `setData` and `add` will not lead to the correct population of // the child forms. if ($config->getCompound() && !$config->getDataMapper()) { - throw new LogicException('Compound forms need a data mapper'); + throw new LogicException('Compound forms need a data mapper.'); } // If the form inherits the data from its parent, it is not necessary @@ -260,7 +260,7 @@ public function isDisabled() public function setParent(FormInterface $parent = null) { if ($this->submitted) { - throw new AlreadySubmittedException('You cannot set the parent of a submitted form'); + throw new AlreadySubmittedException('You cannot set the parent of a submitted form.'); } if (null !== $parent && '' === $this->name) { @@ -495,7 +495,7 @@ public function handleRequest($request = null) public function submit($submittedData, $clearMissing = true) { if ($this->submitted) { - throw new AlreadySubmittedException('A form can only be submitted once'); + throw new AlreadySubmittedException('A form can only be submitted once.'); } // Initialize errors in the very beginning so we're sure @@ -810,7 +810,7 @@ public function all() public function add($child, $type = null, array $options = []) { if ($this->submitted) { - throw new AlreadySubmittedException('You cannot add children to a submitted form'); + throw new AlreadySubmittedException('You cannot add children to a submitted form.'); } if (!$this->config->getCompound()) { @@ -879,7 +879,7 @@ public function add($child, $type = null, array $options = []) public function remove($name) { if ($this->submitted) { - throw new AlreadySubmittedException('You cannot remove children from a submitted form'); + throw new AlreadySubmittedException('You cannot remove children from a submitted form.'); } if (isset($this->children[$name])) { diff --git a/FormView.php b/FormView.php index 0d1310b22d..6393c2d237 100644 --- a/FormView.php +++ b/FormView.php @@ -132,7 +132,7 @@ public function offsetExists($name) */ public function offsetSet($name, $value) { - throw new BadMethodCallException('Not supported'); + throw new BadMethodCallException('Not supported.'); } /** diff --git a/PreloadedExtension.php b/PreloadedExtension.php index 759ae9ad17..310b70f596 100644 --- a/PreloadedExtension.php +++ b/PreloadedExtension.php @@ -47,7 +47,7 @@ public function __construct(array $types, array $typeExtensions, FormTypeGuesser public function getType($name) { if (!isset($this->types[$name])) { - throw new InvalidArgumentException(sprintf('The type "%s" can not be loaded by this extension', $name)); + throw new InvalidArgumentException(sprintf('The type "%s" can not be loaded by this extension.', $name)); } return $this->types[$name]; diff --git a/Test/Traits/ValidatorExtensionTrait.php b/Test/Traits/ValidatorExtensionTrait.php index 46bd8b7e57..670382619d 100644 --- a/Test/Traits/ValidatorExtensionTrait.php +++ b/Test/Traits/ValidatorExtensionTrait.php @@ -30,11 +30,11 @@ trait ValidatorExtensionTrait protected function getValidatorExtension() { if (!interface_exists(ValidatorInterface::class)) { - throw new \Exception('In order to use the "ValidatorExtensionTrait", the symfony/validator component must be installed'); + throw new \Exception('In order to use the "ValidatorExtensionTrait", the symfony/validator component must be installed.'); } if (!$this instanceof TypeTestCase) { - throw new \Exception(sprintf('The trait "ValidatorExtensionTrait" can only be added to a class that extends %s', TypeTestCase::class)); + throw new \Exception(sprintf('The trait "ValidatorExtensionTrait" can only be added to a class that extends %s.', TypeTestCase::class)); } $this->validator = $this->getMockBuilder(ValidatorInterface::class)->getMock(); diff --git a/Util/OrderedHashMap.php b/Util/OrderedHashMap.php index 19ec4fc7d2..45b9e26c01 100644 --- a/Util/OrderedHashMap.php +++ b/Util/OrderedHashMap.php @@ -112,7 +112,7 @@ public function offsetExists($key) public function offsetGet($key) { if (!isset($this->elements[$key])) { - throw new \OutOfBoundsException('The offset "'.$key.'" does not exist.'); + throw new \OutOfBoundsException(sprintf('The offset "%s" does not exist.', $key)); } return $this->elements[$key];