From ab72f80b25cf8b6dd72f26541bb809460c15222d Mon Sep 17 00:00:00 2001 From: Mathias Arlaud Date: Fri, 7 Jan 2022 12:40:44 +0100 Subject: [PATCH] Merge context aware interfaces into regular ones --- UPGRADE-6.1.md | 10 ++++++++++ src/Symfony/Component/Serializer/CHANGELOG.md | 8 ++++++++ .../Encoder/ContextAwareDecoderInterface.php | 2 ++ .../Encoder/ContextAwareEncoderInterface.php | 2 ++ .../Component/Serializer/Encoder/CsvEncoder.php | 8 ++++++-- .../Serializer/Encoder/DecoderInterface.php | 3 ++- .../Serializer/Encoder/EncoderInterface.php | 5 +++-- .../Component/Serializer/Encoder/JsonDecode.php | 4 +++- .../Component/Serializer/Encoder/JsonEncode.php | 4 +++- .../Component/Serializer/Encoder/JsonEncoder.php | 8 ++++++-- .../Component/Serializer/Encoder/XmlEncoder.php | 8 ++++++-- .../Component/Serializer/Encoder/YamlEncoder.php | 8 ++++++-- .../Normalizer/AbstractObjectNormalizer.php | 8 ++++++-- .../Normalizer/BackedEnumNormalizer.php | 4 ++-- .../ConstraintViolationListNormalizer.php | 4 +++- .../ContextAwareDenormalizerInterface.php | 2 ++ .../ContextAwareNormalizerInterface.php | 2 ++ .../Serializer/Normalizer/CustomNormalizer.php | 16 +++++++++------- .../Serializer/Normalizer/DataUriNormalizer.php | 8 ++++++-- .../Normalizer/DateIntervalNormalizer.php | 8 ++++++-- .../Serializer/Normalizer/DateTimeNormalizer.php | 8 ++++++-- .../Normalizer/DateTimeZoneNormalizer.php | 8 ++++++-- .../Normalizer/DenormalizerInterface.php | 9 +++++---- .../Normalizer/FormErrorNormalizer.php | 2 +- .../Normalizer/GetSetMethodNormalizer.php | 8 ++++++-- .../Normalizer/JsonSerializableNormalizer.php | 8 ++++++-- .../Normalizer/MimeMessageNormalizer.php | 4 ++-- .../Normalizer/NormalizerInterface.php | 7 ++++--- .../Serializer/Normalizer/ProblemNormalizer.php | 4 +++- .../Serializer/Normalizer/PropertyNormalizer.php | 8 ++++++-- .../Serializer/Normalizer/UidNormalizer.php | 4 ++-- .../Tests/Encoder/ChainEncoderTest.php | 2 +- .../Tests/Fixtures/AbstractNormalizerDummy.php | 4 ++-- .../Normalizer/AbstractObjectNormalizerTest.php | 2 +- .../Tests/Normalizer/TestDenormalizer.php | 2 +- .../Tests/Normalizer/TestNormalizer.php | 2 +- 36 files changed, 146 insertions(+), 58 deletions(-) create mode 100644 UPGRADE-6.1.md diff --git a/UPGRADE-6.1.md b/UPGRADE-6.1.md new file mode 100644 index 0000000000000..7c1c91fd4e62e --- /dev/null +++ b/UPGRADE-6.1.md @@ -0,0 +1,10 @@ +UPGRADE FROM 6.0 to 6.1 +======================= + +Serializer +---------- + + * Deprecate `ContextAwareNormalizerInterface`, use `NormalizerInterface` instead + * Deprecate `ContextAwareDenormalizerInterface`, use `DenormalizerInterface` instead + * Deprecate `ContextAwareEncoderInterface`, use `EncoderInterface` instead + * Deprecate `ContextAwareDecoderInterface`, use `DecoderInterface` instead diff --git a/src/Symfony/Component/Serializer/CHANGELOG.md b/src/Symfony/Component/Serializer/CHANGELOG.md index c2bbd4b6cff0e..363c3c88c566f 100644 --- a/src/Symfony/Component/Serializer/CHANGELOG.md +++ b/src/Symfony/Component/Serializer/CHANGELOG.md @@ -1,6 +1,14 @@ CHANGELOG ========= +6.1 +--- + + * Deprecate `ContextAwareNormalizerInterface`, use `NormalizerInterface` instead + * Deprecate `ContextAwareDenormalizerInterface`, use `DenormalizerInterface` instead + * Deprecate `ContextAwareEncoderInterface`, use `EncoderInterface` instead + * Deprecate `ContextAwareDecoderInterface`, use `DecoderInterface` instead + 6.0 --- diff --git a/src/Symfony/Component/Serializer/Encoder/ContextAwareDecoderInterface.php b/src/Symfony/Component/Serializer/Encoder/ContextAwareDecoderInterface.php index 6ac2e38cc4657..910b26bac1fc8 100644 --- a/src/Symfony/Component/Serializer/Encoder/ContextAwareDecoderInterface.php +++ b/src/Symfony/Component/Serializer/Encoder/ContextAwareDecoderInterface.php @@ -15,6 +15,8 @@ * Adds the support of an extra $context parameter for the supportsDecoding method. * * @author Kévin Dunglas + * + * @deprecated since symfony/serializer 6.1, use DecoderInterface instead */ interface ContextAwareDecoderInterface extends DecoderInterface { diff --git a/src/Symfony/Component/Serializer/Encoder/ContextAwareEncoderInterface.php b/src/Symfony/Component/Serializer/Encoder/ContextAwareEncoderInterface.php index 832b600eeca57..f828f87a4f82f 100644 --- a/src/Symfony/Component/Serializer/Encoder/ContextAwareEncoderInterface.php +++ b/src/Symfony/Component/Serializer/Encoder/ContextAwareEncoderInterface.php @@ -15,6 +15,8 @@ * Adds the support of an extra $context parameter for the supportsEncoding method. * * @author Kévin Dunglas + * + * @deprecated since symfony/serializer 6.1, use EncoderInterface instead */ interface ContextAwareEncoderInterface extends EncoderInterface { diff --git a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php index cee61fa03a680..8a8e47fb82c85 100644 --- a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php @@ -123,8 +123,10 @@ public function encode(mixed $data, string $format, array $context = []): string /** * {@inheritdoc} + * + * @param array $context */ - public function supportsEncoding(string $format): bool + public function supportsEncoding(string $format /*, array $context = [] */): bool { return self::FORMAT === $format; } @@ -209,8 +211,10 @@ public function decode(string $data, string $format, array $context = []): mixed /** * {@inheritdoc} + * + * @param array $context */ - public function supportsDecoding(string $format): bool + public function supportsDecoding(string $format /*, array $context = [] */): bool { return self::FORMAT === $format; } diff --git a/src/Symfony/Component/Serializer/Encoder/DecoderInterface.php b/src/Symfony/Component/Serializer/Encoder/DecoderInterface.php index 84a84ad1f3e69..f38069e471733 100644 --- a/src/Symfony/Component/Serializer/Encoder/DecoderInterface.php +++ b/src/Symfony/Component/Serializer/Encoder/DecoderInterface.php @@ -40,8 +40,9 @@ public function decode(string $data, string $format, array $context = []); * Checks whether the deserializer can decode from given format. * * @param string $format Format name + * @param array $context Options that decoders have access to * * @return bool */ - public function supportsDecoding(string $format); + public function supportsDecoding(string $format /*, array $context = [] */); } diff --git a/src/Symfony/Component/Serializer/Encoder/EncoderInterface.php b/src/Symfony/Component/Serializer/Encoder/EncoderInterface.php index e0f303b1e3dcd..22da956d22419 100644 --- a/src/Symfony/Component/Serializer/Encoder/EncoderInterface.php +++ b/src/Symfony/Component/Serializer/Encoder/EncoderInterface.php @@ -32,7 +32,8 @@ public function encode(mixed $data, string $format, array $context = []): string /** * Checks whether the serializer can encode to given format. * - * @param string $format Format name + * @param string $format Format name + * @param array $context Options that normalizers/encoders have access to */ - public function supportsEncoding(string $format): bool; + public function supportsEncoding(string $format /*, array $context = [] */): bool; } diff --git a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php index ad094afaca161..f0f94f6d7e230 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -95,8 +95,10 @@ public function decode(string $data, string $format, array $context = []): mixed /** * {@inheritdoc} + * + * @param array $context */ - public function supportsDecoding(string $format): bool + public function supportsDecoding(string $format /*, array $context = [] */): bool { return JsonEncoder::FORMAT === $format; } diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php index 23d0fdd960e3e..9a0a9393b0386 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php @@ -57,8 +57,10 @@ public function encode(mixed $data, string $format, array $context = []): string /** * {@inheritdoc} + * + * @param array $context */ - public function supportsEncoding(string $format): bool + public function supportsEncoding(string $format /*, array $context = [] */): bool { return JsonEncoder::FORMAT === $format; } diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php b/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php index d17ef049285ef..2ce119bcbdde5 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php @@ -47,16 +47,20 @@ public function decode(string $data, string $format, array $context = []): mixed /** * {@inheritdoc} + * + * @param array $context */ - public function supportsEncoding(string $format): bool + public function supportsEncoding(string $format /*, array $context = [] */): bool { return self::FORMAT === $format; } /** * {@inheritdoc} + * + * @param array $context */ - public function supportsDecoding(string $format): bool + public function supportsDecoding(string $format /*, array $context = [] */): bool { return self::FORMAT === $format; } diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index 44bfe86308820..e91a2cb3034e6 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -174,16 +174,20 @@ public function decode(string $data, string $format, array $context = []): mixed /** * {@inheritdoc} + * + * @param array $context */ - public function supportsEncoding(string $format): bool + public function supportsEncoding(string $format /*, array $context = [] */): bool { return self::FORMAT === $format; } /** * {@inheritdoc} + * + * @param array $context */ - public function supportsDecoding(string $format): bool + public function supportsDecoding(string $format /*, array $context = [] */): bool { return self::FORMAT === $format; } diff --git a/src/Symfony/Component/Serializer/Encoder/YamlEncoder.php b/src/Symfony/Component/Serializer/Encoder/YamlEncoder.php index 64fefee0ee93e..990d0039c091a 100644 --- a/src/Symfony/Component/Serializer/Encoder/YamlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/YamlEncoder.php @@ -67,8 +67,10 @@ public function encode(mixed $data, string $format, array $context = []): string /** * {@inheritdoc} + * + * @param array $context */ - public function supportsEncoding(string $format): bool + public function supportsEncoding(string $format /*, array $context = [] */): bool { return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format; } @@ -85,8 +87,10 @@ public function decode(string $data, string $format, array $context = []): mixed /** * {@inheritdoc} + * + * @param array $context */ - public function supportsDecoding(string $format): bool + public function supportsDecoding(string $format /*, array $context = [] */): bool { return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format; } diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php index 3e1e7edc8e117..a8943113c4291 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php @@ -134,8 +134,10 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory /** * {@inheritdoc} + * + * @param array $context */ - public function supportsNormalization(mixed $data, string $format = null) + public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */) { return \is_object($data) && !$data instanceof \Traversable; } @@ -349,8 +351,10 @@ abstract protected function getAttributeValue(object $object, string $attribute, /** * {@inheritdoc} + * + * @param array $context */ - public function supportsDenormalization(mixed $data, string $type, string $format = null) + public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */) { return class_exists($type) || (interface_exists($type, false) && $this->classDiscriminatorResolver && null !== $this->classDiscriminatorResolver->getMappingForClass($type)); } diff --git a/src/Symfony/Component/Serializer/Normalizer/BackedEnumNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/BackedEnumNormalizer.php index ba17cae4ace25..859a09362d3f0 100644 --- a/src/Symfony/Component/Serializer/Normalizer/BackedEnumNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/BackedEnumNormalizer.php @@ -37,7 +37,7 @@ public function normalize($object, $format = null, array $context = []): int|str /** * {@inheritdoc} */ - public function supportsNormalization($data, $format = null): bool + public function supportsNormalization($data, $format = null, array $context = []): bool { return $data instanceof \BackedEnum; } @@ -67,7 +67,7 @@ public function denormalize($data, $type, $format = null, array $context = []): /** * {@inheritdoc} */ - public function supportsDenormalization($data, $type, $format = null): bool + public function supportsDenormalization($data, $type, $format = null, array $context = []): bool { return is_subclass_of($type, \BackedEnum::class); } diff --git a/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php index fcedfa531f1ee..2ac3c3681c94f 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php @@ -106,8 +106,10 @@ public function normalize(mixed $object, string $format = null, array $context = /** * {@inheritdoc} + * + * @param array $context */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool { return $data instanceof ConstraintViolationListInterface; } diff --git a/src/Symfony/Component/Serializer/Normalizer/ContextAwareDenormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/ContextAwareDenormalizerInterface.php index 991db4470a0d6..38c07a2682c92 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ContextAwareDenormalizerInterface.php +++ b/src/Symfony/Component/Serializer/Normalizer/ContextAwareDenormalizerInterface.php @@ -15,6 +15,8 @@ * Adds the support of an extra $context parameter for the supportsDenormalization method. * * @author Kévin Dunglas + * + * @deprecated since symfony/serializer 6.1, use DenormalizerInterface instead */ interface ContextAwareDenormalizerInterface extends DenormalizerInterface { diff --git a/src/Symfony/Component/Serializer/Normalizer/ContextAwareNormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/ContextAwareNormalizerInterface.php index eb28a7048aaba..6f85225bd3487 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ContextAwareNormalizerInterface.php +++ b/src/Symfony/Component/Serializer/Normalizer/ContextAwareNormalizerInterface.php @@ -15,6 +15,8 @@ * Adds the support of an extra $context parameter for the supportsNormalization method. * * @author Kévin Dunglas + * + * @deprecated since symfony/serializer 6.1, use NormalizerInterface instead */ interface ContextAwareNormalizerInterface extends NormalizerInterface { diff --git a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php index e9e6f3d1a9dad..d12361d50a10c 100644 --- a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php @@ -44,10 +44,11 @@ public function denormalize(mixed $data, string $type, string $format = null, ar /** * Checks if the given class implements the NormalizableInterface. * - * @param mixed $data Data to normalize - * @param string $format The format being (de-)serialized from or into + * @param mixed $data Data to normalize + * @param string $format The format being (de-)serialized from or into + * @param array $context */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool { return $data instanceof NormalizableInterface; } @@ -55,11 +56,12 @@ public function supportsNormalization(mixed $data, string $format = null): bool /** * Checks if the given class implements the DenormalizableInterface. * - * @param mixed $data Data to denormalize from - * @param string $type The class to which the data should be denormalized - * @param string $format The format being deserialized from + * @param mixed $data Data to denormalize from + * @param string $type The class to which the data should be denormalized + * @param string $format The format being deserialized from + * @param array $context */ - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool { return is_subclass_of($type, DenormalizableInterface::class); } diff --git a/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php index 93ad3d905ccb8..675b9a13f04bb 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php @@ -73,8 +73,10 @@ public function normalize(mixed $object, string $format = null, array $context = /** * {@inheritdoc} + * + * @param array $context */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool { return $data instanceof \SplFileInfo; } @@ -117,8 +119,10 @@ public function denormalize(mixed $data, string $type, string $format = null, ar /** * {@inheritdoc} + * + * @param array $context */ - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool { return isset(self::SUPPORTED_TYPES[$type]); } diff --git a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php index db1117500b5b3..9a7aa04968724 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php @@ -49,8 +49,10 @@ public function normalize(mixed $object, string $format = null, array $context = /** * {@inheritdoc} + * + * @param array $context */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool { return $data instanceof \DateInterval; } @@ -117,8 +119,10 @@ public function denormalize(mixed $data, string $type, string $format = null, ar /** * {@inheritdoc} + * + * @param array $context */ - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool { return \DateInterval::class === $type; } diff --git a/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php index da4f503eb53c2..ea7e30f9e2cb0 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php @@ -71,8 +71,10 @@ public function normalize(mixed $object, string $format = null, array $context = /** * {@inheritdoc} + * + * @param array $context */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool { return $data instanceof \DateTimeInterface; } @@ -112,8 +114,10 @@ public function denormalize(mixed $data, string $type, string $format = null, ar /** * {@inheritdoc} + * + * @param array $context */ - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool { return isset(self::SUPPORTED_TYPES[$type]); } diff --git a/src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php index 67ff3d92b3fc7..89adcb56f833a 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php @@ -38,8 +38,10 @@ public function normalize(mixed $object, string $format = null, array $context = /** * {@inheritdoc} + * + * @param array $context */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool { return $data instanceof \DateTimeZone; } @@ -64,8 +66,10 @@ public function denormalize(mixed $data, string $type, string $format = null, ar /** * {@inheritdoc} + * + * @param array $context */ - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool { return \DateTimeZone::class === $type; } diff --git a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php index 5e94400b80006..1c708738a1565 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php +++ b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php @@ -49,11 +49,12 @@ public function denormalize(mixed $data, string $type, string $format = null, ar /** * Checks whether the given class is supported for denormalization by this normalizer. * - * @param mixed $data Data to denormalize from - * @param string $type The class to which the data should be denormalized - * @param string $format The format being deserialized from + * @param mixed $data Data to denormalize from + * @param string $type The class to which the data should be denormalized + * @param string $format The format being deserialized from + * @param array $context Options available to the denormalizer * * @return bool */ - public function supportsDenormalization(mixed $data, string $type, string $format = null); + public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */); } diff --git a/src/Symfony/Component/Serializer/Normalizer/FormErrorNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/FormErrorNormalizer.php index 8bd8a845fc793..0ffa9f072a2c1 100644 --- a/src/Symfony/Component/Serializer/Normalizer/FormErrorNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/FormErrorNormalizer.php @@ -44,7 +44,7 @@ public function normalize(mixed $object, string $format = null, array $context = /** * {@inheritdoc} */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool { return $data instanceof FormInterface && $data->isSubmitted() && !$data->isValid(); } diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index bb8b79c2e439f..7e42144f69ff2 100644 --- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -38,16 +38,20 @@ class GetSetMethodNormalizer extends AbstractObjectNormalizer /** * {@inheritdoc} + * + * @param array $context */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool { return parent::supportsNormalization($data, $format) && $this->supports(\get_class($data)); } /** * {@inheritdoc} + * + * @param array $context */ - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool { return parent::supportsDenormalization($data, $type, $format) && $this->supports($type); } diff --git a/src/Symfony/Component/Serializer/Normalizer/JsonSerializableNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/JsonSerializableNormalizer.php index 2bf4319118581..5560ea9166120 100644 --- a/src/Symfony/Component/Serializer/Normalizer/JsonSerializableNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/JsonSerializableNormalizer.php @@ -43,16 +43,20 @@ public function normalize(mixed $object, string $format = null, array $context = /** * {@inheritdoc} + * + * @param array $context */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool { return $data instanceof \JsonSerializable; } /** * {@inheritdoc} + * + * @param array $context */ - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool { return false; } diff --git a/src/Symfony/Component/Serializer/Normalizer/MimeMessageNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/MimeMessageNormalizer.php index f421d99e18e51..7c195bf3021c9 100644 --- a/src/Symfony/Component/Serializer/Normalizer/MimeMessageNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/MimeMessageNormalizer.php @@ -100,7 +100,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar /** * {@inheritdoc} */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool { return $data instanceof Message || $data instanceof Headers || $data instanceof HeaderInterface || $data instanceof Address || $data instanceof AbstractPart; } @@ -108,7 +108,7 @@ public function supportsNormalization(mixed $data, string $format = null): bool /** * {@inheritdoc} */ - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool { return is_a($type, Message::class, true) || Headers::class === $type || AbstractPart::class === $type; } diff --git a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php index 30eeafb47bac7..741f19e50b306 100644 --- a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php +++ b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php @@ -41,10 +41,11 @@ public function normalize(mixed $object, string $format = null, array $context = /** * Checks whether the given class is supported for normalization by this normalizer. * - * @param mixed $data Data to normalize - * @param string $format The format being (de-)serialized from or into + * @param mixed $data Data to normalize + * @param string $format The format being (de-)serialized from or into + * @param array $context Context options for the normalizer * * @return bool */ - public function supportsNormalization(mixed $data, string $format = null); + public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */); } diff --git a/src/Symfony/Component/Serializer/Normalizer/ProblemNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ProblemNormalizer.php index 533b24e65bcc9..f7609945f7ee9 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ProblemNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ProblemNormalizer.php @@ -64,8 +64,10 @@ public function normalize(mixed $object, string $format = null, array $context = /** * {@inheritdoc} + * + * @param array $context */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool { return $data instanceof FlattenException; } diff --git a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php index c85cfd36d0d11..dda4246b01eb8 100644 --- a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php @@ -34,16 +34,20 @@ class PropertyNormalizer extends AbstractObjectNormalizer { /** * {@inheritdoc} + * + * @param array $context */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool { return parent::supportsNormalization($data, $format) && $this->supports(\get_class($data)); } /** * {@inheritdoc} + * + * @param array $context */ - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool { return parent::supportsDenormalization($data, $type, $format) && $this->supports($type); } diff --git a/src/Symfony/Component/Serializer/Normalizer/UidNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/UidNormalizer.php index 42a86d9e95250..889999031939c 100644 --- a/src/Symfony/Component/Serializer/Normalizer/UidNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/UidNormalizer.php @@ -59,7 +59,7 @@ public function normalize(mixed $object, string $format = null, array $context = /** * {@inheritdoc} */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool { return $data instanceof AbstractUid; } @@ -85,7 +85,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar /** * {@inheritdoc} */ - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool { return is_a($type, AbstractUid::class, true); } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php index f447c684a39eb..6f999f612ba19 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php @@ -90,7 +90,7 @@ public function testNeedsNormalizationNormalizationAware() class NormalizationAwareEncoder implements EncoderInterface, NormalizationAwareInterface { - public function supportsEncoding(string $format): bool + public function supportsEncoding(string $format, array $context = []): bool { return true; } diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractNormalizerDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractNormalizerDummy.php index 5fb5ba3d38c0c..afdfdec1604ee 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractNormalizerDummy.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/AbstractNormalizerDummy.php @@ -38,7 +38,7 @@ public function normalize(mixed $object, string $format = null, array $context = /** * {@inheritdoc} */ - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool { return true; } @@ -53,7 +53,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar /** * {@inheritdoc} */ - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool { return true; } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php index b93671aaf9c44..b2f4a08ed0a78 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php @@ -535,7 +535,7 @@ public function denormalize($data, string $type, string $format = null, array $c return null; } - public function supportsDenormalization($data, string $type, string $format = null): bool + public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool { return true; } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php b/src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php index 56398232a9e1e..cef09715d9ede 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/TestDenormalizer.php @@ -30,7 +30,7 @@ public function denormalize($data, string $type, string $format = null, array $c /** * {@inheritdoc} */ - public function supportsDenormalization($data, string $type, string $format = null): bool + public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool { return true; } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php b/src/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php index bf1f8f725f401..f3b604bfe063f 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/TestNormalizer.php @@ -31,7 +31,7 @@ public function normalize($object, string $format = null, array $context = []): /** * {@inheritdoc} */ - public function supportsNormalization($data, string $format = null): bool + public function supportsNormalization($data, string $format = null, array $context = []): bool { return true; }