Skip to content

Commit 2b1897d

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: Fix quotes in exception messages Fix quotes in exception messages Fix quotes in exception messages
2 parents eb9e406 + f1b7a1d commit 2b1897d

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

Encoder/XmlEncoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ private function buildXml(\DOMNode $parentNode, $data, string $xmlRootNodeName =
409409

410410
if (\is_object($data)) {
411411
if (null === $this->serializer) {
412-
throw new BadMethodCallException(sprintf('The serializer needs to be set to allow %s() to be used with object data.', __METHOD__));
412+
throw new BadMethodCallException(sprintf('The serializer needs to be set to allow "%s()" to be used with object data.', __METHOD__));
413413
}
414414

415415
$data = $this->serializer->normalize($data, $this->format, $this->context);
@@ -475,7 +475,7 @@ private function selectNodeType(\DOMNode $node, $val): bool
475475
$this->buildXml($node, $val);
476476
} elseif (\is_object($val)) {
477477
if (null === $this->serializer) {
478-
throw new BadMethodCallException(sprintf('The serializer needs to be set to allow %s() to be used with object data.', __METHOD__));
478+
throw new BadMethodCallException(sprintf('The serializer needs to be set to allow "%s()" to be used with object data.', __METHOD__));
479479
}
480480

481481
return $this->selectNodeType($node, $this->serializer->normalize($val, $this->format, $this->context));

Mapping/Loader/FileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ abstract class FileLoader implements LoaderInterface
3030
public function __construct(string $file)
3131
{
3232
if (!is_file($file)) {
33-
throw new MappingException(sprintf('The mapping file %s does not exist.', $file));
33+
throw new MappingException(sprintf('The mapping file "%s" does not exist.', $file));
3434
}
3535

3636
if (!is_readable($file)) {
37-
throw new MappingException(sprintf('The mapping file %s is not readable.', $file));
37+
throw new MappingException(sprintf('The mapping file "%s" is not readable.', $file));
3838
}
3939

4040
$this->file = $file;

Mapping/Loader/LoaderChain.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(array $loaders)
4040
{
4141
foreach ($loaders as $loader) {
4242
if (!$loader instanceof LoaderInterface) {
43-
throw new MappingException(sprintf('Class %s is expected to implement LoaderInterface.', \get_class($loader)));
43+
throw new MappingException(sprintf('Class "%s" is expected to implement LoaderInterface.', \get_class($loader)));
4444
}
4545
}
4646

Normalizer/AbstractNormalizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ protected function instantiateObject(array &$data, string $class, array &$contex
354354
if ($constructorParameter->isVariadic()) {
355355
if ($allowed && !$ignored && (isset($data[$key]) || \array_key_exists($key, $data))) {
356356
if (!\is_array($data[$paramName])) {
357-
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));
357+
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));
358358
}
359359

360360
$variadicParameters = [];
@@ -384,7 +384,7 @@ protected function instantiateObject(array &$data, string $class, array &$contex
384384
} elseif ($constructorParameter->isDefaultValueAvailable()) {
385385
$params[] = $constructorParameter->getDefaultValue();
386386
} else {
387-
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));
387+
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));
388388
}
389389
}
390390

@@ -406,7 +406,7 @@ protected function denormalizeParameter(\ReflectionClass $class, \ReflectionPara
406406
try {
407407
if (null !== $parameter->getClass()) {
408408
if (!$this->serializer instanceof DenormalizerInterface) {
409-
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));
409+
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));
410410
}
411411
$parameterClass = $parameter->getClass()->getName();
412412
$parameterData = $this->serializer->denormalize($parameterData, $parameterClass, $format, $this->createChildContext($context, $parameterName, $format));

Normalizer/ArrayDenormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function denormalize($data, string $type, string $format = null, array $c
6969
public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
7070
{
7171
if (null === $this->serializer) {
72-
throw new BadMethodCallException(sprintf('The serializer needs to be set to allow %s() to be used.', __METHOD__));
72+
throw new BadMethodCallException(sprintf('The serializer needs to be set to allow "%s()" to be used.', __METHOD__));
7373
}
7474

7575
return '[]' === substr($type, -2)

Normalizer/DateIntervalNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function hasCacheableSupportsMethod(): bool
7272
public function denormalize($data, string $type, string $format = null, array $context = [])
7373
{
7474
if (!\is_string($data)) {
75-
throw new InvalidArgumentException(sprintf('Data expected to be a string, %s given.', \gettype($data)));
75+
throw new InvalidArgumentException(sprintf('Data expected to be a string, "%s" given.', \gettype($data)));
7676
}
7777

7878
if (!$this->isISO8601($data)) {

Serializer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function __construct(array $normalizers = [], array $encoders = [])
112112
final public function serialize($data, string $format, array $context = []): string
113113
{
114114
if (!$this->supportsEncoding($format, $context)) {
115-
throw new NotEncodableValueException(sprintf('Serialization for the format %s is not supported.', $format));
115+
throw new NotEncodableValueException(sprintf('Serialization for the format "%s" is not supported.', $format));
116116
}
117117

118118
if ($this->encoder->needsNormalization($format, $context)) {
@@ -128,7 +128,7 @@ final public function serialize($data, string $format, array $context = []): str
128128
final public function deserialize($data, string $type, string $format, array $context = [])
129129
{
130130
if (!$this->supportsDecoding($format, $context)) {
131-
throw new NotEncodableValueException(sprintf('Deserialization for the format %s is not supported.', $format));
131+
throw new NotEncodableValueException(sprintf('Deserialization for the format "%s" is not supported.', $format));
132132
}
133133

134134
$data = $this->decode($data, $format, $context);
@@ -164,7 +164,7 @@ public function normalize($data, string $format = null, array $context = [])
164164
throw new LogicException('You must register at least one normalizer to be able to normalize objects.');
165165
}
166166

167-
throw new NotNormalizableValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', \get_class($data)));
167+
throw new NotNormalizableValueException(sprintf('Could not normalize object of type "%s", no supporting normalizer found.', \get_class($data)));
168168
}
169169

170170
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))));
@@ -185,7 +185,7 @@ public function denormalize($data, string $type, string $format = null, array $c
185185
return $normalizer->denormalize($data, $type, $format, $context);
186186
}
187187

188-
throw new NotNormalizableValueException(sprintf('Could not denormalize object of type %s, no supporting normalizer found.', $type));
188+
throw new NotNormalizableValueException(sprintf('Could not denormalize object of type "%s", no supporting normalizer found.', $type));
189189
}
190190

191191
/**

Tests/Normalizer/Features/ConstructorArgumentsTestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testConstructorWithMissingData()
5555
$normalizer = $this->getDenormalizerForConstructArguments();
5656

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

0 commit comments

Comments
 (0)