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

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
}

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

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

‎src/Symfony/Component/Serializer/Encoder/JsonEncoder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/JsonEncoder.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,16 @@ public function decode(string $data, string $format, array $context = []): mixed
4747

4848
/**
4949
* {@inheritdoc}
50-
*
51-
* @param array $context
5250
*/
53-
public function supportsEncoding(string $format /* , array $context = [] */): bool
51+
public function supportsEncoding(string $format): bool
5452
{
5553
return self::FORMAT === $format;
5654
}
5755

5856
/**
5957
* {@inheritdoc}
60-
*
61-
* @param array $context
6258
*/
63-
public function supportsDecoding(string $format /* , array $context = [] */): bool
59+
public function supportsDecoding(string $format): bool
6460
{
6561
return self::FORMAT === $format;
6662
}

‎src/Symfony/Component/Serializer/Encoder/XmlEncoder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/XmlEncoder.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,16 @@ public function decode(string $data, string $format, array $context = []): mixed
166166

167167
/**
168168
* {@inheritdoc}
169-
*
170-
* @param array $context
171169
*/
172-
public function supportsEncoding(string $format /* , array $context = [] */): bool
170+
public function supportsEncoding(string $format): bool
173171
{
174172
return self::FORMAT === $format;
175173
}
176174

177175
/**
178176
* {@inheritdoc}
179-
*
180-
* @param array $context
181177
*/
182-
public function supportsDecoding(string $format /* , array $context = [] */): bool
178+
public function supportsDecoding(string $format): bool
183179
{
184180
return self::FORMAT === $format;
185181
}

‎src/Symfony/Component/Serializer/Encoder/YamlEncoder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/YamlEncoder.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ public function encode(mixed $data, string $format, array $context = []): string
6767

6868
/**
6969
* {@inheritdoc}
70-
*
71-
* @param array $context
7270
*/
73-
public function supportsEncoding(string $format /* , array $context = [] */): bool
71+
public function supportsEncoding(string $format): bool
7472
{
7573
return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format;
7674
}
@@ -87,10 +85,8 @@ public function decode(string $data, string $format, array $context = []): mixed
8785

8886
/**
8987
* {@inheritdoc}
90-
*
91-
* @param array $context
9288
*/
93-
public function supportsDecoding(string $format /* , array $context = [] */): bool
89+
public function supportsDecoding(string $format): bool
9490
{
9591
return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format;
9692
}

‎src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Serializer\Encoder\ChainDecoder;
16+
use Symfony\Component\Serializer\Encoder\ContextAwareDecoderInterface;
1617
use Symfony\Component\Serializer\Encoder\DecoderInterface;
1718
use Symfony\Component\Serializer\Exception\RuntimeException;
1819

@@ -28,7 +29,7 @@ class ChainDecoderTest extends TestCase
2829

2930
protected function setUp(): void
3031
{
31-
$this->decoder1 = $this->createMock(DecoderInterface::class);
32+
$this->decoder1 = $this->createMock(ContextAwareDecoderInterface::class);
3233
$this->decoder1
3334
->method('supportsDecoding')
3435
->willReturnMap([

‎src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Serializer\Debug\TraceableEncoder;
1616
use Symfony\Component\Serializer\Encoder\ChainEncoder;
17+
use Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface;
1718
use Symfony\Component\Serializer\Encoder\EncoderInterface;
1819
use Symfony\Component\Serializer\Encoder\NormalizationAwareInterface;
1920
use Symfony\Component\Serializer\Exception\RuntimeException;
@@ -30,7 +31,7 @@ class ChainEncoderTest extends TestCase
3031

3132
protected function setUp(): void
3233
{
33-
$this->encoder1 = $this->createMock(EncoderInterface::class);
34+
$this->encoder1 = $this->createMock(ContextAwareEncoderInterface::class);
3435
$this->encoder1
3536
->method('supportsEncoding')
3637
->willReturnMap([
@@ -106,7 +107,7 @@ public function testNeedsNormalizationTraceableEncoder()
106107

107108
class NormalizationAwareEncoder implements EncoderInterface, NormalizationAwareInterface
108109
{
109-
public function supportsEncoding(string $format, array $context = []): bool
110+
public function supportsEncoding(string $format): bool
110111
{
111112
return true;
112113
}

0 commit comments

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