From b18fdbbc58ee1a88b79e9898227792c48e025b75 Mon Sep 17 00:00:00 2001 From: Sergey Gonchar Date: Sat, 1 Apr 2023 12:54:47 +0300 Subject: [PATCH] fix implements HandlerRegistryInterface.getHandler --- Serializer/JMSHandlerRegistry.php | 71 ++++++++++++++-------------- Serializer/JMSHandlerRegistryV2.php | 72 +++++++++++++++-------------- 2 files changed, 73 insertions(+), 70 deletions(-) diff --git a/Serializer/JMSHandlerRegistry.php b/Serializer/JMSHandlerRegistry.php index e11044daa..42eebbbdc 100644 --- a/Serializer/JMSHandlerRegistry.php +++ b/Serializer/JMSHandlerRegistry.php @@ -23,39 +23,40 @@ */ class JMSHandlerRegistry implements HandlerRegistryInterface { - private $registry; - - public function __construct(HandlerRegistryInterface $registry) - { - $this->registry = $registry; - } - - /** - * {@inheritdoc} - */ - public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void - { - $this->registry->registerSubscribingHandler($handler); - } - - /** - * {@inheritdoc} - */ - public function registerHandler($direction, $typeName, $format, $handler): void - { - $this->registry->registerHandler($direction, $typeName, $format, $handler); - } - - /** - * {@inheritdoc} - */ - public function getHandler($direction, $typeName, $format) - { - do { - $handler = $this->registry->getHandler($direction, $typeName, $format); - if (null !== $handler) { - return $handler; - } - } while ($typeName = get_parent_class($typeName)); - } + private $registry; + + public function __construct(HandlerRegistryInterface $registry) + { + $this->registry = $registry; + } + + public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void + { + $this->registry->registerSubscribingHandler($handler); + } + + /** + * {@inheritdoc} + */ + public function registerHandler($direction, $typeName, $format, $handler): void + { + $this->registry->registerHandler($direction, $typeName, $format, $handler); + } + + /** + * {@inheritdoc} + * + * @return callable|object + */ + public function getHandler($direction, $typeName, $format) + { + do { + $handler = $this->registry->getHandler($direction, $typeName, $format); + if (null !== $handler) { + return $handler; + } + } while ($typeName = get_parent_class($typeName)); + + return null; + } } diff --git a/Serializer/JMSHandlerRegistryV2.php b/Serializer/JMSHandlerRegistryV2.php index 6ee179e6e..3db3b6239 100644 --- a/Serializer/JMSHandlerRegistryV2.php +++ b/Serializer/JMSHandlerRegistryV2.php @@ -23,39 +23,41 @@ */ final class JMSHandlerRegistryV2 implements HandlerRegistryInterface { - private $registry; - - public function __construct(HandlerRegistryInterface $registry) - { - $this->registry = $registry; - } - - /** - * {@inheritdoc} - */ - public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void - { - $this->registry->registerSubscribingHandler($handler); - } - - /** - * {@inheritdoc} - */ - public function registerHandler(int $direction, string $typeName, string $format, $handler): void - { - $this->registry->registerHandler($direction, $typeName, $format, $handler); - } - - /** - * {@inheritdoc} - */ - public function getHandler(int $direction, string $typeName, string $format) - { - do { - $handler = $this->registry->getHandler($direction, $typeName, $format); - if (null !== $handler) { - return $handler; - } - } while ($typeName = get_parent_class($typeName)); - } + private $registry; + + public function __construct(HandlerRegistryInterface $registry) + { + $this->registry = $registry; + } + + public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void + { + $this->registry->registerSubscribingHandler($handler); + } + + /** + * {@inheritdoc} + */ + public function registerHandler(int $direction, string $typeName, string $format, $handler): void + { + $this->registry->registerHandler($direction, $typeName, $format, $handler); + } + + + /** + * {@inheritdoc} + * + * @return callable|object + */ + public function getHandler(int $direction, string $typeName, string $format) + { + do { + $handler = $this->registry->getHandler($direction, $typeName, $format); + if (null !== $handler) { + return $handler; + } + } while ($typeName = get_parent_class($typeName)); + + return null; + } }