8000 [Serializer] Remove abstract uid denormalization code · symfony/symfony@1506a6d · GitHub
[go: up one dir, main page]

Skip to content

Commit 1506a6d

Browse files
committed
[Serializer] Remove abstract uid denormalization code
1 parent 14431f1 commit 1506a6d

File tree

4 files changed

+11
-49
lines changed

4 files changed

+11
-49
lines changed

UPGRADE-7.0.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ Symfony 6.4 and Symfony 7.0 will be released simultaneously at the end of Novemb
55
release process, both versions will have the same features, but Symfony 7.0 won't include any deprecated features.
66
To upgrade, make sure to resolve all deprecation notices.
77

8-
This file will be updated on the branch 7.0 for each deprecated feature that is removed.
8+
Serializer
9+
----------
10+
11+
* Remove denormalization support for `AbstractUid` in `UidNormalizer`, use one of `AbstractUid` child class instead
12+
* Denormalizing to an abstract class in `UidNormalizer` now throws a `NotNormalizableValueException`

src/Symfony/Component/Serializer/CHANGELOG.md

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

4+
7.0
5+
---
6+
7+
* Remove denormalization support for `AbstractUid` in `UidNormalizer`, use one of `AbstractUid` child class instead
8+
* Denormalizing to an abstract class in `UidNormalizer` now throws a `NotNormalizableValueException`
9+
410
6.3
511
---
612

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,32 +70,14 @@ public function supportsNormalization(mixed $data, string $format = null, array
7070
public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed
7171
{
7272
try {
73-
if (AbstractUid::class === $type) {
74-
trigger_deprecation('symfony/serializer', '6.1', 'Denormalizing to an abstract class in "%s" is deprecated.', __CLASS__);
75-
76-
return Uuid::fromString($data);
77-
}
78-
7973
return $type::fromString($data);
8074
} catch (\InvalidArgumentException|\TypeError) {
8175
throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The data is not a valid "%s" string representation.', $type), $data, [Type::BUILTIN_TYPE_STRING], $context['deserialization_path'] ?? null, true);
82-
} catch (\Error $e) { // @deprecated remove this catch block in 7.0
83-
if (str_starts_with($e->getMessage(), 'Cannot instantiate abstract class')) {
84-
return $this->denormalize($data, AbstractUid::class, $format, $context);
85-
}
86-
87-
throw $e;
8876
}
8977
}
9078

9179
public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool
9280
{
93-
if (AbstractUid::class === $type) {
94-
trigger_deprecation('symfony/serializer', '6.1', 'Supporting denormalization for the "%s" type in "%s" is deprecated, use one of "%s" child class instead.', AbstractUid::class, __CLASS__, AbstractUid::class);
95-
96-
return true;
97-
}
98-
9981
return is_subclass_of($type, AbstractUid::class, true);
10082
}
10183

src/Symfony/Component/Serializer/Tests/Normalizer/UidNormalizerTest.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,6 @@ public function testSupportsDenormalizationForNonUid()
146146
$this->assertFalse($this->normalizer->supportsDenormalization('foo', \stdClass::class));
147147
}
148148

149-
/**
150-
* @group legacy
151-
*/
152-
public function testSupportOurAbstractUid()
153-
{
154-
$this->expectDeprecation('Since symfony/serializer 6.1: Supporting denormalization for the "Symfony\Component\Uid\AbstractUid" type in "Symfony\Component\Serializer\Normalizer\UidNormalizer" is deprecated, use one of "Symfony\Component\Uid\AbstractUid" child class instead.');
155-
156-
$this->assertTrue($this->normalizer->supportsDenormalization('1ea6ecef-eb9a-66fe-b62b-957b45f17e43', AbstractUid::class));
157-
}
158-
159149
public function testSupportCustomAbstractUid()
160150
{
161151
$this->assertTrue($this->normalizer->supportsDenormalization('ccc', TestAbstractCustomUid::class));
@@ -169,26 +159,6 @@ public function testDenormalize($uuidString, $class)
169159
$this->assertEquals($class::fromString($uuidString), $this->normalizer->denormalize($uuidString, $class));
170160
}
171161

172-
/**
173-
* @group legacy
174-
*/
175-
public function testDenormalizeOurAbstractUid()
176-
{
177-
$this->expectDeprecation('Since symfony/serializer 6.1: Denormalizing to an abstract class in "Symfony\Component\Serializer\Normalizer\UidNormalizer" is deprecated.');
178-
179-
$this->assertEquals(Uuid::fromString($uuidString = '1ea6ecef-eb9a-66fe-b62b-957b45f17e43'), $this->normalizer->denormalize($uuidString, AbstractUid::class));
180-
}
181-
182-
/**
183-
* @group legacy
184-
*/
185-
public function testDenormalizeCustomAbstractUid()
186-
{
187-
$this->expectDeprecation('Since symfony/serializer 6.1: Denormalizing to an abstract class in "Symfony\Component\Serializer\Normalizer\UidNormalizer" is deprecated.');
188-
189-
$this->assertEquals(Uuid::fromString($uuidString = '1ea6ecef-eb9a-66fe-b62b-957b45f17e43'), $this->normalizer->denormalize($uuidString, TestAbstractCustomUid::class));
190-
}
191-
192162
public function testNormalizeWithNormalizationFormatPassedInConstructor()
193163
{
194164
$uidNormalizer = new UidNormalizer([

0 commit comments

Comments
 (0)
0