Skip to content

Commit e48911d

Browse files
committed
Merge branch '6.1' into 6.2
* 6.1: [LokaliseBridge] Fix push command --delete-missing options when there are no missing messages fix bad help message in cache warmup command [Console] Fix OutputFormatterStyleStack::getCurrent return type Count cookie parts before accessing the second Fix RequestStack state if throwable is thrown [Serializer] Fix caching context-aware encoders/decoders in ChainEncoder/ChainDecoder [Serializer] Revert deprecation of `ContextAwareEncoderInterface` and `ContextAwareDecoderInterface`
2 parents 5892b06 + 03e5987 commit e48911d

15 files changed

+67
-57
lines changed

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ CHANGELOG
1616
* Set `Context` annotation as not final
1717
* Deprecate `ContextAwareNormalizerInterface`, use `NormalizerInterface` instead
1818
* Deprecate `ContextAwareDenormalizerInterface`, use `DenormalizerInterface` instead
19-
* Deprecate `ContextAwareEncoderInterface`, use `EncoderInterface` instead
20-
* Deprecate `ContextAwareDecoderInterface`, use `DecoderInterface` instead
2119
* Deprecate supporting denormalization for `AbstractUid` in `UidNormalizer`, use one of `AbstractUid` child class instead
2220
* Deprecate denormalizing to an abstract class in `UidNormalizer`
2321
* Add support for `can*()` methods to `ObjectNormalizer`

Encoder/ChainDecoder.php

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

64+
$cache = true;
6465
foreach ($this->decoders as $i => $decoder) {
66+
$cache = $cache && !$decoder instanceof ContextAwareDecoderInterface;
6567
if ($decoder->supportsDecoding($format, $context)) {
66-
$this->decoderByFormat[$format] = $i;
68+
if ($cache) {
69+
$this->decoderByFormat[$format] = $i;
70+
}
6771

6872
return $decoder;
6973
}

Encoder/ChainEncoder.php

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

87+
$cache = true;
8788
foreach ($this->encoders as $i => $encoder) {
89+
$cache = $cache && !$encoder instanceof ContextAwareEncoderInterface;
8890
if ($encoder->supportsEncoding($format, $context)) {
89-
$this->encoderByFormat[$format] = $i;
91+
if ($cache) {
92+
$this->encoderByFormat[$format] = $i;
93+
}
9094

9195
return $encoder;
9296
}

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
{

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
{

Encoder/CsvEncoder.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ public function encode(mixed $data, string $format, array $context = []): string
119119
return $value;
120120
}
121121

122-
/**
123-
* @param array $context
124-
*/
125-
public function supportsEncoding(string $format /* , array $context = [] */): bool
122+
public function supportsEncoding(string $format): bool
126123
{
127124
return self::FORMAT === $format;
128125
}
@@ -202,10 +199,7 @@ public function decode(string $data, string $format, array $context = []): mixed
202199
return $result[0];
203200
}
204201

205-
/**
206-
* @param array $context
207-
*/
208-
public function supportsDecoding(string $format /* , array $context = [] */): bool
202+
public function supportsDecoding(string $format): bool
209203
{
210204
return self::FORMAT === $format;
211205
}

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
}

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
}

Encoder/JsonDecode.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ public function decode(string $data, string $format, array $context = []): mixed
9393
return $decodedData;
9494
}
9595

96-
/**
97-
* @param array $context
98-
*/
99-
public function supportsDecoding(string $format /* , array $context = [] */): bool
96+
public function supportsDecoding(string $format): bool
10097
{
10198
return JsonEncoder::FORMAT === $format;
10299
}

Encoder/JsonEncode.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ public function encode(mixed $data, string $format, array $context = []): string
5252
return $encodedJson;
5353
}
5454

55-
/**
56-
* @param array $context
57-
*/
58-
public function supportsEncoding(string $format /* , array $context = [] */): bool
55+
public function supportsEncoding(string $format): bool
5956
{
6057
return JsonEncoder::FORMAT === $format;
6158
}

0 commit comments

Comments
 (0)