Skip to content

Commit

Permalink
Merge pull request #1 from rvdbogerd/use-interfaces-instead-of-implem…
Browse files Browse the repository at this point in the history
…entation

Use VisitorInterface instead of specific implementation typehints
  • Loading branch information
goetas authored Jan 12, 2021
2 parents 063c827 + 95b0595 commit 3cda88b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Headers/Handler/HeaderHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
use JMS\Serializer\Handler\SubscribingHandlerInterface;
use JMS\Serializer\Metadata\StaticPropertyMetadata;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\XmlDeserializationVisitor;
use JMS\Serializer\XmlSerializationVisitor;
use JMS\Serializer\Visitor\DeserializationVisitorInterface;
use JMS\Serializer\Visitor\SerializationVisitorInterface;

class HeaderHandler implements SubscribingHandlerInterface, EventSubscriberInterface
{
Expand Down Expand Up @@ -89,7 +89,7 @@ public function ensureHeaderSerialized(PreSerializeEvent $event): void
/**
* @return mixed
*/
public function deserializeHeaderPlaceholder(XmlDeserializationVisitor $visitor, \SimpleXMLElement $data, array $type, DeserializationContext $context)
public function deserializeHeaderPlaceholder(DeserializationVisitorInterface $visitor, \SimpleXMLElement $data, array $type, DeserializationContext $context)
{
$type = ['name' => $type['params'][0], 'params' => []];
$headers = $context->getNavigator()->accept($data, $type, $context);
Expand All @@ -111,7 +111,7 @@ public function deserializeHeaderPlaceholder(XmlDeserializationVisitor $visitor,
/**
* @return mixed
*/
public function deserializeHeader(XmlDeserializationVisitor $visitor, \SimpleXMLElement $data, array $type, DeserializationContext $context)
public function deserializeHeader(DeserializationVisitorInterface $visitor, \SimpleXMLElement $data, array $type, DeserializationContext $context)
{
$type = ['name' => $type['params'][0], 'params' => []];

Expand All @@ -129,15 +129,15 @@ public function deserializeHeader(XmlDeserializationVisitor $visitor, \SimpleXML
return $return;
}

private function isMustUnderstand(\SimpleXMLElement $data, XmlDeserializationVisitor $visitor, DeserializationContext $context): bool
private function isMustUnderstand(\SimpleXMLElement $data, DeserializationVisitorInterface $visitor, DeserializationContext $context): bool
{
$domElement = dom_import_simplexml($data);
$mustUnderstandAttr = $domElement->getAttributeNS($domElement->ownerDocument->documentElement->namespaceURI, 'mustUnderstand');

return !empty($mustUnderstandAttr) && $visitor->visitBoolean($mustUnderstandAttr, [], $context);
}

public function serializeHeaderPlaceholder(XmlSerializationVisitor $visitor, object $data, array $type, SerializationContext $context): void
public function serializeHeaderPlaceholder(SerializationVisitorInterface $visitor, object $data, array $type, SerializationContext $context): void
{
// serialize default headers
$context->stopVisiting($data);
Expand Down Expand Up @@ -165,7 +165,7 @@ public function serializeHeaderPlaceholder(XmlSerializationVisitor $visitor, obj
}
}

public function serializeHeader(XmlSerializationVisitor $visitor, Header $header, array $type, SerializationContext $context): void
public function serializeHeader(SerializationVisitorInterface $visitor, Header $header, array $type, SerializationContext $context): void
{
$data = $header->getData();
if ($data instanceof \DOMElement) {
Expand All @@ -192,7 +192,7 @@ public function serializeHeader(XmlSerializationVisitor $visitor, Header $header
}
}

private function handleOptions(XmlSerializationVisitor $visitor, array $options): void
private function handleOptions(SerializationVisitorInterface $visitor, array $options): void
{
if (!count($options)) {
return;
Expand Down Expand Up @@ -221,7 +221,7 @@ private function setAttributeOnNode(\DOMElement $node, string $name, $value, str
$node->setAttributeNS($namespace, $prefix . ':' . $name, is_bool($value) || null === $value ? ($value ? 'true' : 'false') : $value);
}

public function deserializeFaultDetail(XmlDeserializationVisitor $visitor, \SimpleXMLElement $data, array $type, DeserializationContext $context): \SimpleXMLElement
public function deserializeFaultDetail(DeserializationVisitorInterface $visitor, \SimpleXMLElement $data, array $type, DeserializationContext $context): \SimpleXMLElement
{
return $data->children();
}
Expand Down

0 comments on commit 3cda88b

Please sign in to comment.