Skip to content

Commit 94663b7

Browse files
committed
add deprecation layer
1 parent 3701332 commit 94663b7

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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.1
5+
---
6+
7+
* Let `UnwrappingDenormalizer` implement `DenormalizerAwareInterface` instead of `SerializerAwareInterface`
8+
* Deprecate method `UnwrappingDenormalizer::setSerializer()`, use `UnwrappingDenormalizer::setDenormalizer()` instead
9+
410
7.0
511
---
612

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
use Symfony\Component\PropertyAccess\PropertyAccess;
1515
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
1616
use Symfony\Component\Serializer\Exception\LogicException;
17-
use Symfony\Component\Serializer\SerializerAwareInterface;
18-
use Symfony\Component\Serializer\SerializerAwareTrait;
17+
use Symfony\Component\Serializer\SerializerInterface;
1918

2019
/**
2120
* @author Eduard Bulava <bulavaeduard@gmail.com>
@@ -58,4 +57,15 @@ public function supportsDenormalization(mixed $data, string $type, string $forma
5857
{
5958
return \array_key_exists(self::UNWRAP_PATH, $context) && !isset($context['unwrapped']);
6059
}
60+
61+
public function setSerializer(SerializerInterface $serializer): void
62+
{
63+
trigger_deprecation('symfony/serializer', '7.1', 'The "%s()" method is deprecated, use "setDenormalizer()" instead.', __METHOD__);
64+
65+
if (!$serializer instanceof DenormalizerInterface) {
66+
throw new LogicException(sprintf('Cannot set denormalizer because the injected serializer does not implement the "%s".', DenormalizerInterface::class));
67+
}
68+
69+
$this->setDenormalizer($serializer);
70+
}
6171
}

0 commit comments

Comments
 (0)