diff --git a/SnsQsConnectionFactory.php b/SnsQsConnectionFactory.php index abb154a..65812be 100644 --- a/SnsQsConnectionFactory.php +++ b/SnsQsConnectionFactory.php @@ -83,10 +83,7 @@ private function parseDsn(string $dsn): void $dsn = Dsn::parseFirst($dsn); if ('snsqs' !== $dsn->getSchemeProtocol()) { - throw new \LogicException(sprintf( - 'The given scheme protocol "%s" is not supported. It must be "snsqs"', - $dsn->getSchemeProtocol() - )); + throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "snsqs"', $dsn->getSchemeProtocol())); } $this->parseOptions($dsn->getQuery()); diff --git a/SnsQsConsumer.php b/SnsQsConsumer.php index 17ec39a..45237d1 100644 --- a/SnsQsConsumer.php +++ b/SnsQsConsumer.php @@ -44,7 +44,7 @@ public function getVisibilityTimeout(): ?int * The duration (in seconds) that the received messages are hidden from subsequent retrieve * requests after being retrieved by a ReceiveMessage request. */ - public function setVisibilityTimeout(int $visibilityTimeout = null): void + public function setVisibilityTimeout(?int $visibilityTimeout = null): void { $this->consumer->setVisibilityTimeout($visibilityTimeout); } diff --git a/SnsQsContext.php b/SnsQsContext.php index 4a71216..d26a0fc 100644 --- a/SnsQsContext.php +++ b/SnsQsContext.php @@ -189,7 +189,7 @@ private function getSnsContext(): SnsContext if (null === $this->snsContext) { $context = call_user_func($this->snsContextFactory); if (false == $context instanceof SnsContext) { - throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', SnsContext::class, is_object($context) ? get_class($context) : gettype($context))); + throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', SnsContext::class, is_object($context) ? $context::class : gettype($context))); } $this->snsContext = $context; @@ -203,7 +203,7 @@ private function getSqsContext(): SqsContext if (null === $this->sqsContext) { $context = call_user_func($this->sqsContextFactory); if (false == $context instanceof SqsContext) { - throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', SqsContext::class, is_object($context) ? get_class($context) : gettype($context))); + throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', SqsContext::class, is_object($context) ? $context::class : gettype($context))); } $this->sqsContext = $context; diff --git a/SnsQsMessage.php b/SnsQsMessage.php index c804b18..900ad91 100644 --- a/SnsQsMessage.php +++ b/SnsQsMessage.php @@ -41,7 +41,7 @@ public function __construct( string $body = '', array $properties = [], array $headers = [], - array $messageAttributes = null + ?array $messageAttributes = null, ) { $this->body = $body; $this->properties = $properties; @@ -77,7 +77,7 @@ public function setMessageAttributes(?array $messageAttributes): void * any messages sent with the same MessageDeduplicationId are accepted successfully but aren't delivered during the 5-minute * deduplication interval. For more information, see http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing. */ - public function setMessageDeduplicationId(string $id = null): void + public function setMessageDeduplicationId(?string $id = null): void { $this->messageDeduplicationId = $id; } @@ -96,7 +96,7 @@ public function getMessageDeduplicationId(): ?string * for multiple users). In this scenario, multiple readers can process the queue, but the session data * of each user is processed in a FIFO fashion. */ - public function setMessageGroupId(string $id = null): void + public function setMessageGroupId(?string $id = null): void { $this->messageGroupId = $id; } diff --git a/SnsQsProducer.php b/SnsQsProducer.php index 6bc66e8..a80e1eb 100644 --- a/SnsQsProducer.php +++ b/SnsQsProducer.php @@ -51,7 +51,7 @@ public function send(Destination $destination, Message $message): void InvalidMessageException::assertMessageInstanceOf($message, SnsQsMessage::class); if (false == $destination instanceof SnsQsTopic && false == $destination instanceof SnsQsQueue) { - throw new InvalidDestinationException(sprintf('The destination must be an instance of [%s|%s] but got %s.', SnsQsTopic::class, SnsQsQueue::class, is_object($destination) ? get_class($destination) : gettype($destination))); + throw new InvalidDestinationException(sprintf('The destination must be an instance of [%s|%s] but got %s.', SnsQsTopic::class, SnsQsQueue::class, is_object($destination) ? $destination::class : gettype($destination))); } if ($destination instanceof SnsQsTopic) { @@ -82,7 +82,7 @@ public function send(Destination $destination, Message $message): void /** * Delivery delay is supported by SQSProducer. */ - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { $this->getSqsProducer()->setDeliveryDelay($deliveryDelay); @@ -97,7 +97,7 @@ public function getDeliveryDelay(): ?int return $this->getSqsProducer()->getDeliveryDelay(); } - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { $this->getSnsProducer()->setPriority($priority); $this->getSqsProducer()->setPriority($priority); @@ -110,7 +110,7 @@ public function getPriority(): ?int return $this->getSnsProducer()->getPriority(); } - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { $this->getSnsProducer()->setTimeToLive($timeToLive); $this->getSqsProducer()->setTimeToLive($timeToLive); diff --git a/Tests/Spec/SnsQsFactoryTrait.php b/Tests/Spec/SnsQsFactoryTrait.php index efc4a70..e314c26 100644 --- a/Tests/Spec/SnsQsFactoryTrait.php +++ b/Tests/Spec/SnsQsFactoryTrait.php @@ -33,7 +33,7 @@ protected function createSnsQsContext(): SnsQsContext protected function createSnsQsQueue(string $queueName): SnsQsQueue { - $queueName = $queueName.time(); + $queueName .= time(); $this->snsQsQueue = $this->snsQsContext->createQueue($queueName); $this->snsQsContext->declareQueue($this->snsQsQueue); @@ -47,7 +47,7 @@ protected function createSnsQsQueue(string $queueName): SnsQsQueue protected function createSnsQsTopic(string $topicName): SnsQsTopic { - $topicName = $topicName.time(); + $topicName .= time(); $this->snsQsTopic = $this->snsQsContext->createTopic($topicName); $this->snsQsContext->declareTopic($this->snsQsTopic); diff --git a/Tests/Spec/SnsQsSendToAndReceiveFromQueueTest.php b/Tests/Spec/SnsQsSendToAndReceiveFromQueueTest.php index ed19918..707cab5 100644 --- a/Tests/Spec/SnsQsSendToAndReceiveFromQueueTest.php +++ b/Tests/Spec/SnsQsSendToAndReceiveFromQueueTest.php @@ -8,6 +8,7 @@ /** * @group functional + * * @retry 5 */ class SnsQsSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec diff --git a/Tests/Spec/SnsQsSendToAndReceiveNoWaitFromQueueTest.php b/Tests/Spec/SnsQsSendToAndReceiveNoWaitFromQueueTest.php index 53ae719..652766d 100644 --- a/Tests/Spec/SnsQsSendToAndReceiveNoWaitFromQueueTest.php +++ b/Tests/Spec/SnsQsSendToAndReceiveNoWaitFromQueueTest.php @@ -8,6 +8,7 @@ /** * @group functional + * * @retry 5 */ class SnsQsSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec diff --git a/Tests/Spec/SnsQsSendToTopicAndReceiveFromQueueSpec.php b/Tests/Spec/SnsQsSendToTopicAndReceiveFromQueueSpec.php index 24206c9..4a5869d 100644 --- a/Tests/Spec/SnsQsSendToTopicAndReceiveFromQueueSpec.php +++ b/Tests/Spec/SnsQsSendToTopicAndReceiveFromQueueSpec.php @@ -8,6 +8,7 @@ /** * @group functional + * * @retry 5 */ class SnsQsSendToTopicAndReceiveFromQueueSpec extends SendToTopicAndReceiveFromQueueSpec diff --git a/examples/consumer.php b/examples/consumer.php index a5303b9..37f1939 100644 --- a/examples/consumer.php +++ b/examples/consumer.php @@ -12,7 +12,7 @@ if ($autoload) { require_once $autoload; } else { - throw new \LogicException('Composer autoload was not found'); + throw new LogicException('Composer autoload was not found'); } use Enqueue\SnsQs\SnsQsConnectionFactory; @@ -34,7 +34,7 @@ while (true) { if ($m = $consumer->receive(20000)) { $consumer->acknowledge($m); - echo 'Received message: '.$m->getBody().' '.json_encode($m->getHeaders()).' '.json_encode($m->getProperties()).PHP_EOL; + echo 'Received message: '.$m->getBody().' '.json_encode($m->getHeaders()).' '.json_encode($m->getProperties()).\PHP_EOL; } } echo 'Done'."\n"; diff --git a/examples/produce.php b/examples/produce.php index 0396d9c..53018d7 100644 --- a/examples/produce.php +++ b/examples/produce.php @@ -12,7 +12,7 @@ if ($autoload) { require_once $autoload; } else { - throw new \LogicException('Composer autoload was not found'); + throw new LogicException('Composer autoload was not found'); } use Enqueue\SnsQs\SnsQsConnectionFactory; @@ -33,7 +33,7 @@ while (true) { $context->createProducer()->send($topic, $message); - echo 'Sent message: '.$message->getBody().PHP_EOL; + echo 'Sent message: '.$message->getBody().\PHP_EOL; sleep(1); }