Skip to content

Commit 4dea4e0

Browse files
committed
add deprecation layer
1 parent 3701332 commit 4dea4e0

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
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
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use PHPUnit\Framework\TestCase;
1616
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
1717
use Symfony\Component\Serializer\Normalizer\UnwrappingDenormalizer;
18-
use Symfony\Component\Serializer\Serializer;
1918
use Symfony\Component\Serializer\Tests\Normalizer\Features\ObjectDummy;
2019

2120
/**

src/Symfony/Component/Serializer/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"require": {
1919
"php": ">=8.2",
20-
"symfony/polyfill-ctype": "~1.8"
20+
"symfony/polyfill-ctype": "~1.8",
21+
"symfony/deprecation-contracts": "^3.4@dev"
2122
},
2223
"require-dev": {
2324
"phpdocumentor/reflection-docblock": "^3.2|^4.0|^5.0",

0 commit comments

Comments
 (0)