8000 [Serializer] Remove BC layer · symfony/symfony@24bc857 · GitHub
[go: up one dir, main page]

Skip to content

Commit 24bc857

Browse files
committed
[Serializer] Remove BC layer
1 parent b1deb51 commit 24bc857

38 files changed

+111
-542
lines changed

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

+30-31
< 10000 tr class="diff-line-row">
Original file line numberDiff line numberDiff line change
@@ -11912,84 +11912,83 @@ index b684fddb2f..ade2242791 100644
1191211912
{
1191311913
return $this->data;
1191411914
diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
11915-
index 079b1e7a9e..e3cfe43e67 100644
11915+
index efe4a6e0e1..fbf291af7e 100644
1191611916
--- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
1191711917
+++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
11918-
@@ -221,5 +221,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
11918+
@@ -211,5 +211,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
1191911919
* @throws LogicException if the 'allow_extra_attributes' context variable is false and no class metadata factory is provided
1192011920
*/
1192111921
- protected function getAllowedAttributes(string|object $classOrObject, array $context, bool $attributesAsString = false)
1192211922
+ protected function getAllowedAttributes(string|object $classOrObject, array $context, bool $attributesAsString = false): array|bool
1192311923
{
1192411924
$allowExtraAttributes = $context[self::ALLOW_EXTRA_ATTRIBUTES] ?? $this->defaultContext[self::ALLOW_EXTRA_ATTRIBUTES];
11925-
@@ -271,5 +271,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
11925+
@@ -261,5 +261,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
1192611926
* @return bool
1192711927
*/
1192811928
- protected function isAllowedAttribute(object|string $classOrObject, string $attribute, string $format = null, array $context = [])
1192911929
+ protected function isAllowedAttribute(object|string $classOrObject, string $attribute, string $format = null, array $context = []): bool
1193011930
{
1193111931
$ignoredAttributes = $context[self::IGNORED_ATTRIBUTES] ?? $this->defaultContext[self::IGNORED_ATTRIBUTES];
11932-
@@ -322,5 +322,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
11932+
@@ -312,5 +312,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
1193311933
* @throws MissingConstructorArgumentsException
1193411934
*/
1193511935
- protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null)
1193611936
+ protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null): object
1193711937
{
1193811938
if (null !== $object = $this->extractObjectToPopulate($class, $context, self::OBJECT_TO_POPULATE)) {
1193911939
diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
11940-
index 0dba039bc0..576445825e 100644
11940+
index 4f061239b9..85c9f17a83 100644
1194111941
--- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
1194211942
+++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
11943-
@@ -143,5 +143,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11943+
@@ -141,5 +141,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1194411944
* @return bool
1194511945
*/
11946-
- public function supportsNormalization(mixed $data, string $format = null /* , array $context = [] */)
11947-
+ public function supportsNormalization(mixed $data, string $format = null /* , array $context = [] */): bool
11946+
- public function supportsNormalization(mixed $data, string $format = null, array $context = [])
11947+
+ public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool
1194811948
{
1194911949
return \is_object($data) && !$data instanceof \Traversable;
11950-
@@ -151,5 +151,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11950+
@@ -149,5 +149,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1195111951
* @return array|string|int|float|bool|\ArrayObject|null
1195211952
*/
1195311953
- public function normalize(mixed $object, string $format = null, array $context = [])
1195411954
+ public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
1195511955
{
1195611956
if (!isset($context['cache_key'])) {
11957-
@@ -235,5 +235,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11957+
@@ -233,5 +233,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1195811958
* @return object
1195911959
*/
1196011960
- protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null)
1196111961
+ protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null): object
1196211962
{
1196311963
if ($class !== $mappedClass = $this->getMappedClass($data, $class, $context)) {
11964-
@@ -286,5 +286,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11964+
@@ -284,5 +284,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1196511965
* @return string[]
1196611966
*/
1196711967
- abstract protected function extractAttributes(object $object, string $format = null, array $context = []);
1196811968
+ abstract protected function extractAttributes(object $object, string $format = null, array $context = []): array;
1196911969

1197011970
/**
11971-
@@ -293,5 +293,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11971+
@@ -291,10 +291,10 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1197211972
* @return mixed
1197311973
*/
1197411974
- abstract protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = []);
1197511975
+ abstract protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = []): mixed;
1197611976

1197711977
/**
11978-
@@ -300,5 +300,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1197911978
* @return bool
1198011979
*/
11981-
- public function supportsDenormalization(mixed $data, string $type, string $format = null /* , array $context = [] */)
11982-
+ public function supportsDenormalization(mixed $data, string $type, string $format = null /* , array $context = [] */): bool
11980+
- public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = [])
11981+
+ public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool
1198311982
{
1198411983
return class_exists($type) || (interface_exists($type, false) && null !== $this->classDiscriminatorResolver?->getMappingForClass($type));
11985-
@@ -308,5 +308,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11984+
@@ -304,5 +304,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1198611985
* @return mixed
1198711986
*/
1198811987
- public function denormalize(mixed $data, string $type, string $format = null, array $context = [])
1198911988
+ public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed
1199011989
{
1199111990
if (!isset($context['cache_key'])) {
11992-
@@ -414,5 +414,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11991+
@@ -410,5 +410,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1199311992
* @return void
1199411993
*/
1199511994
- abstract protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = []);
@@ -12017,7 +12016,7 @@ index 48e8c3fb54..a71c3ea476 100644
1201712016
+ public function setDenormalizer(DenormalizerInterface $denormalizer): void;
1201812017
}
1201912018
diff --git a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php
12020-
index 4edb70096d..8c844785db 100644
12019+
index e4d0ed9123..8a39d97f36 100644
1202112020
--- a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php
1202212021
+++ b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php
1202312022
@@ -47,5 +47,5 @@ interface DenormalizerInterface
@@ -12027,18 +12026,18 @@ index 4edb70096d..8c844785db 100644
1202712026
+ public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed;
1202812027

1202912028
/**
12030-
@@ -59,5 +59,5 @@ interface DenormalizerInterface
12029+
@@ -58,5 +58,5 @@ interface DenormalizerInterface
1203112030
* @return bool
1203212031
*/
12033-
- public function supportsDenormalization(mixed $data, string $type, string $format = null /* , array $context = [] */);
12034-
+ public function supportsDenormalization(mixed $data, string $type, string $format = null /* , array $context = [] */): bool;
12032+
- public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []);
12033+
+ public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool;
1203512034

1203612035
/**
1203712036
diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
12038-
index 063d34ea59..fb10337d35 100644
12037+
index 3d11567a7b..22e873b151 100644
1203912038
--- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
1204012039
+++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
12041-
@@ -147,5 +147,5 @@ class GetSetMethodNormalizer extends AbstractObjectNormalizer
12040+
@@ -131,5 +131,5 @@ class GetSetMethodNormalizer extends AbstractObjectNormalizer
1204212041
* @return void
1204312042
*/
1204412043
- protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = [])
@@ -12067,7 +12066,7 @@ index 40a4fa0e8c..a1e2749aae 100644
1206712066
{
1206812067
$this->normalizer = $normalizer;
1206912068
diff --git a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php
12070-
index 40779de316..105cf99b06 100644
12069+
index 01979d6fcf..e918540c83 100644
1207112070
--- a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php
1207212071
+++ b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php
1207312072
@@ -39,5 +39,5 @@ interface NormalizerInterface
@@ -12077,29 +12076,29 @@ index 40779de316..105cf99b06 100644
1207712076
+ public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null;
1207812077

1207912078
/**
12080-
@@ -50,5 +50,5 @@ interface NormalizerInterface
12079+
@@ -49,5 +49,5 @@ interface NormalizerInterface
1208112080
* @return bool
1208212081
*/
12083-
- public function supportsNormalization(mixed $data, string $format = null /* , array $context = [] */);
12084-
+ public function supportsNormalization(mixed $data, string $format = null /* , array $context = [] */): bool;
12082+
- public function supportsNormalization(mixed $data, string $format = null, array $context = []);
12083+
+ public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool;
1208512084

1208612085
/**
1208712086
diff --git a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
12088-
index 357c36426e..f4423f47f4 100644
12087+
index af530f8d3d..dd672812f1 100644
1208912088
--- a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
1209012089
+++ b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
12091-
@@ -146,5 +146,5 @@ class ObjectNormalizer extends AbstractObjectNormalizer
12090+
@@ -136,5 +136,5 @@ class ObjectNormalizer extends AbstractObjectNormalizer
1209212091
* @return void
1209312092
*/
1209412093
- protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = [])
1209512094
+ protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = []): void
1209612095
{
1209712096
try {
1209812097
diff --git a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php
12099-
index ec12db9bb2..d3b7f036a8 100644
12098+
index cfe93bc10b..7f1d8e5e13 100644
1210012099
--- a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php
1210112100
+++ b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php
12102-
@@ -187,5 +187,5 @@ class PropertyNormalizer extends AbstractObjectNormalizer
12101+
@@ -171,5 +171,5 @@ class PropertyNormalizer extends AbstractObjectNormalizer
1210312102
* @return void
1210412103
*/
1210512104
- protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = [])

UPGRADE-7.0.md

+6
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ Serializer
4747

4848
* Remove denormalization support for `AbstractUid` in `UidNormalizer`, use one of `AbstractUid` child class instead
4949
* Denormalizing to an abstract class in `UidNormalizer` now throws an `\Error`
50+
* Remove `ContextAwareDenormalizerInterface`, use `DenormalizerInterface` instead
51+
* Remove `ContextAwareNormalizerInterface`, use `NormalizerInterface` instead
52+
* Remove `CacheableSupportsMethodInterface`, use `NormalizerInterface` and `DenormalizerInterface` instead
53+
* First argument of `Symfony\Component\Validator\Mapping\ClassMetadata::setSerializedName()` is now required
54+
* Third argument `array $context = []` of the `Symfony\Component\Serializer\Normalizer\NormalizerInterface::supportsNormalization()` is now required
55+
* Forth argument `array $context = []` of the `Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization()` is now required

src/Symfony/Component/Serializer/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ CHANGELOG
66

77
* Remove denormalization support for `AbstractUid` in `UidNormalizer`, use one of `AbstractUid` child class instead
88
* Denormalizing to an abstract class in `UidNormalizer` now throws an `\Error`
9+
* Remove `ContextAwareDenormalizerInterface`, use `DenormalizerInterface` instead
10+
* Remove `ContextAwareNormalizerInterface`, use `NormalizerInterface` instead
11+
* Remove `CacheableSupportsMethodInterface`, use `NormalizerInterface` and `DenormalizerInterface` instead
12+
* First argument of `Symfony\Component\Validator\Mapping\ClassMetadata::setSerializedName()` is now required
13+
* Third argument `array $context = []` of the `Symfony\Component\Serializer\Normalizer\NormalizerInterface::supportsNormalization()` is now required
14+
* Forth argument `array $context = []` of the `Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization()` is now required
915

1016
6.3
1117
---

src/Symfony/Component/Serializer/Debug/TraceableNormalizer.php

+1-20
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Serializer\Debug;
1313

1414
use Symfony\Component\Serializer\DataCollector\SerializerDataCollector;
15-
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
1615
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
1716
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
1817
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
@@ -27,24 +26,16 @@
2726
*
2827
* @internal
2928
*/
30-
class TraceableNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, NormalizerAwareInterface, DenormalizerAwareInterface, CacheableSupportsMethodInterface
29+
class TraceableNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, NormalizerAwareInterface, DenormalizerAwareInterface
3130
{
3231
public function __construct(
3332
private NormalizerInterface|DenormalizerInterface $normalizer,
3433
private SerializerDataCollector $dataCollector,
3534
) {
36-
if (!method_exists($normalizer, 'getSupportedTypes')) {
37-
trigger_deprecation('symfony/serializer', '6.3', 'Not implementing the "NormalizerInterface::getSupportedTypes()" in "%s" is deprecated.', get_debug_type($normalizer));
38-
}
3935
}
4036

4137
public function getSupportedTypes(?string $format): array
4238
{
43-
// @deprecated remove condition in 7.0
44-
if (!method_exists($this->normalizer, 'getSupportedTypes')) {
45-
return ['*' => $this->normalizer instanceof CacheableSupportsMethodInterface && $this->normalizer->hasCacheableSupportsMethod()];
46-
}
47-
4839
return $this->normalizer->getSupportedTypes($format);
4940
}
5041

@@ -127,16 +118,6 @@ public function setDenormalizer(DenormalizerInterface $denormalizer): void
127118
$this->normalizer->setDenormalizer($denormalizer);
128119
}
129120

130-
/**
131-
* @deprecated since Symfony 6.3, use "getSupportedTypes()" instead
132-
*/
133-
public function hasCacheableSupportsMethod(): bool
134-
{
135-
trigger_deprecation('symfony/serializer', '6.3', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__);
136-
137-
return $this->normalizer instanceof CacheableSupportsMethodInterface && $this->normalizer->hasCacheableSupportsMethod();
138-
}
139-
140121
/**
141122
* Proxies all method calls to the original normalizer.
142123
*/

src/Symfony/Component/Serializer/Debug/TraceableSerializer.php

-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Serializer\DataCollector\SerializerDataCollector;
1515
use Symfony\Component\Serializer\Encoder\DecoderInterface;
1616
use Symfony\Component\Serializer\Encoder\EncoderInterface;
17-
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
1817
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
1918
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
2019
use Symfony\Component\Serializer\SerializerInterface;
@@ -34,9 +33,6 @@ public function __construct(
3433
private SerializerInterface&NormalizerInterface&DenormalizerInterface&EncoderInterface&DecoderInterface $serializer,
3534
private SerializerDataCollector $dataCollector,
3635
) {
37-
if (!method_exists($serializer, 'getSupportedTypes')) {
38-
trigger_deprecation('symfony/serializer', '6.3', 'Not implementing the "NormalizerInterface::getSupportedTypes()" in "%s" is deprecated.', get_debug_type($serializer));
39-
}
4036
}
4137

4238
public function serialize(mixed $data, string $format, array $context = []): string
@@ -131,11 +127,6 @@ public function decode(string $data, string $format, array $context = []): mixed
131127

132128
public function getSupportedTypes(?string $format): array
133129
{
134-
// @deprecated remove condition in 7.0
135-
if (!method_exists($this->serializer, 'getSupportedTypes')) {
136-
return ['*' => $this->serializer instanceof CacheableSupportsMethodInterface && $this->serializer->hasCacheableSupportsMethod()];
137-
}
138-
139130
return $this->serializer->getSupportedTypes($format);
140131
}
141132

src/Symfony/Component/Serializer/Mapping/AttributeMetadata.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,8 @@ public function getMaxDepth(): ?int
110110
return $this->maxDepth;
111111
}
112112

113-
public function setSerializedName(string $serializedName = null): void
113+
public function setSerializedName(?string $serializedName): void
114114
{
115-
if (1 > \func_num_args()) {
116-
trigger_deprecation('symfony/serializer', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
117-
}
118-
119115
$this->serializedName = $serializedName;
120116
}
121117

src/Symfony/Component/Serializer/Mapping/ClassMetadata.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,8 @@ public function getClassDiscriminatorMapping(): ?ClassDiscriminatorMapping
9090
return $this->classDiscriminatorMapping;
9191
}
9292

93-
public function setClassDiscriminatorMapping(ClassDiscriminatorMapping $mapping = null): void
93+
public function setClassDiscriminatorMapping(?ClassDiscriminatorMapping $mapping): void
9494
{
95-
if (1 > \func_num_args()) {
96-
trigger_deprecation('symfony/serializer', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
97-
}
9895
$this->classDiscriminatorMapping = $mapping;
9996
}
10097

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

+1-11
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @author Kévin Dunglas <dunglas@gmail.com>
3030
*/
31-
abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, CacheableSupportsMethodInterface
31+
abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface
3232
{
3333
use ObjectToPopulateTrait;
3434
use SerializerAwareTrait;
@@ -156,16 +156,6 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory
156156
}
157157
}
158158

159-
/**
160-
* @deprecated since Symfony 6.3, use "getSupportedTypes()" instead
161-
*/
162-
public function hasCacheableSupportsMethod(): bool
163-
{
164-
trigger_deprecation('symfony/serializer', '6.3', 'The "%s()" method is deprecated, use "getSupportedTypes()" instead.', __METHOD__);
165-
166-
return false;
167-
}
168-
169159
/**
170160
* Detects if the configured circular reference limit is reached.
171161
*

0 commit comments

Comments
 (0)
0