diff --git a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php index dd64c9dcab193..7e67a31a91ce7 100644 --- a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php @@ -28,6 +28,7 @@ public function getSupportedTypes(?string $format): array { return [ NormalizableInterface::class => __CLASS__ === static::class || $this->hasCacheableSupportsMethod(), + DenormalizableInterface::class => __CLASS__ === static::class || $this->hasCacheableSupportsMethod(), ]; } diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php index 914458fb4225c..f4a164dc5b3f1 100644 --- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -50,6 +50,7 @@ use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummy; use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummyFirstChild; use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummySecondChild; +use Symfony\Component\Serializer\Tests\Fixtures\DenormalizableDummy; use Symfony\Component\Serializer\Tests\Fixtures\DummyFirstChildQuux; use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageInterface; use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageNumberOne; @@ -120,6 +121,14 @@ public function testDenormalizeNoMatch() $serializer->denormalize('foo', 'stdClass'); } + public function testDenormalizeOnObjectThatOnlySupportsDenormalization() + { + $serializer = new Serializer([new CustomNormalizer()]); + + $obj = $serializer->denormalize('foo', (new DenormalizableDummy())::class, 'xml'); + $this->assertInstanceOf(DenormalizableDummy::class, $obj); + } + public function testDenormalizeOnNormalizer() { $this->expectException(UnexpectedValueException::class); 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