Issue #3232080 by paulocs, daffie, longwave: [Symfony 6] Add "mixed" type hint to all Normalizer classes that implement the method ::denormalize()
parent
42a48a2e2b
commit
45630c7c34
|
@ -123,7 +123,7 @@ class ContentEntityNormalizer extends NormalizerBase {
|
|||
*
|
||||
* @throws \Symfony\Component\Serializer\Exception\UnexpectedValueException
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
// Get type, necessary for determining which bundle to create.
|
||||
if (!isset($data['_links']['type'])) {
|
||||
throw new UnexpectedValueException('The type link relation must be specified.');
|
||||
|
|
|
@ -38,7 +38,7 @@ class FieldItemNormalizer extends NormalizerBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
if (!isset($context['target_instance'])) {
|
||||
throw new InvalidArgumentException('$context[\'target_instance\'] must be set to denormalize with the FieldItemNormalizer');
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ abstract class EntityDenormalizerBase extends NormalizerBase implements Denormal
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
if (empty($context['resource_type']) || !$context['resource_type'] instanceof ResourceType) {
|
||||
throw new PreconditionFailedHttpException('Missing context during denormalization.');
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ class FieldItemNormalizer extends NormalizerBase implements DenormalizerInterfac
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
$item_definition = $context['field_definition']->getItemDefinition();
|
||||
assert($item_definition instanceof FieldItemDataDefinitionInterface);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ class FieldNormalizer extends NormalizerBase implements DenormalizerInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
$field_definition = $context['field_definition'];
|
||||
assert($field_definition instanceof FieldDefinitionInterface);
|
||||
$resource_type = $context['resource_type'];
|
||||
|
|
|
@ -70,7 +70,7 @@ class JsonApiDocumentTopLevelNormalizer extends NormalizerBase implements Denorm
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
$resource_type = $context['resource_type'];
|
||||
|
||||
// Validate a few common errors in document formatting.
|
||||
|
|
|
@ -63,7 +63,7 @@ class ResourceIdentifierNormalizer extends NormalizerBase implements Denormalize
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
// If we get here, it's via a relationship POST/PATCH.
|
||||
/** @var \Drupal\jsonapi\ResourceType\ResourceType $resource_type */
|
||||
$resource_type = $context['resource_type'];
|
||||
|
|
|
@ -70,7 +70,7 @@ final class Serializer extends SymfonySerializer {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $type, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $type, $format = NULL, array $context = []): mixed {
|
||||
if ($this->selfSupportsDenormalization($data, $type, $format, $context)) {
|
||||
return parent::denormalize($data, $type, $format, $context);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class StringNormalizer extends NormalizerBase implements DenormalizerInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
return str_replace('NOT', 'super', $data);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class ConfigEntityNormalizer extends EntityNormalizer {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
return parent::denormalize(static::getDataWithoutInternals($data), $class, $format, $context);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class DateTimeIso8601Normalizer extends DateTimeNormalizer {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
// @todo Move the date-only handling out of here in https://www.drupal.org/project/drupal/issues/2958416.
|
||||
if (isset($context['target_instance'])) {
|
||||
$field_definition = $context['target_instance']->getFieldDefinition();
|
||||
|
|
|
@ -85,7 +85,7 @@ class DateTimeNormalizer extends NormalizerBase implements DenormalizerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
// This only knows how to denormalize datetime strings and timestamps. If
|
||||
// something else is received, let validation constraints handle this.
|
||||
if (!is_string($data) && !is_numeric($data)) {
|
||||
|
|
|
@ -40,7 +40,7 @@ class EntityNormalizer extends ComplexDataNormalizer implements DenormalizerInte
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
$entity_type_id = $this->determineEntityTypeId($class, $context);
|
||||
$entity_type_definition = $this->getEntityTypeDefinition($entity_type_id);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class FieldItemNormalizer extends ComplexDataNormalizer implements DenormalizerI
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
if (!isset($context['target_instance'])) {
|
||||
throw new InvalidArgumentException('$context[\'target_instance\'] must be set to denormalize with the FieldItemNormalizer');
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class FieldNormalizer extends ListNormalizer implements DenormalizerInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
if (!isset($context['target_instance'])) {
|
||||
throw new InvalidArgumentException('$context[\'target_instance\'] must be set to denormalize with the FieldNormalizer');
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class TimestampNormalizer extends DateTimeNormalizer {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
$denormalized = parent::denormalize($data, $class, $format, $context);
|
||||
return $denormalized->getTimestamp();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class BooleanNormalizer extends NormalizerBase implements DenormalizerInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []) {
|
||||
public function denormalize($data, $class, $format = NULL, array $context = []): mixed {
|
||||
if (!in_array($data, ['👍', '👎'], TRUE)) {
|
||||
throw new \UnexpectedValueException('Only 👍 and 👎 are acceptable values.');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue