Skip to content

Commit afca338

Browse files
[Serializer] Revert deprecation of ContextAwareEncoderInterface and ContextAwareDecoderInterface
1 parent 6b0112c commit afca338

15 files changed

+29
-47
lines changed

src/Symfony/Component/Serializer/CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ CHANGELOG
99
* Set `Context` annotation as not final
1010
* Deprecate `ContextAwareNormalizerInterface`, use `NormalizerInterface` instead
1111
* Deprecate `ContextAwareDenormalizerInterface`, use `DenormalizerInterface` instead
12-
* Deprecate `ContextAwareEncoderInterface`, use `EncoderInterface` instead
13-
* Deprecate `ContextAwareDecoderInterface`, use `DecoderInterface` instead
1412
* Deprecate supporting denormalization for `AbstractUid` in `UidNormalizer`, use one of `AbstractUid` child class instead
1513
* Deprecate denormalizing to an abstract class in `UidNormalizer`
1614
* Add support for `can*()` methods to `ObjectNormalizer`

src/Symfony/Component/Serializer/Encoder/ChainDecoder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,13 @@ private function getDecoder(string $format, array $context): DecoderInterface
6767
return $this->decoders[$this->decoderByFormat[$format]];
6868
}
6969

70+
$cache = true;
7071
foreach ($this->decoders as $i => $decoder) {
72+
$cache = $cache && !$decoder instanceof ContextAwareDecoderInterface;
7173
if ($decoder->supportsDecoding($format, $context)) {
72-
$this->decoderByFormat[$format] = $i;
74+
if ($cache) {
75+
$this->decoderByFormat[$format] = $i;
76+
}
7377

7478
return $decoder;
7579
}

src/Symfony/Component/Serializer/Encoder/ChainEncoder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,13 @@ private function getEncoder(string $format, array $context): EncoderInterface
9090
return $this->encoders[$this->encoderByFormat[$format]];
9191
}
9292

93+
$cache = true;
9394
foreach ($this->encoders as $i => $encoder) {
95+
$cache = $cache && !$encoder instanceof ContextAwareEncoderInterface;
9496
if ($encoder->supportsEncoding($format, $context)) {
95-
$this->encoderByFormat[$format] = $i;
97+
if ($cache) {
98+
$this->encoderByFormat[$format] = $i;
99+
}
96100

97101
return $encoder;
98102
}

src/Symfony/Component/Serializer/Encoder/ContextAwareDecoderInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* Adds the support of an extra $context parameter for the supportsDecoding method.
1616
*
1717
* @author Kévin Dunglas <dunglas@gmail.com>
18-
*
19-
* @deprecated since symfony/serializer 6.1, use DecoderInterface instead
2018
*/
2119
interface ContextAwareDecoderInterface extends DecoderInterface
2220
{

src/Symfony/Component/Serializer/Encoder/ContextAwareEncoderInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* Adds the support of an extra $context parameter for the supportsEncoding method.
1616
*
1717
* @author Kévin Dunglas <dunglas@gmail.com>
18-
*
19-
* @deprecated since symfony/serializer 6.1, use EncoderInterface instead
2018
*/
2119
interface ContextAwareEncoderInterface extends EncoderInterface
2220
{

src/Symfony/Component/Serializer/Encoder/CsvEncoder.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,8 @@ public function encode(mixed $data, string $format, array $context = []): string
124124

125125
/**
126126
* {@inheritdoc}
127-
*
128-
* @param array $context
129127
*/
130-
public function supportsEncoding(string $format /* , array $context = [] */): bool
128+
public function supportsEncoding(string $format): bool
131129
{
132130
return self::FORMAT === $format;
133131
}
@@ -212,10 +210,8 @@ public function decode(string $data, string $format, array $context = []): mixed
212210

213211
/**
214212
* {@inheritdoc}
215-
*
216-
* @param array $context
217213
*/
218-
public function supportsDecoding(string $format /* , array $context = [] */): bool
214+
public function supportsDecoding(string $format): bool
219215
{
220216
return self::FORMAT === $format;
221217
}

src/Symfony/Component/Serializer/Encoder/DecoderInterface.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ public function decode(string $data, string $format, array $context = []);
3939
/**
4040
* Checks whether the deserializer can decode from given format.
4141
*
42-
* @param string $format Format name
43-
* @param array $context Options that decoders have access to
42+
* @param string $format Format name
4443
*
4544
* @return bool
4645
*/
47-
public function supportsDecoding(string $format /* , array $context = [] */);
46+
public function supportsDecoding(string $format);
4847
}

src/Symfony/Component/Serializer/Encoder/EncoderInterface.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public function encode(mixed $data, string $format, array $context = []): string
3232
/**
3333
* Checks whether the serializer can encode to given format.
3434
*
35-
* @param string $format Format name
36-
* @param array $context Options that normalizers/encoders have access to
35+
* @param string $format Format name
3736
*/
38-
public function supportsEncoding(string $format /* , array $context = [] */): bool;
37+
public function supportsEncoding(string $format): bool;
3938
}

src/Symfony/Component/Serializer/Encoder/JsonDecode.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,8 @@ public function decode(string $data, string $format, array $context = []): mixed
9595

9696
/**
9797
* {@inheritdoc}
98-
*
99-
* @param array $context
10098
*/
101-
public function supportsDecoding(string $format /* , array $context = [] */): bool
99+
public function supportsDecoding(string $format): bool
102100
{
103101
return JsonEncoder::FORMAT === $format;
104102
}

src/Symfony/Component/Serializer/Encoder/JsonEncode.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ public function encode(mixed $data, string $format, array $context = []): string
5757

5858
/**
5959
* {@inheritdoc}
60-
*
61-
* @param array $context
6260
*/
63-
public function supportsEncoding(string $format /* , array $context = [] */): bool
61+
public function supportsEncoding(string $format): bool
6462
{
6563
return JsonEncoder::FORMAT === $format;
6664
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy