Skip to content

Commit

Permalink
allow to control null deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed May 2, 2019
1 parent 2087b98 commit 9efa114
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/GraphNavigator/DeserializationGraphNavigator.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ public function accept($data, ?array $type = null)
// Sometimes data can convey null but is not of a null type.
// Visitors can have the power to add this custom null evaluation
// If null is explicitly allowed we should skip this
if (false === $this->shouldDeserializeNull
&& $this->visitor instanceof NullAwareVisitorInterface
if ($this->visitor instanceof NullAwareVisitorInterface
&& true === $this->visitor->isNull($data)
&& (!empty($type['nullable']) || false === $this->shouldDeserializeNull)
) {
$type = ['name' => 'NULL', 'params' => []];
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/BlogPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class BlogPost
private $metadata;

/**
* @Type("JMS\Serializer\Tests\Fixtures\Author")
* @Type("?JMS\Serializer\Tests\Fixtures\Author")
* @Groups({"post"})
* @XmlElement(namespace="http://www.w3.org/2005/Atom")
*/
Expand All @@ -100,7 +100,7 @@ class BlogPost
private $publisher;

/**
* @Type("array<JMS\Serializer\Tests\Fixtures\Tag>")
* @Type("?array<JMS\Serializer\Tests\Fixtures\Tag>")
* @XmlList(inline=true, entry="tag", namespace="http://purl.org/dc/elements/1.1/");
*/
private $tag;
Expand Down

0 comments on commit 9efa114

Please sign in to comment.