denormalizer->supportsDenormalization($data, $localType, $format)) { try { return $this->denormalizer->denormalize($data, $localType, $format, $context); } catch (RuntimeException|NotNormalizableValueException $e) { $lastException = $e; } } } throw new RuntimeException(sprintf('Could not find any denormalizer for those ' . 'ALLOWED_TYPES: %s', implode(', ', $context[self::ALLOWED_TYPES]))); } public function supportsDenormalization($data, $type, $format = null, array $context = []) { if (self::TYPE !== $type) { return false; } if (0 === count($context[self::ALLOWED_TYPES] ?? [])) { throw new LogicException('The context should contains a list of allowed types'); } foreach ($context[self::ALLOWED_TYPES] as $localType) { if ($this->denormalizer->supportsDenormalization($data, $localType, $format)) { return true; } } return false; } }