Skip to content

Navigation Menu

Sign in
Appearance settings

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

Commit 9ac7fb1

Browse filesBrowse files
[Serializer] Revert deprecation of ContextAwareEncoderInterface and ContextAwareDecoderInterface
1 parent 6b0112c commit 9ac7fb1
Copy full SHA for 9ac7fb1
Expand file treeCollapse file tree

16 files changed

+32
-50
lines changed

‎.github/expected-missing-return-types.diff

Copy file name to clipboardExpand all lines: .github/expected-missing-return-types.diff
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -899,11 +899,11 @@ index f38069e471..0966eb3e89 100644
899899
+ public function decode(string $data, string $format, array $context = []): mixed;
900900

901901
/**
902-
@@ -45,4 +45,4 @@ interface DecoderInterface
902+
@@ -44,4 +44,4 @@ interface DecoderInterface
903903
* @return bool
904904
*/
905-
- public function supportsDecoding(string $format /* , array $context = [] */);
906-
+ public function supportsDecoding(string $format /* , array $context = [] */): bool;
905+
- public function supportsDecoding(string $format);
906+
+ public function supportsDecoding(string $format): bool;
907907
}
908908
diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
909909
index 44ba45f581..3398115497 100644

‎src/Symfony/Component/Serializer/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/CHANGELOG.md
-2Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/ChainDecoder.php
+5-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/ChainEncoder.php
+5-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/ContextAwareDecoderInterface.php
-2Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/ContextAwareEncoderInterface.php
-2Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/CsvEncoder.php
+2-6Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/DecoderInterface.php
+2-3Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/EncoderInterface.php
+2-3Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/JsonDecode.php
+1-3Lines 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
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.