Skip to content

Commit 5f3721d

Browse files
committed
cs: fixes
1 parent c58850b commit 5f3721d

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/Serializer/AbstractItemNormalizer.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,12 @@ protected function getClassDiscriminatorResolvedClass(array $data, string $class
356356
}
357357

358358
if (!isset($data[$mapping->getTypeProperty()])) {
359-
throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('Type property "%s" not found for the abstract object "%s".', $mapping->getTypeProperty(), $class), null, ['string'], isset($context['deserialization_path']) ? $context['deserialization_path'] . '.' . $mapping->getTypeProperty() : $mapping->getTypeProperty());
359+
throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('Type property "%s" not found for the abstract object "%s".', $mapping->getTypeProperty(), $class), null, ['string'], isset($context['deserialization_path']) ? $context['deserialization_path'].'.'.$mapping->getTypeProperty() : $mapping->getTypeProperty());
360360
}
361361

362362
$type = $data[$mapping->getTypeProperty()];
363363
if (null === ($mappedClass = $mapping->getClassForType($type))) {
364-
throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The type "%s" is not a valid value.', $type), $type, ['string'], isset($context['deserialization_path']) ? $context['deserialization_path'] . '.' . $mapping->getTypeProperty() : $mapping->getTypeProperty(), true);
364+
throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The type "%s" is not a valid value.', $type), $type, ['string'], isset($context['deserialization_path']) ? $context['deserialization_path'].'.'.$mapping->getTypeProperty() : $mapping->getTypeProperty(), true);
365365
}
366366

367367
return $mappedClass;
@@ -491,7 +491,7 @@ protected function validateType(string $attribute, Type $type, mixed $value, str
491491
if (Type::BUILTIN_TYPE_FLOAT === $builtinType && null !== $format && str_contains($format, 'json')) {
492492
$isValid = \is_float($value) || \is_int($value);
493493
} else {
494-
$isValid = \call_user_func('is_' . $builtinType, $value);
494+
$isValid = \call_user_func('is_'.$builtinType, $value);
495495
}
496496

497497
if (!$isValid) {
@@ -515,7 +515,7 @@ protected function denormalizeCollection(string $attribute, ApiProperty $propert
515515
$childContext = $this->createChildContext($this->createOperationContext($context, $className), $attribute, $format);
516516
$values = [];
517517
foreach ($value as $index => $obj) {
518-
if (null !== $collectionKeyBuiltinType && !\call_user_func('is_' . $collectionKeyBuiltinType, $index)) {
518+
if (null !== $collectionKeyBuiltinType && !\call_user_func('is_'.$collectionKeyBuiltinType, $index)) {
519519
throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The type of the key "%s" must be "%s", "%s" given.', $index, $collectionKeyBuiltinType, \gettype($index)), $index, [$collectionKeyBuiltinType], ($context['deserialization_path'] ?? false) ? sprintf('key(%s)', $context['deserialization_path']) : null, true);
520520
}
521521

@@ -577,7 +577,7 @@ protected function getFactoryOptions(array $context): array
577577
$options['serializer_groups'] = (array) $context[self::GROUPS];
578578
}
579579

580-
$operationCacheKey = ($context['resource_class'] ?? '') . ($context['operation_name'] ?? '') . ($context['api_normalize'] ?? '');
580+
$operationCacheKey = ($context['resource_class'] ?? '').($context['operation_name'] ?? '').($context['api_normalize'] ?? '');
581581
if ($operationCacheKey && isset($this->localFactoryOptionsCache[$operationCacheKey])) {
582582
return $options + $this->localFactoryOptionsCache[$operationCacheKey];
583583
}
@@ -633,6 +633,7 @@ protected function getAttributeValue(object $object, string $attribute, string $
633633

634634
$resourceClass = $this->resourceClassResolver->getResourceClass($attributeValue, $className);
635635
$childContext = $this->createChildContext($this->createOperationContext($context, $resourceClass), $attribute, $format);
636+
636637
return $this->normalizeCollectionOfRelations($propertyMetadata, $attributeValue, $resourceClass, $format, $childContext);
637638
}
638639

@@ -646,6 +647,7 @@ protected function getAttributeValue(object $object, string $attribute, string $
646647

647648
$resourceClass = $this->resourceClassResolver->getResourceClass($attributeValue, $className);
648649
$childContext = $this->createChildContext($this->createOperationContext($context, $resourceClass), $attribute, $format);
650+
649651
return $this->normalizeRelation($propertyMetadata, $attributeValue, $resourceClass, $format, $childContext);
650652
}
651653

@@ -660,13 +662,15 @@ protected function getAttributeValue(object $object, string $attribute, string $
660662

661663
// Anonymous resources
662664
if ($type->getClassName()) {
663-
$childContext = $this->createChildContext($this->createOperationContext($context, null), $attribute, $format);
665+
$childContext = $this->createChildContext($this->createOperationContext($context, null), $attribute, $format);
664666
$childContext['output']['gen_id'] = $propertyMetadata->getGenId() ?? true;
667+
665668
return $this->serializer->normalize($attributeValue, $format, $childContext);
666669
}
667670

668671
if ('array' === $type->getBuiltinType()) {
669-
$childContext = $this->createChildContext($this->createOperationContext($context, null), $attribute, $format);
672+
$childContext = $this->createChildContext($this->createOperationContext($context, null), $attribute, $format);
673+
670674
return $this->serializer->normalize($attributeValue, $format, $childContext);
671675
}
672676
}
@@ -795,7 +799,8 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value
795799
&& $this->resourceClassResolver->isResourceClass($className)
796800
) {
797801
$resourceClass = $this->resourceClassResolver->getResourceClass(null, $className);
798-
$childContext = $this->createChildContext($this->createOperationContext($context, $resourceClass), $attribute, $format);
802+
$childContext = $this->createChildContext($this->createOperationContext($context, $resourceClass), $attribute, $format);
803+
799804
return $this->denormalizeRelation($attribute, $propertyMetadata, $resourceClass, $value, $format, $childContext);
800805
}
801806

@@ -811,7 +816,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value
811816

812817
unset($context['resource_class']);
813818

814-
return $this->serializer->denormalize($value, $className . '[]', $format, $context);
819+
return $this->serializer->denormalize($value, $className.'[]', $format, $context);
815820
}
816821

817822
if (null !== $className = $type->getClassName()) {

0 commit comments

Comments
 (0)