Skip to content

Commit

Permalink
workaround for "node no longer exists"
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasmarxrose committed May 16, 2022
1 parent 0207dc2 commit 4cd3873
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/XmlDeserializationVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,18 @@ public function visitProperty(PropertyMetadata $metadata, $data)
}

if ($metadata->xmlAttribute) {
$attributes = $data->attributes($metadata->xmlNamespace);
if (isset($attributes[$name])) {
if (!$metadata->type) {
throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name);
if( $data->getName() !== "") {
$attributes = $data->attributes($metadata->xmlNamespace);
if (isset($attributes[$name])) {
if (!$metadata->type) {
throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name);
}

return $this->navigator->accept($attributes[$name], $metadata->type);
}

return $this->navigator->accept($attributes[$name], $metadata->type);
throw new NotAcceptableException();
}

throw new NotAcceptableException();
}

if ($metadata->xmlValue) {
Expand Down Expand Up @@ -353,7 +355,12 @@ public function visitProperty(PropertyMetadata $metadata, $data)
}

if ($metadata->xmlNamespace) {
$node = $data->children($metadata->xmlNamespace)->$name;
if (empty($data->children($metadata->xmlNamespace)->$name)) {
$node = new \SimpleXMLElement("<body></body>");
}
else{
$node = $data->children($metadata->xmlNamespace)->$name;
}
if (!$node->count()) {
throw new NotAcceptableException();
}
Expand Down

0 comments on commit 4cd3873

Please sign in to comment.