Skip to content

Commit 3c28fa4

Browse files
committed
[Serializer] Remove BC layer
1 parent 2a2c825 commit 3c28fa4

Some content is hidden

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

45 files changed

+199
-543
lines changed

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

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11875,84 +11875,83 @@ index b684fddb2f..ade2242791 100644
1187511875
{
1187611876
return $this->data;
1187711877
diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
11878-
index 079b1e7a9e..e3cfe43e67 100644
11878+
index efe4a6e0e1..fbf291af7e 100644
1187911879
--- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
1188011880
+++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
11881-
@@ -221,5 +221,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
11881+
@@ -211,5 +211,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
1188211882
* @throws LogicException if the 'allow_extra_attributes' context variable is false and no class metadata factory is provided
1188311883
*/
1188411884
- protected function getAllowedAttributes(string|object $classOrObject, array $context, bool $attributesAsString = false)
1188511885
+ protected function getAllowedAttributes(string|object $classOrObject, array $context, bool $attributesAsString = false): array|bool
1188611886
{
1188711887
$allowExtraAttributes = $context[self::ALLOW_EXTRA_ATTRIBUTES] ?? $this->defaultContext[self::ALLOW_EXTRA_ATTRIBUTES];
11888-
@@ -271,5 +271,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
11888+
@@ -261,5 +261,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
1188911889
* @return bool
1189011890
*/
1189111891
- protected function isAllowedAttribute(object|string $classOrObject, string $attribute, string $format = null, array $context = [])
1189211892
+ protected function isAllowedAttribute(object|string $classOrObject, string $attribute, string $format = null, array $context = []): bool
1189311893
{
1189411894
$ignoredAttributes = $context[self::IGNORED_ATTRIBUTES] ?? $this->defaultContext[self::IGNORED_ATTRIBUTES];
11895-
@@ -322,5 +322,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
11895+
@@ -312,5 +312,5 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
1189611896
* @throws MissingConstructorArgumentsException
1189711897
*/
1189811898
- protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null)
1189911899
+ protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null): object
1190011900
{
1190111901
if (null !== $object = $this->extractObjectToPopulate($class, $context, self::OBJECT_TO_POPULATE)) {
1190211902
diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
11903-
index 0dba039bc0..576445825e 100644
11903+
index 4f061239b9..85c9f17a83 100644
1190411904
--- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
1190511905
+++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
11906-
@@ -143,5 +143,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11906+
@@ -141,5 +141,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1190711907
* @return bool
1190811908
*/
11909-
- public function supportsNormalization(mixed $data, string $format = null /* , array $context = [] */)
11910-
+ public function supportsNormalization(mixed $data, string $format = null /* , array $context = [] */): bool
11909+
- public function supportsNormalization(mixed $data, string $format = null, array $context = [])
11910+
+ public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool
1191111911
{
1191211912
return \is_object($data) && !$data instanceof \Traversable;
11913-
@@ -151,5 +151,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11913+
@@ -149,5 +149,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1191411914
* @return array|string|int|float|bool|\ArrayObject|null
1191511915
*/
1191611916
- public function normalize(mixed $object, string $format = null, array $context = [])
1191711917
+ public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
1191811918
{
1191911919
if (!isset($context['cache_key'])) {
11920-
@@ -235,5 +235,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11920+
@@ -233,5 +233,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1192111921
* @return object
1192211922
*/
1192311923
- protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null)
1192411924
+ protected function instantiateObject(array &$data, string $class, array &$context, \ReflectionClass $reflectionClass, array|bool $allowedAttributes, string $format = null): object
1192511925
{
1192611926
if ($class !== $mappedClass = $this->getMappedClass($data, $class, $context)) {
11927-
@@ -286,5 +286,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11927+
@@ -284,5 +284,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1192811928
* @return string[]
1192911929
*/
1193011930
- abstract protected function extractAttributes(object $object, string $format = null, array $context = []);
1193111931
+ abstract protected function extractAttributes(object $object, string $format = null, array $context = []): array;
1193211932

1193311933
/**
11934-
@@ -293,5 +293,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11934+
@@ -291,10 +291,10 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1193511935
* @return mixed
1193611936
*/
1193711937
- abstract protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = []);
1193811938
+ abstract protected function getAttributeValue(object $object, string $attribute, string $format = null, array $context = []): mixed;
1193911939

1194011940
/**
11941-
@@ -300,5 +300,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1194211941
* @return bool
1194311942
*/
11944-
- public function supportsDenormalization(mixed $data, string $type, string $format = null /* , array $context = [] */)
11945-
+ public function supportsDenormalization(mixed $data, string $type, string $format = null /* , array $context = [] */): bool
11943+
- public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = [])
11944+
+ public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool
1194611945
{
1194711946
return class_exists($type) || (interface_exists($type, false) && null !== $this->classDiscriminatorResolver?->getMappingForClass($type));
11948-
@@ -308,5 +308,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11947+
@@ -304,5 +304,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1194911948
* @return mixed
1195011949
*/
1195111950
- public function denormalize(mixed $data, string $type, string $format = null, array $context = [])
1195211951
+ public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed
1195311952
{
1195411953
if (!isset($context['cache_key'])) {
11955-
@@ -414,5 +414,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
11954+
@@ -410,5 +410,5 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
1195611955
* @return void
1195711956
*/
1195811957
- abstract protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = []);
@@ -11980,7 +11979,7 @@ index 48e8c3fb54..a71c3ea476 100644
1198011979
+ public function setDenormalizer(DenormalizerInterface $denormalizer): void;
1198111980
}
1198211981
diff --git a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php
11983-
index 4edb70096d..8c844785db 100644
11982+
index e4d0ed9123..8a39d97f36 100644
1198411983
--- a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php
1198511984
+++ b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php
1198611985
@@ -47,5 +47,5 @@ interface DenormalizerInterface
@@ -11990,18 +11989,18 @@ index 4edb70096d..8c844785db 100644
1199011989
+ public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed;
1199111990

1199211991
/**
11993-
@@ -59,5 +59,5 @@ interface DenormalizerInterface
11992+
@@ -58,5 +58,5 @@ interface DenormalizerInterface
1199411993
* @return bool
1199511994
*/
11996-
- public function supportsDenormalization(mixed $data, string $type, string $format = null /* , array $context = [] */);
11997-
+ public function supportsDenormalization(mixed $data, string $type, string $format = null /* , array $context = [] */): bool;
11995+
- public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []);
11996+
+ public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool;
1199811997

1199911998
/**
1200011999
diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
12001-
index 063d34ea59..fb10337d35 100644
12000+
index 3d11567a7b..22e873b151 100644
1200212001
--- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
1200312002
+++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
12004-
@@ -147,5 +147,5 @@ class GetSetMethodNormalizer extends AbstractObjectNormalizer
12003+
@@ -131,5 +131,5 @@ class GetSetMethodNormalizer extends AbstractObjectNormalizer
1200512004
* @return void
1200612005
*/
1200712006
- protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = [])
@@ -12030,7 +12029,7 @@ index 40a4fa0e8c..a1e2749aae 100644
1203012029
{
1203112030
$this->normalizer = $normalizer;
1203212031
diff --git a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php
12033-
index 40779de316..105cf99b06 100644
12032+
index 01979d6fcf..e918540c83 100644
1203412033
--- a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php
1203512034
+++ b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php
1203612035
@@ -39,5 +39,5 @@ interface NormalizerInterface
@@ -12040,29 +12039,29 @@ index 40779de316..105cf99b06 100644
1204012039
+ public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null;
1204112040

1204212041
/**
12043-
@@ -50,5 +50,5 @@ interface NormalizerInterface
12042+
@@ -49,5 +49,5 @@ interface NormalizerInterface
1204412043
* @return bool
1204512044
*/
12046-
- public function supportsNormalization(mixed $data, string $format = null /* , array $context = [] */);
12047-
+ public function supportsNormalization(mixed $data, string $format = null /* , array $context = [] */): bool;
12045+
- public function supportsNormalization(mixed $data, string $format = null, array $context = []);
12046+
+ public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool;
1204812047

1204912048
/**
1205012049
diff --git a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
12051-
index 357c36426e..f4423f47f4 100644
12050+
index af530f8d3d..dd672812f1 100644
1205212051
--- a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
1205312052
+++ b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
12054-
@@ -146,5 +146,5 @@ class ObjectNormalizer extends AbstractObjectNormalizer
12053+
@@ -136,5 +136,5 @@ class ObjectNormalizer extends AbstractObjectNormalizer
1205512054
* @return void
1205612055
*/
1205712056
- protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = [])
1205812057
+ protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = []): void
1205912058
{
1206012059
try {
1206112060
diff --git a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php
12062-
index ec12db9bb2..d3b7f036a8 100644
12061+
index cfe93bc10b..7f1d8e5e13 100644
1206312062
--- a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php
1206412063
+++ b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php
12065-
@@ -187,5 +187,5 @@ class PropertyNormalizer extends AbstractObjectNormalizer
12064+
@@ -171,5 +171,5 @@ class PropertyNormalizer extends AbstractObjectNormalizer
1206612065
* @return void
1206712066
*/
1206812067
- protected function setAttributeValue(object $object, string $attribute, mixed $value, string $format = null, array $context = [])

UPGRADE-7.0.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ Serializer
3131

3232
* Remove denormalization support for `AbstractUid` in `UidNormalizer`, use one of `AbstractUid` child class instead
3333
* Denormalizing to an abstract class in `UidNormalizer` now throws an `\Error`
34+
* Remove `ContextAwareDenormalizerInterface`, use `DenormalizerInterface` instead
35+
* Remove `ContextAwareNormalizerInterface`, use `NormalizerInterface` instead
36+
* Remove `CacheableSupportsMethodInterface`, use `NormalizerInterface` and `DenormalizerInterface` instead
37+
* First argument of `Symfony\Component\Validator\Mapping\ClassMetadata::setSerializedName()` is now required
38+
* Third argument `array $context = []` of the `Symfony\Component\Serializer\Normalizer\NormalizerInterface::supportsNormalization()` is now required
39+
* Forth argument `array $context = []` of the `Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization()` is now required

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

Lines changed: 5 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 DenormalizerInterface, NormalizerInterface
2626
{
2727
use NormalizerAwareTrait;
2828

@@ -45,6 +45,9 @@ public function normalize(mixed $object, string $format = null, array $context =
4545
return $normalized;
4646
}
4747

48+
/**
49+
* @return array<class-string|'*'|'object'|string, bool|null>
50+
*/
4851
public function getSupportedTypes(?string $format): array
4952
{
5053
return [

src/Symfony/Component/Serializer/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
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

Lines changed: 4 additions & 20 deletions
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,19 @@
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

37+
/**
38+
* @return array<class-string|'*'|'object'|string, bool|null>
39+
*/
4140
public function getSupportedTypes(?string $format): array
4241
{
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-
4842
return $this->normalizer->getSupportedTypes($format);
4943
}
5044

@@ -127,16 +121,6 @@ public function setDenormalizer(DenormalizerInterface $denormalizer): void
127121
$this->normalizer->setDenormalizer($denormalizer);
128122
}
129123

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-
140124
/**
141125
* Proxies all method calls to the original normalizer.
142126
*/

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

Lines changed: 3 additions & 9 deletions
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
@@ -129,13 +125,11 @@ public function decode(string $data, string $format, array $context = []): mixed
129125
return $result;
130126
}
131127

128+
/**
129+
* @return array<class-string|'*'|'object'|string, bool|null>
130+
*/
132131
public function getSupportedTypes(?string $format): array
133132
{
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-
139133
return $this->serializer->getSupportedTypes($format);
140134
}
141135

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

Lines changed: 1 addition & 5 deletions
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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy