From 349b9bad802b30fe6479cb2bf55ce78e456634f3 Mon Sep 17 00:00:00 2001 From: andreyserdjuk <3006342+andreyserdjuk@users.noreply.github.com> Date: Wed, 20 Apr 2022 18:09:41 +0200 Subject: [PATCH] non-static QueueSubscriberInterface::getSubscribedQueues() I propose to make this accessor non-static to allow developers build more sophisticated mechanism of subscription. For example I have code: ```php abstract class AbstractConsumer implements Processor, QueueSubscriberInterface { // .... // .... public function process(Message $message, Context $context) { $event = $this->serializer->deserialize($message->getBody(), $this->eventModel(), $this->format()); try { $this->doProcessEvent($event); } catch (OperationNotSupportedException $e) { return self::REJECT; } catch (OperationFailedException $e) { return self::REQUEUE; } return self::ACK; } abstract protected function eventModel(): string; abstract protected function doProcessEvent(EventInterface $event): void; // FYI getSubscribedQueues() is implemented by child classes } ``` where `getSubscribedQueues()` is implemented by child classes. In my project I want to introduce `EventProcessorInterface`, which can process events data mapped to `eventModel()` considering `getSubscribedEvents(): string[]`. But I cannot INJECT `EventProcessorInterface` to `AbstractConsumer` and delegate `QueueSubscriberInterface::getSubscribedQueues()` to `EventProcessorInterface::getSubscribedEvents()` because it is static method! --- pkg/enqueue/Consumption/QueueSubscriberInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/enqueue/Consumption/QueueSubscriberInterface.php b/pkg/enqueue/Consumption/QueueSubscriberInterface.php index 1d7df12d5..09135d531 100644 --- a/pkg/enqueue/Consumption/QueueSubscriberInterface.php +++ b/pkg/enqueue/Consumption/QueueSubscriberInterface.php @@ -10,5 +10,5 @@ interface QueueSubscriberInterface * * @return string[] */ - public static function getSubscribedQueues(); + public function getSubscribedQueues(); }