diff --git a/Encoder/XmlEncoder.php b/Encoder/XmlEncoder.php index bd6b8f156..d7551183d 100644 --- a/Encoder/XmlEncoder.php +++ b/Encoder/XmlEncoder.php @@ -412,7 +412,7 @@ private function buildXml(\DOMNode $parentNode, $data, $xmlRootNodeName = null) if (\is_object($data)) { if (null === $this->serializer) { - throw new BadMethodCallException(sprintf('The serializer needs to be set to allow %s() to be used with object data.', __METHOD__)); + throw new BadMethodCallException(sprintf('The serializer needs to be set to allow "%s()" to be used with object data.', __METHOD__)); } $data = $this->serializer->normalize($data, $this->format, $this->context); @@ -490,7 +490,7 @@ private function selectNodeType(\DOMNode $node, $val) $this->buildXml($node, $val); } elseif (\is_object($val)) { if (null === $this->serializer) { - throw new BadMethodCallException(sprintf('The serializer needs to be set to allow %s() to be used with object data.', __METHOD__)); + throw new BadMethodCallException(sprintf('The serializer needs to be set to allow "%s()" to be used with object data.', __METHOD__)); } return $this->selectNodeType($node, $this->serializer->normalize($val, $this->format, $this->context)); diff --git a/Mapping/Loader/FileLoader.php b/Mapping/Loader/FileLoader.php index be3b8984a..20f9e4886 100644 --- a/Mapping/Loader/FileLoader.php +++ b/Mapping/Loader/FileLoader.php @@ -30,11 +30,11 @@ abstract class FileLoader implements LoaderInterface public function __construct($file) { if (!is_file($file)) { - throw new MappingException(sprintf('The mapping file %s does not exist.', $file)); + throw new MappingException(sprintf('The mapping file "%s" does not exist.', $file)); } if (!is_readable($file)) { - throw new MappingException(sprintf('The mapping file %s is not readable.', $file)); + throw new MappingException(sprintf('The mapping file "%s" is not readable.', $file)); } $this->file = $file; diff --git a/Mapping/Loader/LoaderChain.php b/Mapping/Loader/LoaderChain.php index 7f90c8404..f422f11c7 100644 --- a/Mapping/Loader/LoaderChain.php +++ b/Mapping/Loader/LoaderChain.php @@ -40,7 +40,7 @@ public function __construct(array $loaders) { foreach ($loaders as $loader) { if (!$loader instanceof LoaderInterface) { - throw new MappingException(sprintf('Class %s is expected to implement LoaderInterface.', \get_class($loader))); + throw new MappingException(sprintf('Class "%s" is expected to implement LoaderInterface.', \get_class($loader))); } } diff --git a/Normalizer/AbstractNormalizer.php b/Normalizer/AbstractNormalizer.php index 55bf43b0d..a360dc2fc 100644 --- a/Normalizer/AbstractNormalizer.php +++ b/Normalizer/AbstractNormalizer.php @@ -340,7 +340,7 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref if (method_exists($constructorParameter, 'isVariadic') && $constructorParameter->isVariadic()) { if ($allowed && !$ignored && (isset($data[$key]) || \array_key_exists($key, $data))) { if (!\is_array($data[$paramName])) { - throw new RuntimeException(sprintf('Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.', $class, $constructorParameter->name)); + throw new RuntimeException(sprintf('Cannot create an instance of "%s" from serialized data because the variadic parameter "%s" can only accept an array.', $class, $constructorParameter->name)); } $variadicParameters = []; @@ -366,7 +366,7 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref } elseif ($constructorParameter->isDefaultValueAvailable()) { $params[] = $constructorParameter->getDefaultValue(); } else { - throw new RuntimeException(sprintf('Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present.', $class, $constructorParameter->name)); + throw new RuntimeException(sprintf('Cannot create an instance of "%s" from serialized data because its constructor requires parameter "%s" to be present.', $class, $constructorParameter->name)); } } @@ -388,7 +388,7 @@ protected function denormalizeParameter(\ReflectionClass $class, \ReflectionPara try { if (null !== $parameter->getClass()) { if (!$this->serializer instanceof DenormalizerInterface) { - throw new LogicException(sprintf('Cannot create an instance of %s from serialized data because the serializer inject in "%s" is not a denormalizer.', $parameter->getClass(), static::class)); + throw new LogicException(sprintf('Cannot create an instance of "%s" from serialized data because the serializer inject in "%s" is not a denormalizer.', $parameter->getClass(), static::class)); } $parameterClass = $parameter->getClass()->getName(); diff --git a/Normalizer/ArrayDenormalizer.php b/Normalizer/ArrayDenormalizer.php index 702b8bfec..af331d30f 100644 --- a/Normalizer/ArrayDenormalizer.php +++ b/Normalizer/ArrayDenormalizer.php @@ -69,7 +69,7 @@ public function denormalize($data, $type, $format = null, array $context = []) public function supportsDenormalization($data, $type, $format = null/*, array $context = []*/) { if (null === $this->serializer) { - throw new BadMethodCallException(sprintf('The serializer needs to be set to allow %s() to be used.', __METHOD__)); + throw new BadMethodCallException(sprintf('The serializer needs to be set to allow "%s()" to be used.', __METHOD__)); } $context = \func_num_args() > 3 ? func_get_arg(3) : []; diff --git a/Normalizer/DateIntervalNormalizer.php b/Normalizer/DateIntervalNormalizer.php index 83d9312b0..8b5cde30f 100644 --- a/Normalizer/DateIntervalNormalizer.php +++ b/Normalizer/DateIntervalNormalizer.php @@ -67,7 +67,7 @@ public function supportsNormalization($data, $format = null) public function denormalize($data, $type, $format = null, array $context = []) { if (!\is_string($data)) { - throw new InvalidArgumentException(sprintf('Data expected to be a string, %s given.', \gettype($data))); + throw new InvalidArgumentException(sprintf('Data expected to be a string, "%s" given.', \gettype($data))); } if (!$this->isISO8601($data)) { diff --git a/Serializer.php b/Serializer.php index 95a2d9613..1c125bc93 100644 --- a/Serializer.php +++ b/Serializer.php @@ -109,7 +109,7 @@ public function __construct(array $normalizers = [], array $encoders = []) final public function serialize($data, $format, array $context = []) { if (!$this->supportsEncoding($format, $context)) { - throw new NotEncodableValueException(sprintf('Serialization for the format %s is not supported.', $format)); + throw new NotEncodableValueException(sprintf('Serialization for the format "%s" is not supported.', $format)); } if ($this->encoder->needsNormalization($format, $context)) { @@ -125,7 +125,7 @@ final public function serialize($data, $format, array $context = []) final public function deserialize($data, $type, $format, array $context = []) { if (!$this->supportsDecoding($format, $context)) { - throw new NotEncodableValueException(sprintf('Deserialization for the format %s is not supported.', $format)); + throw new NotEncodableValueException(sprintf('Deserialization for the format "%s" is not supported.', $format)); } $data = $this->decode($data, $format, $context); @@ -161,7 +161,7 @@ public function normalize($data, $format = null, array $context = []) throw new LogicException('You must register at least one normalizer to be able to normalize objects.'); } - throw new NotNormalizableValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', \get_class($data))); + throw new NotNormalizableValueException(sprintf('Could not normalize object of type "%s", no supporting normalizer found.', \get_class($data))); } throw new NotNormalizableValueException(sprintf('An unexpected value could not be normalized: %s.', !\is_resource($data) ? var_export($data, true) : sprintf('%s resource', get_resource_type($data)))); @@ -182,7 +182,7 @@ public function denormalize($data, $type, $format = null, array $context = []) return $normalizer->denormalize($data, $type, $format, $context); } - throw new NotNormalizableValueException(sprintf('Could not denormalize object of type %s, no supporting normalizer found.', $type)); + throw new NotNormalizableValueException(sprintf('Could not denormalize object of type "%s", no supporting normalizer found.', $type)); } /**