Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Messenger][Serializer] Deprecate "context aware" interfaces #43982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions 10 UPGRADE-6.1.md
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions 8 src/Symfony/Component/Serializer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* Adds the support of an extra $context parameter for the supportsDecoding method.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @deprecated since symfony/serializer 6.1, use DecoderInterface instead
*/
interface ContextAwareDecoderInterface extends DecoderInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* Adds the support of an extra $context parameter for the supportsEncoding method.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @deprecated since symfony/serializer 6.1, use EncoderInterface instead
*/
interface ContextAwareEncoderInterface extends EncoderInterface
{
Expand Down
8 changes: 6 additions & 2 deletions 8 src/Symfony/Component/Serializer/Encoder/CsvEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [] */);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 3 additions & 1 deletion 4 src/Symfony/Component/Serializer/Encoder/JsonDecode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion 4 src/Symfony/Component/Serializer/Encoder/JsonEncode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 6 additions & 2 deletions 8 src/Symfony/Component/Serializer/Encoder/JsonEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 6 additions & 2 deletions 8 src/Symfony/Component/Serializer/Encoder/XmlEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 6 additions & 2 deletions 8 src/Symfony/Component/Serializer/Encoder/YamlEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* Adds the support of an extra $context parameter for the supportsDenormalization method.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @deprecated since symfony/serializer 6.1, use DenormalizerInterface instead
*/
interface ContextAwareDenormalizerInterface extends DenormalizerInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* Adds the support of an extra $context parameter for the supportsNormalization method.
*
* @author Kévin Dunglas <dunglas@gmail.com>
*
* @deprecated since symfony/serializer 6.1, use NormalizerInterface instead
*/
interface ContextAwareNormalizerInterface extends NormalizerInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,24 @@ 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;
}

/**
* 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.