8000 Merge context aware interfaces into regular ones · symfony/symfony@f671ec2 · GitHub
[go: up one dir, main page]

Skip to content

Commit f671ec2

Browse files
committed
Merge context aware interfaces into regular ones
1 parent cd2e251 commit f671ec2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+156
-72
lines changed

UPGRADE-6.1.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
UPGRADE FROM 6.0 to 6.1
2+
=======================
3+
4+
Serializer
5+
-----
6+
7+
* Deprecate `ContextAwareNormalizerInterface`, use `NormalizerInterface` instead
8+
* Deprecate `ContextAwareDenormalizerInterface`, use `DenormalizerInterface` instead
9+
* Deprecate `ContextAwareEncoderInterface`, use `EncoderInterface` instead
10+
* Deprecate `ContextAwareDecoderInterface`, use `DecoderInterface` instead

src/Symfony/Component/Messenger/Transport/Serialization/Normalizer/FlattenExceptionNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313

1414
use Symfony\Component\ErrorHandler\Exception\FlattenException;
1515
use Symfony\Component\Messenger\Transport\Serialization\Serializer;
16-
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
1716
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
1817
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
18+
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
1919

2020
/**
2121
* This normalizer is only used in Debug/Dev/Messenger contexts.
2222
*
2323
* @author Pascal Luna <skalpa@zetareticuli.org>
2424
*/
25-
final class FlattenExceptionNormalizer implements DenormalizerInterface, ContextAwareNormalizerInterface
25+
final class FlattenExceptionNormalizer implements NormalizerInterface, DenormalizerInterface
2626
{
2727
use NormalizerAwareTrait;
2828

src/Symfony/Component/Serializer/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
CHANGELOG
22
=========
33

4+
6.1
5+
---
6+
7+
* Deprecate `ContextAwareNormalizerInterface`, use `NormalizerInterface` instead
8+
* Deprecate `ContextAwareDenormalizerInterface`, use `DenormalizerInterface` instead
9+
* Deprecate `ContextAwareEncoderInterface`, use `EncoderInterface` instead
10+
* Deprecate `ContextAwareDecoderInterface`, use `DecoderInterface` instead
11+
412
6.0
513
---
614

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
* @final
2424
*/
25-
class ChainDecoder implements ContextAwareDecoderInterface
25+
class ChainDecoder implements DecoderInterface
2626
{
2727
private array $decoders = [];
2828
private array $decoderByFormat = [];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
* @final
2424
*/
25-
class ChainEncoder implements ContextAwareEncoderInterface
25+
class ChainEncoder implements EncoderInterface
2626
{
2727
private array $encoders = [];
2828
private array $encoderByFormat = [];

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
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.
1820
*/
1921
interface ContextAwareDecoderInterface extends DecoderInterface
2022
{

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
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.
1820
*/
1921
interface ContextAwareEncoderInterface extends EncoderInterface
2022
{

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

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

123123
/**
124124
* {@inheritdoc}
125+
*
126+
* @param array $context
125127
*/
126-
public function supportsEncoding(string $format): bool
128+
public function supportsEncoding(string $format /*, array $context = [] */): bool
127129
{
128130
return self::FORMAT === $format;
129131
}
@@ -208,8 +210,10 @@ public function decode(string $data, string $format, array $context = []): mixed
208210

209211
/**
210212
* {@inheritdoc}
213+
*
214+
* @param array $context
211215
*/
212-
public function supportsDecoding(string $format): bool
216+
public function supportsDecoding(string $format /*, array $context = [] */): bool
213217
{
214218
return self::FORMAT === $format;
215219
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public function decode(string $data, string $format, array $context = []): mixed
3737
/**
3838
* Checks whether the deserializer can decode from given format.
3939
*
40-
* @param string $format Format name
40+
* @param string $format Format name
41+
* @param array $context Options that decoders have access to
4142
*/
42-
public function supportsDecoding(string $format): bool;
43+
public function supportsDecoding(string $format /*, array $context = [] */): bool;
4344
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ 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
35+
* @param string $format Format name
36+
* @param array $context Options that normalizers/encoders have access to
3637
*/
37-
public function supportsEncoding(string $format): bool;
38+
public function supportsEncoding(string $format /*, array $context = [] */): bool;
3839
}

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

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

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

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

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

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

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,20 @@ public function decode(string $data, string $format, array $context = []): mixed
4747

4848
/**
4949
* {@inheritdoc}
50+
*
51+
* @param array $context
5052
*/
51-
public function supportsEncoding(string $format): bool
53+
public function supportsEncoding(string $format /*, array $context = [] */): bool
5254
{
5355
return self::FORMAT === $format;
5456
}
5557

5658
/**
5759
* {@inheritdoc}
60+
*
61+
* @param array $context
5862
*/
59-
public function supportsDecoding(string $format): bool
63+
public function supportsDecoding(string $format /*, array $context = [] */): bool
6064
{
6165
return self::FORMAT === $format;
6266
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,20 @@ public function decode(string $data, string $format, array $context = []): mixed
174174

175175
/**
176176
* {@inheritdoc}
177+
*
178+
* @param array $context
177179
*/
178-
public function supportsEncoding(string $format): bool
180+
public function supportsEncoding(string $format /*, array $context = [] */): bool
179181
{
180182
return self::FORMAT === $format;
181183
}
182184

183185
/**
184186
* {@inheritdoc}
187+
*
188+
* @param array $context
185189
*/
186-
public function supportsDecoding(string $format): bool
190+
public function supportsDecoding(string $format /*, array $context = [] */): bool
187191
{
188192
return self::FORMAT === $format;
189193
}

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

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

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

8688
/**
8789
* {@inheritdoc}
90+
*
91+
* @param array $context
8892
*/
89-
public function supportsDecoding(string $format): bool
93+
public function supportsDecoding(string $format /*, array $context = [] */): bool
9094
{
9195
return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format;
9296
}

src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory
135135

136136
/**
137137
* {@inheritdoc}
138+
*
139+
* @param array $context
138140
*/
139-
public function supportsNormalization(mixed $data, string $format = null): bool
141+
public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool
140142
{
141143
return \is_object($data) && !$data instanceof \Traversable;
142144
}
@@ -348,8 +350,10 @@ abstract protected function getAttributeValue(object $object, string $attribute,
348350

349351
/**
350352
* {@inheritdoc}
353+
*
354+
* @param array $context
351355
*/
352-
public function supportsDenormalization(mixed $data, string $type, string $format = null): bool
356+
public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool
353357
{
354358
return class_exists($type) || (interface_exists($type, false) && $this->classDiscriminatorResolver && null !== $this->classDiscriminatorResolver->getMappingForClass($type));
355359
}

src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
* @final
2424
*/
25-
class ArrayDenormalizer implements ContextAwareDenormalizerInterface, DenormalizerAwareInterface, CacheableSupportsMethodInterface
25+
class ArrayDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface, CacheableSupportsMethodInterface
2626
{
2727
use DenormalizerAwareTrait;
2828

src/Symfony/Component/Serializer/Normalizer/BackedEnumNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function normalize($object, $format = null, array $context = []): int|str
3737
/**
3838
* {@inheritdoc}
3939
*/
40-
public function supportsNormalization($data, $format = null): bool
40+
public function supportsNormalization($data, $format = null, array $context = []): bool
4141
{
4242
return $data instanceof \BackedEnum;
4343
}
@@ -67,7 +67,7 @@ public function denormalize($data, $type, $format = null, array $context = []):
6767
/**
6868
* {@inheritdoc}
6969
*/
70-
public function supportsDenormalization($data, $type, $format = null): bool
70+
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
7171
{
7272
return is_subclass_of($type, \BackedEnum::class);
7373
}

src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ public function normalize(mixed $object, string $format = null, array $context =
106106

107107
/**
108108
* {@inheritdoc}
109+
*
110+
* @param array $context
109111
*/
110-
public function supportsNormalization(mixed $data, string $format = null): bool
112+
public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool
111113
{
112114
return $data instanceof ConstraintViolationListInterface;
113115
}

src/Symfony/Component/Serializer/Normalizer/ContextAwareDenormalizerInterface.php

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

src/Symfony/Component/Serializer/Normalizer/ContextAwareNormalizerInterface.php

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

src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,24 @@ public function denormalize(mixed $data, string $type, string $format = null, ar
4444
/**
4545
* Checks if the given class implements the NormalizableInterface.
4646
*
47-
* @param mixed $data Data to normalize
48-
* @param string $format The format being (de-)serialized from or into
47+
* @param mixed $data Data to normalize
48+
* @param string $format The format being (de-)serialized from or into
49+
* @param array $context
4950
*/
50-
public function supportsNormalization(mixed $data, string $format = null): bool
51+
public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool
5152
{
5253
return $data instanceof NormalizableInterface;
5354
}
5455

5556
/**
5657
* Checks if the given class implements the DenormalizableInterface.
5758
*
58-
* @param mixed $data Data to denormalize from
59-
* @param string $type The class to which the data should be denormalized
60-
* @param string $format The format being deserialized from
59+
* @param mixed $data Data to denormalize from
60+
* @param string $type The class to which the data should be denormalized
61+
* @param string $format The format being deserialized from
62+
* @param array $context
6163
*/
62-
public function supportsDenormalization(mixed $data, string $type, string $format = null): bool
64+
public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool
6365
{
6466
return is_subclass_of($type, DenormalizableInterface::class);
6567
}

src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ public function normalize(mixed $object, string $format = null, array $context =
7373

7474
/**
7575
* {@inheritdoc}
76+
*
77+
* @param array $context
7678
*/
77-
public function supportsNormalization(mixed $data, string $format = null): bool
79+
public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool
7880
{
7981
return $data instanceof \SplFileInfo;
8082
}
@@ -117,8 +119,10 @@ public function denormalize(mixed $data, string $type, string $format = null, ar
117119

118120
/**
119121
* {@inheritdoc}
122+
*
123+
* @param array $context
120124
*/
121-
public function supportsDenormalization(mixed $data, string $type, string $format = null): bool
125+
public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool
122126
{
123127
return isset(self::SUPPORTED_TYPES[$type]);
124128
}

src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ public function normalize(mixed $object, string $format = null, array $context =
4949

5050
/**
5151
* {@inheritdoc}
52+
*
53+
* @param array $context
5254
*/
53-
public function supportsNormalization(mixed $data, string $format = null): bool
55+
public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool
5456
{
5557
return $data instanceof \DateInterval;
5658
}
@@ -117,8 +119,10 @@ public function denormalize(mixed $data, string $type, string $format = null, ar
117119

118120
/**
119121
* {@inheritdoc}
122+
*
123+
* @param array $context
120124
*/
121-
public function supportsDenormalization(mixed $data, string $type, string $format = null): bool
125+
public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool
122126
{
123127
return \DateInterval::class === $type;
124128
}

0 commit comments

Comments
 (0)
0