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 b81e087

Browse filesBrowse files
committed
Merge context aware interfaces into regular ones
1 parent 0d6e859 commit b81e087
Copy full SHA for b81e087

36 files changed

+146
-58
lines changed

‎UPGRADE-6.1.md

Copy file name to clipboard
+10Lines 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/Serializer/CHANGELOG.md

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

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

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

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

124124
/**
125125
* {@inheritdoc}
126+
*
127+
* @param array $context
126128
*/
127-
public function supportsEncoding(string $format): bool
129+
public function supportsEncoding(string $format /*, array $context = [] */): bool
128130
{
129131
return self::FORMAT === $format;
130132
}
@@ -209,8 +211,10 @@ public function decode(string $data, string $format, array $context = []): mixed
209211

210212
/**
211213
* {@inheritdoc}
214+
*
215+
* @param array $context
212216
*/
213-
public function supportsDecoding(string $format): bool
217+
public function supportsDecoding(string $format /*, array $context = [] */): bool
214218
{
215219
return self::FORMAT === $format;
216220
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/DecoderInterface.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ public function decode(string $data, string $format, array $context = []);
4040
* Checks whether the deserializer can decode from given format.
4141
*
4242
* @param string $format Format name
43+
* @param array $context Options that decoders have access to
4344
*
4445
* @return bool
4546
*/
46-
public function supportsDecoding(string $format);
47+
public function supportsDecoding(string $format /*, array $context = [] */);
4748
}

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

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

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

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

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

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

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory
134134

135135
/**
136136
* {@inheritdoc}
137+
*
138+
* @param array $context
137139
*/
138-
public function supportsNormalization(mixed $data, string $format = null)
140+
public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */)
139141
{
140142
return \is_object($data) && !$data instanceof \Traversable;
141143
}
@@ -349,8 +351,10 @@ abstract protected function getAttributeValue(object $object, string $attribute,
349351

350352
/**
351353
* {@inheritdoc}
354+
*
355+
* @param array $context
352356
*/
353-
public function supportsDenormalization(mixed $data, string $type, string $format = null)
357+
public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */)
354358
{
355359
return class_exists($type) || (interface_exists($type, false) && $this->classDiscriminatorResolver && null !== $this->classDiscriminatorResolver->getMappingForClass($type));
356360
}

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

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

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

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

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php
+9-7Lines 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

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

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

‎src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ public function normalize(mixed $object, string $format = null, array $context =
7171

7272
/**
7373
* {@inheritdoc}
74+
*
75+
* @param array $context
7476
*/
75-
public function supportsNormalization(mixed $data, string $format = null): bool
77+
public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool
7678
{
7779
return $data instanceof \DateTimeInterface;
7880
}
@@ -112,8 +114,10 @@ public function denormalize(mixed $data, string $type, string $format = null, ar
112114

113115
/**
114116
* {@inheritdoc}
117+
*
118+
* @param array $context
115119
*/
116-
public function supportsDenormalization(mixed $data, string $type, string $format = null): bool
120+
public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool
117121
{
118122
return isset(self::SUPPORTED_TYPES[$type]);
119123
}

‎src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ public function normalize(mixed $object, string $format = null, array $context =
3838

3939
/**
4040
* {@inheritdoc}
41+
*
42+
* @param array $context
4143
*/
42-
public function supportsNormalization(mixed $data, string $format = null): bool
44+
public function supportsNormalization(mixed $data, string $format = null /*, array $context = [] */): bool
4345
{
4446
return $data instanceof \DateTimeZone;
4547
}
@@ -64,8 +66,10 @@ public function denormalize(mixed $data, string $type, string $format = null, ar
6466

6567
/**
6668
* {@inheritdoc}
69+
*
70+
* @param array $context
6771
*/
68-
public function supportsDenormalization(mixed $data, string $type, string $format = null): bool
72+
public function supportsDenormalization(mixed $data, string $type, string $format = null /*, array $context = [] */): bool
6973
{
7074
return \DateTimeZone::class === $type;
7175
}

0 commit comments

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