Skip to content

Commit

Permalink
Merge branch '4.4' into 5.0
Browse files Browse the repository at this point in the history
* 4.4:
  Fix quotes in exception messages
  Fix quotes in exception messages
  Fix quotes in exception messages
  • Loading branch information
fabpot committed Mar 16, 2020
2 parents eb9e406 + f1b7a1d commit 2b1897d
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Encoder/XmlEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private function buildXml(\DOMNode $parentNode, $data, string $xmlRootNodeName =

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 @@ -475,7 +475,7 @@ private function selectNodeType(\DOMNode $node, $val): bool
$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(string $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 @@ -354,7 +354,7 @@ protected function instantiateObject(array &$data, string $class, array &$contex
if ($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 Down Expand Up @@ -384,7 +384,7 @@ protected function instantiateObject(array &$data, string $class, array &$contex
} elseif ($constructorParameter->isDefaultValueAvailable()) {
$params[] = $constructorParameter->getDefaultValue();
} else {
throw new MissingConstructorArgumentsException(sprintf('Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present.', $class, $constructorParameter->name));
throw new MissingConstructorArgumentsException(sprintf('Cannot create an instance of "%s" from serialized data because its constructor requires parameter "%s" to be present.', $class, $constructorParameter->name));
}
}

Expand All @@ -406,7 +406,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(), self::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(), self::class));
}
$parameterClass = $parameter->getClass()->getName();
$parameterData = $this->serializer->denormalize($parameterData, $parameterClass, $format, $this->createChildContext($context, $parameterName, $format));
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, string $type, string $format = null, array $c
public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
{
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__));
}

return '[]' === substr($type, -2)
Expand Down
2 changes: 1 addition & 1 deletion Normalizer/DateIntervalNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function hasCacheableSupportsMethod(): bool
public function denormalize($data, string $type, string $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 @@ -112,7 +112,7 @@ public function __construct(array $normalizers = [], array $encoders = [])
final public function serialize($data, string $format, array $context = []): string
{
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 @@ -128,7 +128,7 @@ final public function serialize($data, string $format, array $context = []): str
final public function deserialize($data, string $type, string $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 @@ -164,7 +164,7 @@ public function normalize($data, string $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 @@ -185,7 +185,7 @@ public function denormalize($data, string $type, string $format = null, array $c
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testConstructorWithMissingData()
$normalizer = $this->getDenormalizerForConstructArguments();

$this->expectException(MissingConstructorArgumentsException::class);
$this->expectExceptionMessage('Cannot create an instance of '.ConstructorArgumentsObject::class.' from serialized data because its constructor requires parameter "bar" to be present.');
$this->expectExceptionMessage('Cannot create an instance of "'.ConstructorArgumentsObject::class.'" from serialized data because its constructor requires parameter "bar" to be present.');
$normalizer->denormalize($data, ConstructorArgumentsObject::class);
}
}

0 comments on commit 2b1897d

Please sign in to comment.