Skip to content

Commit

Permalink
Merge branch '3.4' into 4.4
Browse files Browse the repository at this point in the history
* 3.4:
  Add missing dots at the end of exception messages
  • Loading branch information
fabpot committed Mar 15, 2020
2 parents ee3302b + 90ce15b commit 15d100a
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion AbstractExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private function getFqcnTypeClass(InputInterface $input, SymfonyStyle $io, strin
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]);
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/DataTransformer/ArrayToPartsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
16 changes: 8 additions & 8 deletions Extension/Core/DataTransformer/DateTimeToArrayTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,35 +133,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,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;
Expand Down Expand Up @@ -180,7 +180,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);
Expand All @@ -201,7 +201,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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions Extension/Validator/ViolationMapper/ViolationPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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];
Expand All @@ -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];
Expand All @@ -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];
Expand Down
10 changes: 5 additions & 5 deletions Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,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
Expand Down Expand Up @@ -266,7 +266,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) {
Expand Down Expand Up @@ -501,7 +501,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
Expand Down Expand Up @@ -835,7 +835,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()) {
Expand Down Expand Up @@ -906,7 +906,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])) {
Expand Down
2 changes: 1 addition & 1 deletion FormView.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function offsetExists($name)
*/
public function offsetSet($name, $value)
{
throw new BadMethodCallException('Not supported');
throw new BadMethodCallException('Not supported.');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion PreloadedExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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];
Expand Down
4 changes: 2 additions & 2 deletions Test/Traits/ValidatorExtensionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Util/OrderedHashMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 15d100a

Please sign in to comment.