Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a0a3ce1

Browse filesBrowse files
author
Petar Obradović
committed
[Serializer] Fix ignoring objects that only implement DenormalizableInterface
1 parent e5c5a51 commit a0a3ce1
Copy full SHA for a0a3ce1

File tree

2 files changed

+10
-0
lines changed
Filter options

2 files changed

+10
-0
lines changed

‎src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function getSupportedTypes(?string $format): array
2828
{
2929
return [
3030
NormalizableInterface::class => __CLASS__ === static::class || $this->hasCacheableSupportsMethod(),
31+
DenormalizableInterface::class => __CLASS__ === static::class || $this->hasCacheableSupportsMethod(),
3132
];
3233
}
3334

‎src/Symfony/Component/Serializer/Tests/SerializerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/SerializerTest.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummy;
5151
use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummyFirstChild;
5252
use Symfony\Component\Serializer\Tests\Fixtures\Annotations\AbstractDummySecondChild;
53+
use Symfony\Component\Serializer\Tests\Fixtures\DenormalizableDummy;
5354
use Symfony\Component\Serializer\Tests\Fixtures\DummyFirstChildQuux;
5455
use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageInterface;
5556
use Symfony\Component\Serializer\Tests\Fixtures\DummyMessageNumberOne;
@@ -120,6 +121,14 @@ public function testDenormalizeNoMatch()
120121
$serializer->denormalize('foo', 'stdClass');
121122
}
122123

124+
public function testDenormalizeOnObjectThatOnlySupportsDenormalization()
125+
{
126+
$serializer = new Serializer([new CustomNormalizer()]);
127+
128+
$obj = $serializer->denormalize('foo', (new DenormalizableDummy())::class, 'xml');
129+
$this->assertInstanceOf(DenormalizableDummy::class, $obj);
130+
}
131+
123132
public function testDenormalizeOnNormalizer()
124133
{
125134
$this->expectException(UnexpectedValueException::class);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.