From 8eb8f3b43c4b6a174bff00a089ba894c7637f5a5 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 --- .../Core/DataTransformer/BaseDateTimeTransformer.php | 4 ++-- Extension/Core/Type/ChoiceType.php | 2 +- Extension/Validator/ViolationMapper/ViolationPath.php | 8 ++++---- Form.php | 8 ++++---- Test/Traits/ValidatorExtensionTrait.php | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Extension/Core/DataTransformer/BaseDateTimeTransformer.php b/Extension/Core/DataTransformer/BaseDateTimeTransformer.php index 845ba88f04..f607105c67 100644 --- a/Extension/Core/DataTransformer/BaseDateTimeTransformer.php +++ b/Extension/Core/DataTransformer/BaseDateTimeTransformer.php @@ -53,13 +53,13 @@ public function __construct($inputTimezone = null, $outputTimezone = null) try { new \DateTimeZone($this->inputTimezone); } catch (\Exception $e) { - throw new InvalidArgumentException(sprintf('Input timezone is invalid: %s.', $this->inputTimezone), $e->getCode(), $e); + throw new InvalidArgumentException(sprintf('Input timezone is invalid: "%s".', $this->inputTimezone), $e->getCode(), $e); } try { new \DateTimeZone($this->outputTimezone); } catch (\Exception $e) { - throw new InvalidArgumentException(sprintf('Output timezone is invalid: %s.', $this->outputTimezone), $e->getCode(), $e); + throw new InvalidArgumentException(sprintf('Output timezone is invalid: "%s".', $this->outputTimezone), $e->getCode(), $e); } } } diff --git a/Extension/Core/Type/ChoiceType.php b/Extension/Core/Type/ChoiceType.php index 2bfc87dd80..1e506bf168 100644 --- a/Extension/Core/Type/ChoiceType.php +++ b/Extension/Core/Type/ChoiceType.php @@ -273,7 +273,7 @@ public function configureOptions(OptionsResolver $resolver) // Set by the user if (true !== $choicesAsValues) { - throw new \RuntimeException(sprintf('The "choices_as_values" option of the %s should not be used. Remove it and flip the contents of the "choices" option instead.', static::class)); + throw new \RuntimeException(sprintf('The "choices_as_values" option of the "%s" should not be used. Remove it and flip the contents of the "choices" option instead.', static::class)); } @trigger_error('The "choices_as_values" option is deprecated since Symfony 3.1 and will be removed in 4.0. You should not use it anymore.', E_USER_DEPRECATED); diff --git a/Extension/Validator/ViolationMapper/ViolationPath.php b/Extension/Validator/ViolationMapper/ViolationPath.php index 1b67982788..73ce1d2e5a 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 0403ba1049..53ac447d3d 100644 --- a/Form.php +++ b/Form.php @@ -1031,7 +1031,7 @@ private function modelToNorm($value) $value = $transformer->transform($value); } } catch (TransformationFailedException $exception) { - throw new TransformationFailedException('Unable to transform data for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception); + throw new TransformationFailedException(sprintf('Unable to transform data for property path "%s": %s', $this->getPropertyPath(), $exception->getMessage()), $exception->getCode(), $exception); } return $value; @@ -1055,7 +1055,7 @@ private function normToModel($value) $value = $transformers[$i]->reverseTransform($value); } } catch (TransformationFailedException $exception) { - throw new TransformationFailedException('Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception); + throw new TransformationFailedException(sprintf('Unable to reverse value for property path "%s": %s', $this->getPropertyPath(), $exception->getMessage()), $exception->getCode(), $exception); } return $value; @@ -1086,7 +1086,7 @@ private function normToView($value) $value = $transformer->transform($value); } } catch (TransformationFailedException $exception) { - throw new TransformationFailedException('Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception); + throw new TransformationFailedException(sprintf('Unable to transform value for property path "%s": %s', $this->getPropertyPath(), $exception->getMessage()), $exception->getCode(), $exception); } return $value; @@ -1112,7 +1112,7 @@ private function viewToNorm($value) $value = $transformers[$i]->reverseTransform($value); } } catch (TransformationFailedException $exception) { - throw new TransformationFailedException('Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception); + throw new TransformationFailedException(sprintf('Unable to reverse value for property path "%s": %s', $this->getPropertyPath(), $exception->getMessage()), $exception->getCode(), $exception); } return $value; diff --git a/Test/Traits/ValidatorExtensionTrait.php b/Test/Traits/ValidatorExtensionTrait.php index 670382619d..e7f7d0e0c4 100644 --- a/Test/Traits/ValidatorExtensionTrait.php +++ b/Test/Traits/ValidatorExtensionTrait.php @@ -34,7 +34,7 @@ protected function getValidatorExtension() } 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();