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:
  Add missing dots at the end of exception messages
  [DI][Form] Fixed test suite (TimeType changes & unresolved merge conflict)
  Fix bad merge
  Add missing dots at the end of exception messages
  • Loading branch information
fabpot committed Mar 15, 2020
2 parents 4411e73 + 644d110 commit eb9e406
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Encoder/XmlEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ private function buildXml(\DOMNode $parentNode, $data, string $xmlRootNodeName =
return $this->appendNode($parentNode, $data, 'data');
}

throw new NotEncodableValueException(sprintf('An unexpected value could not be serialized: %s', !\is_resource($data) ? var_export($data, true) : sprintf('%s resource', get_resource_type($data))));
throw new NotEncodableValueException(sprintf('An unexpected value could not be serialized: %s.', !\is_resource($data) ? var_export($data, true) : sprintf('%s resource', get_resource_type($data))));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Mapping/Factory/ClassResolverTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private function getClass($value): string
}

if (!\is_object($value)) {
throw new InvalidArgumentException(sprintf('Cannot create metadata for non-objects. Got: "%s"', \gettype($value)));
throw new InvalidArgumentException(sprintf('Cannot create metadata for non-objects. Got: "%s".', \gettype($value)));
}

return \get_class($value);
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
4 changes: 2 additions & 2 deletions Normalizer/AbstractNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ protected function handleCircularReference(object $object, string $format = null
return $circularReferenceHandler($object, $format, $context);
}

throw new CircularReferenceException(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d)', \get_class($object), $context[self::CIRCULAR_REFERENCE_LIMIT] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_LIMIT]));
throw new CircularReferenceException(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d).', \get_class($object), $context[self::CIRCULAR_REFERENCE_LIMIT] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_LIMIT]));
}

/**
Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions Normalizer/AbstractObjectNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function normalize($object, string $format = null, array $context = [])

foreach ($stack as $attribute => $attributeValue) {
if (!$this->serializer instanceof NormalizerInterface) {
throw new LogicException(sprintf('Cannot normalize attribute "%s" because the injected serializer is not a normalizer', $attribute));
throw new LogicException(sprintf('Cannot normalize attribute "%s" because the injected serializer is not a normalizer.', $attribute));
}

$data = $this->updateData($data, $attribute, $this->serializer->normalize($attributeValue, $format, $this->createChildContext($context, $attribute, $format)), $class, $format, $context);
Expand All @@ -215,12 +215,12 @@ protected function instantiateObject(array &$data, string $class, array &$contex
{
if ($this->classDiscriminatorResolver && $mapping = $this->classDiscriminatorResolver->getMappingForClass($class)) {
if (!isset($data[$mapping->getTypeProperty()])) {
throw new RuntimeException(sprintf('Type property "%s" not found for the abstract object "%s"', $mapping->getTypeProperty(), $class));
throw new RuntimeException(sprintf('Type property "%s" not found for the abstract object "%s".', $mapping->getTypeProperty(), $class));
}

$type = $data[$mapping->getTypeProperty()];
if (null === ($mappedClass = $mapping->getClassForType($type))) {
throw new RuntimeException(sprintf('The type "%s" has no mapped class for the abstract object "%s"', $type, $class));
throw new RuntimeException(sprintf('The type "%s" has no mapped class for the abstract object "%s".', $type, $class));
}

$class = $mappedClass;
Expand Down Expand Up @@ -414,7 +414,7 @@ private function validateAndDenormalize(string $currentClass, string $attribute,

if (Type::BUILTIN_TYPE_OBJECT === $builtinType) {
if (!$this->serializer instanceof DenormalizerInterface) {
throw new LogicException(sprintf('Cannot denormalize attribute "%s" for class "%s" because injected serializer is not a denormalizer', $attribute, $class));
throw new LogicException(sprintf('Cannot denormalize attribute "%s" for class "%s" because injected serializer is not a denormalizer.', $attribute, $class));
}

$childContext = $this->createChildContext($context, $attribute, $format);
Expand Down
2 changes: 1 addition & 1 deletion Normalizer/DateTimeNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function denormalize($data, string $type, string $format = null, array $c

$dateTimeErrors = \DateTime::class === $type ? \DateTime::getLastErrors() : \DateTimeImmutable::getLastErrors();

throw new NotNormalizableValueException(sprintf('Parsing datetime string "%s" using format "%s" resulted in %d errors:'."\n".'%s', $data, $dateTimeFormat, $dateTimeErrors['error_count'], implode("\n", $this->formatDateTimeErrors($dateTimeErrors['errors']))));
throw new NotNormalizableValueException(sprintf('Parsing datetime string "%s" using format "%s" resulted in %d errors:.'."\n".'%s', $data, $dateTimeFormat, $dateTimeErrors['error_count'], implode("\n", $this->formatDateTimeErrors($dateTimeErrors['errors']))));
}

try {
Expand Down
2 changes: 1 addition & 1 deletion Normalizer/JsonSerializableNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function normalize($object, string $format = null, array $context = [])
}

if (!$this->serializer instanceof NormalizerInterface) {
throw new LogicException('Cannot normalize object because injected serializer is not a normalizer');
throw new LogicException('Cannot normalize object because injected serializer is not a normalizer.');
}

return $this->serializer->normalize($object->jsonSerialize(), $format, $context);
Expand Down
6 changes: 3 additions & 3 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 @@ -167,7 +167,7 @@ public function normalize($data, string $format = null, array $context = [])
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))));
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 Down

0 comments on commit eb9e406

Please sign in to comment.