Skip to content

Commit

Permalink
Fix quotes in exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Mar 16, 2020
1 parent a1162d3 commit 2b5a266
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Encoder/XmlEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions Mapping/Loader/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Mapping/Loader/LoaderChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}

Expand Down
6 changes: 3 additions & 3 deletions Normalizer/AbstractNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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));
}
}

Expand All @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion Normalizer/ArrayDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) : [];
Expand Down
2 changes: 1 addition & 1 deletion Normalizer/DateIntervalNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
8 changes: 4 additions & 4 deletions Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down Expand Up @@ -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))));
Expand All @@ -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));
}

/**
Expand Down

0 comments on commit 2b5a266

Please sign in to comment.