diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f3b500e8..36c3d5d90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,7 +69,7 @@ jobs: - run: sed -i 's/525568/16777471/' vendor/kwn/php-rdkafka-stubs/stubs/constants.php - - run: ./bin/php-cs-fixer fix --config=.php_cs.php --no-interaction --dry-run --diff -v --path-mode=intersection -- ${{ env.GIT_DIFF_FILTERED }} + - run: ./bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --no-interaction --dry-run --diff -v --path-mode=intersection -- ${{ env.GIT_DIFF_FILTERED }} if: env.GIT_DIFF_FILTERED unit_tests: diff --git a/.gitignore b/.gitignore index e92454ae9..7a2e2ec9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,21 @@ *~ /.idea/ bin/doctrine* -bin/php-cs-fixer -bin/phpunit -bin/sql-formatter -bin/phpstan -bin/jp.php -bin/php-parse -bin/google-cloud-batch +bin/php-cs-fixer* +bin/phpunit* +bin/sql-formatter* +bin/phpstan* +bin/jp.php* +bin/php-parse* +bin/google-cloud-batch* +bin/patch-type-declarations* bin/thruway -bin/phpstan.phar -bin/var-dump-server -bin/yaml-lint +bin/var-dump-server* +bin/yaml-lint* vendor var .php_cs .php_cs.cache composer.lock .phpunit.result.cache +.php-cs-fixer.cache diff --git a/.php_cs.php b/.php-cs-fixer.dist.php similarity index 94% rename from .php_cs.php rename to .php-cs-fixer.dist.php index e1755cb13..b9316b59b 100644 --- a/.php_cs.php +++ b/.php-cs-fixer.dist.php @@ -1,6 +1,7 @@ setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) ->setRiskyAllowed(true) ->setRules(array( '@Symfony' => true, diff --git a/bin/fix-symfony-version.php b/bin/fix-symfony-version.php index efd0eb50e..aac84f081 100644 --- a/bin/fix-symfony-version.php +++ b/bin/fix-symfony-version.php @@ -1,14 +1,14 @@ createContext(); @@ -13,4 +13,4 @@ $dbalContext->getDbalConnection()->exec('USE '.$database); $dbalContext->createDataBaseTable(); -echo 'MySQL Database is updated'.PHP_EOL; +echo 'MySQL Database is updated'.\PHP_EOL; diff --git a/docker/bin/refresh-postgres-database.php b/docker/bin/refresh-postgres-database.php index 7efaf4806..1d96c3c07 100644 --- a/docker/bin/refresh-postgres-database.php +++ b/docker/bin/refresh-postgres-database.php @@ -11,4 +11,4 @@ $dbalContext->getDbalConnection()->getSchemaManager()->dropAndCreateDatabase('postgres'); $dbalContext->createDataBaseTable(); -echo 'Postgresql Database is updated'.PHP_EOL; +echo 'Postgresql Database is updated'.\PHP_EOL; diff --git a/docker/bin/test.sh b/docker/bin/test.sh index cfc94aab5..b78e1c1a8 100755 --- a/docker/bin/test.sh +++ b/docker/bin/test.sh @@ -44,7 +44,7 @@ waitForService localstack 4566 50 php docker/bin/refresh-mysql-database.php || exit 1 php docker/bin/refresh-postgres-database.php || exit 1 php pkg/job-queue/Tests/Functional/app/console doctrine:database:create --if-not-exists || exit 1 -php pkg/job-queue/Tests/Functional/app/console doctrine:schema:update --force || exit 1 +php pkg/job-queue/Tests/Functional/app/console doctrine:schema:update --force --complete || exit 1 #php pkg/enqueue-bundle/Tests/Functional/app/console.php config:dump-reference enqueue bin/phpunit "$@" diff --git a/pkg/amqp-bunny/AmqpConnectionFactory.php b/pkg/amqp-bunny/AmqpConnectionFactory.php index 241929abe..749e63be0 100644 --- a/pkg/amqp-bunny/AmqpConnectionFactory.php +++ b/pkg/amqp-bunny/AmqpConnectionFactory.php @@ -26,7 +26,7 @@ class AmqpConnectionFactory implements InteropAmqpConnectionFactory, DelayStrate private $client; /** - * @see \Enqueue\AmqpTools\ConnectionConfig for possible config formats and values + * @see ConnectionConfig for possible config formats and values * * @param array|string|null $config */ @@ -89,10 +89,10 @@ private function establishConnection(): BunnyClient $bunnyConfig['timeout'] = $this->config->getConnectionTimeout(); // @see https://github.com/php-enqueue/enqueue-dev/issues/229 -// $bunnyConfig['persistent'] = $this->config->isPersisted(); -// if ($this->config->isPersisted()) { -// $bunnyConfig['path'] = 'enqueue';//$this->config->getOption('path', $this->config->getOption('vhost')); -// } + // $bunnyConfig['persistent'] = $this->config->isPersisted(); + // if ($this->config->isPersisted()) { + // $bunnyConfig['path'] = 'enqueue';//$this->config->getOption('path', $this->config->getOption('vhost')); + // } if ($this->config->getHeartbeat()) { $bunnyConfig['heartbeat'] = $this->config->getHeartbeat(); diff --git a/pkg/amqp-bunny/AmqpConsumer.php b/pkg/amqp-bunny/AmqpConsumer.php index f1b52a99d..89301c80c 100644 --- a/pkg/amqp-bunny/AmqpConsumer.php +++ b/pkg/amqp-bunny/AmqpConsumer.php @@ -48,7 +48,7 @@ public function __construct(AmqpContext $context, InteropAmqpQueue $queue) $this->flags = self::FLAG_NOPARAM; } - public function setConsumerTag(string $consumerTag = null): void + public function setConsumerTag(?string $consumerTag = null): void { $this->consumerTag = $consumerTag; } @@ -98,7 +98,7 @@ public function receive(int $timeout = 0): ?Message return $message; } - usleep(100000); //100ms + usleep(100000); // 100ms } return null; diff --git a/pkg/amqp-bunny/AmqpContext.php b/pkg/amqp-bunny/AmqpContext.php index f57554335..151cbd842 100644 --- a/pkg/amqp-bunny/AmqpContext.php +++ b/pkg/amqp-bunny/AmqpContext.php @@ -51,7 +51,6 @@ class AmqpContext implements InteropAmqpContext, DelayStrategyAware * Callable must return instance of \Bunny\Channel once called. * * @param Channel|callable $bunnyChannel - * @param array $config */ public function __construct($bunnyChannel, array $config) { @@ -294,10 +293,7 @@ public function getBunnyChannel(): Channel if (false == $this->bunnyChannel) { $bunnyChannel = call_user_func($this->bunnyChannelFactory); if (false == $bunnyChannel instanceof Channel) { - throw new \LogicException(sprintf( - 'The factory must return instance of \Bunny\Channel. It returned %s', - is_object($bunnyChannel) ? get_class($bunnyChannel) : gettype($bunnyChannel) - )); + throw new \LogicException(sprintf('The factory must return instance of \Bunny\Channel. It returned %s', is_object($bunnyChannel) ? $bunnyChannel::class : gettype($bunnyChannel))); } $this->bunnyChannel = $bunnyChannel; diff --git a/pkg/amqp-bunny/AmqpProducer.php b/pkg/amqp-bunny/AmqpProducer.php index 76892ebeb..178ff81a8 100644 --- a/pkg/amqp-bunny/AmqpProducer.php +++ b/pkg/amqp-bunny/AmqpProducer.php @@ -79,7 +79,7 @@ public function send(Destination $destination, Message $message): void /** * @return self */ - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { if (null === $this->delayStrategy) { throw DeliveryDelayNotSupportedException::providerDoestNotSupportIt(); @@ -98,7 +98,7 @@ public function getDeliveryDelay(): ?int /** * @return self */ - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { $this->priority = $priority; @@ -113,7 +113,7 @@ public function getPriority(): ?int /** * @return self */ - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { $this->timeToLive = $timeToLive; diff --git a/pkg/amqp-bunny/AmqpSubscriptionConsumer.php b/pkg/amqp-bunny/AmqpSubscriptionConsumer.php index b36bcd949..2904c1c19 100644 --- a/pkg/amqp-bunny/AmqpSubscriptionConsumer.php +++ b/pkg/amqp-bunny/AmqpSubscriptionConsumer.php @@ -47,7 +47,7 @@ public function consume(int $timeout = 0): void try { $this->context->getBunnyChannel()->getClient()->run(0 !== $timeout ? $timeout / 1000 : null); } catch (ClientException $e) { - if (0 === strpos($e->getMessage(), 'stream_select() failed') && $signalHandler->wasThereSignal()) { + if (str_starts_with($e->getMessage(), 'stream_select() failed') && $signalHandler->wasThereSignal()) { return; } @@ -63,7 +63,7 @@ public function consume(int $timeout = 0): void public function subscribe(Consumer $consumer, callable $callback): void { if (false == $consumer instanceof AmqpConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class)); } if ($consumer->getConsumerTag() && array_key_exists($consumer->getConsumerTag(), $this->subscribers)) { @@ -110,7 +110,7 @@ public function subscribe(Consumer $consumer, callable $callback): void public function unsubscribe(Consumer $consumer): void { if (false == $consumer instanceof AmqpConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class)); } if (false == $consumer->getConsumerTag()) { diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php index ae4b74c6a..e5c2d1302 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php @@ -18,9 +18,6 @@ public function test() $this->markTestIncomplete(); } - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -31,8 +28,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php index 00710aad7..b7c311cfb 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php @@ -13,9 +13,6 @@ */ class AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest extends SendAndReceiveDelayedMessageFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -26,8 +23,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php index bf2041c4b..89530e2e6 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePriorityMessagesFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -23,8 +20,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php index a50bdf98e..793e3fa78 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTimeToLiveMessagesFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -23,8 +20,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimestampAsIntegerTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimestampAsIntegerTest.php index f253d73c9..37ef1d0bd 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimestampAsIntegerTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendAndReceiveTimestampAsIntegerTest.php @@ -10,9 +10,6 @@ */ class AmqpSendAndReceiveTimestampAsIntegerTest extends SendAndReceiveTimestampAsIntegerSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php index e715f5c80..e3286ae9c 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -23,8 +20,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php index ac7efaf1d..ce9fc2794 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php @@ -13,9 +13,6 @@ */ class AmqpSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -24,8 +21,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createTopic(Context $context, $topicName) diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php index 9d37cade4..f1210d03a 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -23,8 +20,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php index 8947fe9f1..cc47cf44a 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php @@ -13,9 +13,6 @@ */ class AmqpSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFromTopicSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -24,8 +21,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createTopic(Context $context, $topicName) diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php index 28deeac86..f13ead179 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php @@ -14,9 +14,6 @@ */ class AmqpSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceiveFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -25,8 +22,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) @@ -41,8 +36,6 @@ protected function createQueue(Context $context, $queueName) } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createTopic(Context $context, $topicName) diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php index 5facc03b2..683e0b1ca 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php @@ -14,9 +14,6 @@ */ class AmqpSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndReceiveNoWaitFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -25,8 +22,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) @@ -41,8 +36,6 @@ protected function createQueue(Context $context, $queueName) } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createTopic(Context $context, $topicName) diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php index f22c6d6a7..4a549fcf8 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php @@ -19,9 +19,6 @@ public function test() parent::test(); } - /** - * {@inheritdoc} - */ protected function createContext() { $baseDir = realpath(__DIR__.'/../../../../'); @@ -44,8 +41,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php index c2403792b..5d4d8d40e 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php @@ -15,8 +15,6 @@ class AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subscri { /** * @return AmqpContext - * - * {@inheritdoc} */ protected function createContext() { @@ -30,8 +28,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php index a1f4ac57f..6cae48148 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php @@ -24,8 +24,6 @@ protected function tearDown(): void /** * @return AmqpContext - * - * {@inheritdoc} */ protected function createContext() { @@ -39,8 +37,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php b/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php index 624d0a8f4..d9d8527d3 100644 --- a/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php +++ b/pkg/amqp-bunny/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php @@ -15,8 +15,6 @@ class AmqpSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerStopOn { /** * @return AmqpContext - * - * {@inheritdoc} */ protected function createContext() { @@ -30,8 +28,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-ext/AmqpConnectionFactory.php b/pkg/amqp-ext/AmqpConnectionFactory.php index 177a786d8..c3241d72a 100644 --- a/pkg/amqp-ext/AmqpConnectionFactory.php +++ b/pkg/amqp-ext/AmqpConnectionFactory.php @@ -24,7 +24,7 @@ class AmqpConnectionFactory implements InteropAmqpConnectionFactory, DelayStrate private $connection; /** - * @see \Enqueue\AmqpTools\ConnectionConfig for possible config formats and values + * @see ConnectionConfig for possible config formats and values * * @param array|string|null $config */ diff --git a/pkg/amqp-ext/AmqpConsumer.php b/pkg/amqp-ext/AmqpConsumer.php index 03c949714..700e8d77f 100644 --- a/pkg/amqp-ext/AmqpConsumer.php +++ b/pkg/amqp-ext/AmqpConsumer.php @@ -43,7 +43,7 @@ public function __construct(AmqpContext $context, InteropAmqpQueue $queue) $this->flags = self::FLAG_NOPARAM; } - public function setConsumerTag(string $consumerTag = null): void + public function setConsumerTag(?string $consumerTag = null): void { $this->consumerTag = $consumerTag; } @@ -93,7 +93,7 @@ public function receive(int $timeout = 0): ?Message return $message; } - usleep(100000); //100ms + usleep(100000); // 100ms } return null; @@ -130,7 +130,7 @@ public function reject(Message $message, bool $requeue = false): void $this->getExtQueue()->reject( $message->getDeliveryTag(), - $requeue ? AMQP_REQUEUE : AMQP_NOPARAM + $requeue ? \AMQP_REQUEUE : \AMQP_NOPARAM ); } diff --git a/pkg/amqp-ext/AmqpContext.php b/pkg/amqp-ext/AmqpContext.php index 5ea099da2..c339dc0a1 100644 --- a/pkg/amqp-ext/AmqpContext.php +++ b/pkg/amqp-ext/AmqpContext.php @@ -177,7 +177,7 @@ public function unbind(InteropAmqpBind $bind): void public function createTemporaryQueue(): Queue { $extQueue = new \AMQPQueue($this->getExtChannel()); - $extQueue->setFlags(AMQP_EXCLUSIVE); + $extQueue->setFlags(\AMQP_EXCLUSIVE); $extQueue->declareQueue(); @@ -243,10 +243,7 @@ public function getExtChannel(): \AMQPChannel if (false == $this->extChannel) { $extChannel = call_user_func($this->extChannelFactory); if (false == $extChannel instanceof \AMQPChannel) { - throw new \LogicException(sprintf( - 'The factory must return instance of AMQPChannel. It returns %s', - is_object($extChannel) ? get_class($extChannel) : gettype($extChannel) - )); + throw new \LogicException(sprintf('The factory must return instance of AMQPChannel. It returns %s', is_object($extChannel) ? $extChannel::class : gettype($extChannel))); } $this->extChannel = $extChannel; diff --git a/pkg/amqp-ext/AmqpProducer.php b/pkg/amqp-ext/AmqpProducer.php index 0fe6b7a39..fc55ca29e 100644 --- a/pkg/amqp-ext/AmqpProducer.php +++ b/pkg/amqp-ext/AmqpProducer.php @@ -72,7 +72,7 @@ public function send(Destination $destination, Message $message): void } } - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { if (null === $this->delayStrategy) { throw DeliveryDelayNotSupportedException::providerDoestNotSupportIt(); @@ -88,7 +88,7 @@ public function getDeliveryDelay(): ?int return $this->deliveryDelay; } - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { $this->priority = $priority; @@ -100,7 +100,7 @@ public function getPriority(): ?int return $this->priority; } - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { $this->timeToLive = $timeToLive; @@ -146,7 +146,7 @@ private function doSend(AmqpDestination $destination, AmqpMessage $message): voi } else { /** @var AmqpQueue $destination */ $amqpExchange = new \AMQPExchange($this->amqpChannel); - $amqpExchange->setType(AMQP_EX_TYPE_DIRECT); + $amqpExchange->setType(\AMQP_EX_TYPE_DIRECT); $amqpExchange->setName(''); $amqpExchange->publish( diff --git a/pkg/amqp-ext/AmqpSubscriptionConsumer.php b/pkg/amqp-ext/AmqpSubscriptionConsumer.php index 08a3df1c6..3d0faccb7 100644 --- a/pkg/amqp-ext/AmqpSubscriptionConsumer.php +++ b/pkg/amqp-ext/AmqpSubscriptionConsumer.php @@ -86,7 +86,7 @@ public function consume(int $timeout = 0): void public function subscribe(Consumer $consumer, callable $callback): void { if (false == $consumer instanceof AmqpConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class)); } if ($consumer->getConsumerTag() && array_key_exists($consumer->getConsumerTag(), $this->subscribers)) { @@ -109,7 +109,7 @@ public function subscribe(Consumer $consumer, callable $callback): void public function unsubscribe(Consumer $consumer): void { if (false == $consumer instanceof AmqpConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class)); } if (false == $consumer->getConsumerTag()) { diff --git a/pkg/amqp-ext/Flags.php b/pkg/amqp-ext/Flags.php index ca31a4b74..2054f5526 100644 --- a/pkg/amqp-ext/Flags.php +++ b/pkg/amqp-ext/Flags.php @@ -12,14 +12,14 @@ class Flags { public static function convertMessageFlags(int $interop): int { - $flags = AMQP_NOPARAM; + $flags = \AMQP_NOPARAM; if ($interop & InteropAmqpMessage::FLAG_MANDATORY) { - $flags |= AMQP_MANDATORY; + $flags |= \AMQP_MANDATORY; } if ($interop & InteropAmqpMessage::FLAG_IMMEDIATE) { - $flags |= AMQP_IMMEDIATE; + $flags |= \AMQP_IMMEDIATE; } return $flags; @@ -27,12 +27,12 @@ public static function convertMessageFlags(int $interop): int public static function convertTopicFlags(int $interop): int { - $flags = AMQP_NOPARAM; + $flags = \AMQP_NOPARAM; $flags |= static::convertDestinationFlags($interop); if ($interop & InteropAmqpTopic::FLAG_INTERNAL) { - $flags |= AMQP_INTERNAL; + $flags |= \AMQP_INTERNAL; } return $flags; @@ -40,12 +40,12 @@ public static function convertTopicFlags(int $interop): int public static function convertQueueFlags(int $interop): int { - $flags = AMQP_NOPARAM; + $flags = \AMQP_NOPARAM; $flags |= static::convertDestinationFlags($interop); if ($interop & InteropAmqpQueue::FLAG_EXCLUSIVE) { - $flags |= AMQP_EXCLUSIVE; + $flags |= \AMQP_EXCLUSIVE; } return $flags; @@ -53,22 +53,22 @@ public static function convertQueueFlags(int $interop): int public static function convertDestinationFlags(int $interop): int { - $flags = AMQP_NOPARAM; + $flags = \AMQP_NOPARAM; if ($interop & InteropAmqpDestination::FLAG_PASSIVE) { - $flags |= AMQP_PASSIVE; + $flags |= \AMQP_PASSIVE; } if ($interop & InteropAmqpDestination::FLAG_DURABLE) { - $flags |= AMQP_DURABLE; + $flags |= \AMQP_DURABLE; } if ($interop & InteropAmqpDestination::FLAG_AUTODELETE) { - $flags |= AMQP_AUTODELETE; + $flags |= \AMQP_AUTODELETE; } if ($interop & InteropAmqpDestination::FLAG_NOWAIT) { - $flags |= AMQP_NOWAIT; + $flags |= \AMQP_NOWAIT; } return $flags; @@ -76,22 +76,22 @@ public static function convertDestinationFlags(int $interop): int public static function convertConsumerFlags(int $interop): int { - $flags = AMQP_NOPARAM; + $flags = \AMQP_NOPARAM; if ($interop & InteropAmqpConsumer::FLAG_NOLOCAL) { - $flags |= AMQP_NOLOCAL; + $flags |= \AMQP_NOLOCAL; } if ($interop & InteropAmqpConsumer::FLAG_NOACK) { - $flags |= AMQP_AUTOACK; + $flags |= \AMQP_AUTOACK; } if ($interop & InteropAmqpConsumer::FLAG_EXCLUSIVE) { - $flags |= AMQP_EXCLUSIVE; + $flags |= \AMQP_EXCLUSIVE; } if ($interop & InteropAmqpConsumer::FLAG_NOWAIT) { - $flags |= AMQP_NOWAIT; + $flags |= \AMQP_NOWAIT; } return $flags; diff --git a/pkg/amqp-ext/Tests/AmqpConsumerTest.php b/pkg/amqp-ext/Tests/AmqpConsumerTest.php index ae803e047..1dcc0f349 100644 --- a/pkg/amqp-ext/Tests/AmqpConsumerTest.php +++ b/pkg/amqp-ext/Tests/AmqpConsumerTest.php @@ -5,7 +5,6 @@ use Enqueue\AmqpExt\AmqpConsumer; use Enqueue\AmqpExt\AmqpContext; use Enqueue\Test\ClassExtensionTrait; -use Interop\Amqp\Impl\AmqpQueue; use Interop\Queue\Consumer; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; diff --git a/pkg/amqp-ext/Tests/Spec/AmqpMessageTest.php b/pkg/amqp-ext/Tests/Spec/AmqpMessageTest.php index e11afd964..73fc4ad14 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpMessageTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpMessageTest.php @@ -7,9 +7,6 @@ class AmqpMessageTest extends MessageSpec { - /** - * {@inheritdoc} - */ protected function createMessage() { return new AmqpMessage(); diff --git a/pkg/amqp-ext/Tests/Spec/AmqpProducerTest.php b/pkg/amqp-ext/Tests/Spec/AmqpProducerTest.php index 3dead4d9f..1183e3a8e 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpProducerTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpProducerTest.php @@ -10,9 +10,6 @@ */ class AmqpProducerTest extends ProducerSpec { - /** - * {@inheritdoc} - */ protected function createProducer() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php index ac30c510f..f79f7e635 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php @@ -13,9 +13,6 @@ */ class AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest extends SendAndReceiveDelayedMessageFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -26,8 +23,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php index 311f82ab6..71da671f4 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php @@ -13,9 +13,6 @@ */ class AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest extends SendAndReceiveDelayedMessageFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -26,8 +23,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php index 0bfab937b..40edcd865 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePriorityMessagesFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -23,8 +20,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php index 6f0d7b6cf..6654107c9 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTimeToLiveMessagesFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -23,8 +20,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php index 00d7e3840..5ecc00046 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php @@ -10,9 +10,6 @@ */ class AmqpSendAndReceiveTimestampAsIntengerTest extends SendAndReceiveTimestampAsIntegerSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php index 9d4713dee..cb45dc5a5 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -23,8 +20,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php index 629703303..fb8e62750 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php @@ -13,9 +13,6 @@ */ class AmqpSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -24,8 +21,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createTopic(Context $context, $topicName) diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php index c4e602f8d..a0d93c38b 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -23,8 +20,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php index 6a599c9f7..f9867d1b1 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php @@ -13,9 +13,6 @@ */ class AmqpSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFromTopicSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -24,8 +21,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createTopic(Context $context, $topicName) diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php index 2f2e30d6b..058606b51 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php @@ -14,9 +14,6 @@ */ class AmqpSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceiveFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -25,8 +22,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) @@ -41,8 +36,6 @@ protected function createQueue(Context $context, $queueName) } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createTopic(Context $context, $topicName) diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php index b9d4510d5..b8ac82403 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php @@ -14,9 +14,6 @@ */ class AmqpSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndReceiveNoWaitFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -25,8 +22,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) @@ -41,8 +36,6 @@ protected function createQueue(Context $context, $queueName) } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createTopic(Context $context, $topicName) diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php index 31e4e175f..0aa03cbd0 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSslSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $baseDir = realpath(__DIR__.'/../../../../'); @@ -37,8 +34,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php index 1adda733d..c069acefd 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php @@ -15,8 +15,6 @@ class AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subscri { /** * @return AmqpContext - * - * {@inheritdoc} */ protected function createContext() { @@ -30,8 +28,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php index ccb13bb89..c3341c937 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php @@ -24,8 +24,6 @@ protected function tearDown(): void /** * @return AmqpContext - * - * {@inheritdoc} */ protected function createContext() { @@ -39,8 +37,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php b/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php index 424013f4a..e017bb603 100644 --- a/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php +++ b/pkg/amqp-ext/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php @@ -15,8 +15,6 @@ class AmqpSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerStopOn { /** * @return AmqpContext - * - * {@inheritdoc} */ protected function createContext() { @@ -30,8 +28,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-ext/Tests/fix_composer_json.php b/pkg/amqp-ext/Tests/fix_composer_json.php index f025f6081..01f73c95e 100644 --- a/pkg/amqp-ext/Tests/fix_composer_json.php +++ b/pkg/amqp-ext/Tests/fix_composer_json.php @@ -6,4 +6,4 @@ $composerJson['config']['platform']['ext-amqp'] = '1.9.3'; -file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, JSON_PRETTY_PRINT)); +file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, \JSON_PRETTY_PRINT)); diff --git a/pkg/amqp-ext/examples/consume.php b/pkg/amqp-ext/examples/consume.php index 74ed8fab5..d510bf077 100644 --- a/pkg/amqp-ext/examples/consume.php +++ b/pkg/amqp-ext/examples/consume.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\AmqpExt\AmqpConnectionFactory; @@ -32,7 +32,7 @@ while (true) { if ($m = $consumer->receive(1)) { - echo $m->getBody(), PHP_EOL; + echo $m->getBody(), \PHP_EOL; $consumer->acknowledge($m); } diff --git a/pkg/amqp-ext/examples/produce.php b/pkg/amqp-ext/examples/produce.php index 72acb7e94..dfc4374da 100644 --- a/pkg/amqp-ext/examples/produce.php +++ b/pkg/amqp-ext/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\AmqpExt\AmqpConnectionFactory; diff --git a/pkg/amqp-lib/AmqpConnectionFactory.php b/pkg/amqp-lib/AmqpConnectionFactory.php index 3cb1c29b7..198e6874d 100644 --- a/pkg/amqp-lib/AmqpConnectionFactory.php +++ b/pkg/amqp-lib/AmqpConnectionFactory.php @@ -32,7 +32,7 @@ class AmqpConnectionFactory implements InteropAmqpConnectionFactory, DelayStrate private $connection; /** - * @see \Enqueue\AmqpTools\ConnectionConfig for possible config formats and values. + * @see ConnectionConfig for possible config formats and values. * * @param array|string|null $config */ diff --git a/pkg/amqp-lib/AmqpConsumer.php b/pkg/amqp-lib/AmqpConsumer.php index 0218db6b2..0534a9371 100644 --- a/pkg/amqp-lib/AmqpConsumer.php +++ b/pkg/amqp-lib/AmqpConsumer.php @@ -47,7 +47,7 @@ public function __construct(AmqpContext $context, InteropAmqpQueue $queue) $this->flags = self::FLAG_NOPARAM; } - public function setConsumerTag(string $consumerTag = null): void + public function setConsumerTag(?string $consumerTag = null): void { $this->consumerTag = $consumerTag; } @@ -97,7 +97,7 @@ public function receive(int $timeout = 0): ?Message return $message; } - usleep(100000); //100ms + usleep(100000); // 100ms } return null; @@ -127,7 +127,6 @@ public function acknowledge(Message $message): void /** * @param InteropAmqpMessage $message - * @param bool $requeue */ public function reject(Message $message, bool $requeue = false): void { diff --git a/pkg/amqp-lib/AmqpProducer.php b/pkg/amqp-lib/AmqpProducer.php index 70e876793..928597298 100644 --- a/pkg/amqp-lib/AmqpProducer.php +++ b/pkg/amqp-lib/AmqpProducer.php @@ -81,7 +81,7 @@ public function send(Destination $destination, Message $message): void /** * @return self */ - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { if (null === $this->delayStrategy) { throw DeliveryDelayNotSupportedException::providerDoestNotSupportIt(); @@ -100,7 +100,7 @@ public function getDeliveryDelay(): ?int /** * @return self */ - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { $this->priority = $priority; @@ -115,7 +115,7 @@ public function getPriority(): ?int /** * @return self */ - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { $this->timeToLive = $timeToLive; diff --git a/pkg/amqp-lib/AmqpSubscriptionConsumer.php b/pkg/amqp-lib/AmqpSubscriptionConsumer.php index 5d59ddf82..f96c4e49a 100644 --- a/pkg/amqp-lib/AmqpSubscriptionConsumer.php +++ b/pkg/amqp-lib/AmqpSubscriptionConsumer.php @@ -93,7 +93,7 @@ public function consume(int $timeout = 0): void public function subscribe(Consumer $consumer, callable $callback): void { if (false == $consumer instanceof AmqpConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class)); } if ($consumer->getConsumerTag() && array_key_exists($consumer->getConsumerTag(), $this->subscribers)) { @@ -140,7 +140,7 @@ public function subscribe(Consumer $consumer, callable $callback): void public function unsubscribe(Consumer $consumer): void { if (false == $consumer instanceof AmqpConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, $consumer::class)); } if (false == $consumer->getConsumerTag()) { diff --git a/pkg/amqp-lib/Tests/Spec/AmqpProducerTest.php b/pkg/amqp-lib/Tests/Spec/AmqpProducerTest.php index 510b72ab9..f72296a66 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpProducerTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpProducerTest.php @@ -10,9 +10,6 @@ */ class AmqpProducerTest extends ProducerSpec { - /** - * {@inheritdoc} - */ protected function createProducer() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php index 8b618e912..1a5fb70b3 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php @@ -13,9 +13,6 @@ */ class AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest extends SendAndReceiveDelayedMessageFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -26,8 +23,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php index f3eb0f7c7..0e00b10e9 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest.php @@ -13,9 +13,6 @@ */ class AmqpSendAndReceiveDelayedMessageWithDlxStrategyTest extends SendAndReceiveDelayedMessageFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -26,8 +23,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php index bd88088a9..83c4c948f 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceivePriorityMessagesFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePriorityMessagesFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -23,8 +20,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php index 39fcb6fc1..d5f35ed65 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTimeToLiveMessagesFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -23,8 +20,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php index 2574f5ab2..ade42b346 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSendAndReceiveTimestampAsIntengerTest.php @@ -10,9 +10,6 @@ */ class AmqpSendAndReceiveTimestampAsIntengerTest extends SendAndReceiveTimestampAsIntegerSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php index a80e91b8a..6d66532c6 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -23,8 +20,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php index 72a4eb5c4..621608020 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveFromTopicTest.php @@ -13,9 +13,6 @@ */ class AmqpSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -24,8 +21,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createTopic(Context $context, $topicName) diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php index 47da126e6..db536948a 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -23,8 +20,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php index 49a168ba7..c2b184209 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSendToAndReceiveNoWaitFromTopicTest.php @@ -13,9 +13,6 @@ */ class AmqpSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFromTopicSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -24,8 +21,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createTopic(Context $context, $topicName) diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php index d2b2aee06..ec404b59e 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveFromQueueTest.php @@ -14,9 +14,6 @@ */ class AmqpSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceiveFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -25,8 +22,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) @@ -41,8 +36,6 @@ protected function createQueue(Context $context, $queueName) } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createTopic(Context $context, $topicName) diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php index c42c4213b..665382fe4 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSendToTopicAndReceiveNoWaitFromQueueTest.php @@ -14,9 +14,6 @@ */ class AmqpSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndReceiveNoWaitFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new AmqpConnectionFactory(getenv('AMQP_DSN')); @@ -25,8 +22,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) @@ -41,8 +36,6 @@ protected function createQueue(Context $context, $queueName) } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createTopic(Context $context, $topicName) diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php index 19d6a7030..7bf142e5d 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSslSendToAndReceiveFromQueueTest.php @@ -12,9 +12,6 @@ */ class AmqpSslSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $baseDir = realpath(__DIR__.'/../../../../'); @@ -37,8 +34,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param AmqpContext $context */ protected function createQueue(Context $context, $queueName) diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php index 284a03c11..b81b139e8 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php @@ -15,8 +15,6 @@ class AmqpSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subscri { /** * @return AmqpContext - * - * {@inheritdoc} */ protected function createContext() { @@ -30,8 +28,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php index a8bd48e01..288ab25f4 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerConsumeUntilUnsubscribedTest.php @@ -24,8 +24,6 @@ protected function tearDown(): void /** * @return AmqpContext - * - * {@inheritdoc} */ protected function createContext() { @@ -39,8 +37,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php b/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php index b1987bbe7..345007135 100644 --- a/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php +++ b/pkg/amqp-lib/Tests/Spec/AmqpSubscriptionConsumerStopOnFalseTest.php @@ -15,8 +15,6 @@ class AmqpSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerStopOn { /** * @return AmqpContext - * - * {@inheritdoc} */ protected function createContext() { @@ -30,8 +28,6 @@ protected function createContext() /** * @param AmqpContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/amqp-lib/examples/consume.php b/pkg/amqp-lib/examples/consume.php index 633efca66..03f609c71 100644 --- a/pkg/amqp-lib/examples/consume.php +++ b/pkg/amqp-lib/examples/consume.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\AmqpLib\AmqpConnectionFactory; @@ -32,7 +32,7 @@ while (true) { if ($m = $consumer->receive(100)) { - echo $m->getBody(), PHP_EOL; + echo $m->getBody(), \PHP_EOL; $consumer->acknowledge($m); } diff --git a/pkg/amqp-lib/examples/produce.php b/pkg/amqp-lib/examples/produce.php index 2753f4ac7..7527b2620 100644 --- a/pkg/amqp-lib/examples/produce.php +++ b/pkg/amqp-lib/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\AmqpLib\AmqpConnectionFactory; @@ -26,7 +26,7 @@ $topic = $context->createTopic('test.amqp.ext'); $topic->addFlag(AmqpTopic::FLAG_DURABLE); $topic->setType(AmqpTopic::TYPE_FANOUT); -//$topic->setArguments(['alternate-exchange' => 'foo']); +// $topic->setArguments(['alternate-exchange' => 'foo']); $context->deleteTopic($topic); $context->declareTopic($topic); diff --git a/pkg/amqp-lib/tutorial/rpc_client.php b/pkg/amqp-lib/tutorial/rpc_client.php index 74368c20f..6ad091bc0 100644 --- a/pkg/amqp-lib/tutorial/rpc_client.php +++ b/pkg/amqp-lib/tutorial/rpc_client.php @@ -11,12 +11,12 @@ 'pass' => 'guest', ]; -class FibonacciRpcClient +class rpc_client { - /** @var \Interop\Amqp\AmqpContext */ + /** @var Interop\Amqp\AmqpContext */ private $context; - /** @var \Interop\Amqp\AmqpQueue */ + /** @var Interop\Amqp\AmqpQueue */ private $callback_queue; public function __construct(array $config) @@ -43,7 +43,7 @@ public function call($n) while (true) { if ($message = $consumer->receive()) { if ($message->getCorrelationId() == $corr_id) { - return (int) ($message->getBody()); + return (int) $message->getBody(); } } } diff --git a/pkg/amqp-lib/tutorial/rpc_server.php b/pkg/amqp-lib/tutorial/rpc_server.php index 954d21f25..241471684 100644 --- a/pkg/amqp-lib/tutorial/rpc_server.php +++ b/pkg/amqp-lib/tutorial/rpc_server.php @@ -37,7 +37,7 @@ function fib($n) while (true) { if ($req = $consumer->receive()) { - $n = (int) ($req->getBody()); + $n = (int) $req->getBody(); echo ' [.] fib(', $n, ")\n"; $msg = $context->createMessage((string) fib($n)); diff --git a/pkg/amqp-tools/ConnectionConfig.php b/pkg/amqp-tools/ConnectionConfig.php index 224d54b9d..e1356c7cb 100644 --- a/pkg/amqp-tools/ConnectionConfig.php +++ b/pkg/amqp-tools/ConnectionConfig.php @@ -104,9 +104,6 @@ public function __construct($config = null) $this->addSupportedScheme('amqps'); } - /** - * @param string[] $extensions - */ public function addSupportedScheme(string $schema): self { $this->supportedSchemes[] = $schema; @@ -117,7 +114,6 @@ public function addSupportedScheme(string $schema): self /** * @param string $name - * @param mixed $value * * @return self */ @@ -153,18 +149,18 @@ public function parse() $config = array_replace($this->defaultConfig, $config); $config['host'] = (string) $config['host']; - $config['port'] = (int) ($config['port']); + $config['port'] = (int) $config['port']; $config['user'] = (string) $config['user']; $config['pass'] = (string) $config['pass']; - $config['read_timeout'] = max((float) ($config['read_timeout']), 0); - $config['write_timeout'] = max((float) ($config['write_timeout']), 0); - $config['connection_timeout'] = max((float) ($config['connection_timeout']), 0); - $config['heartbeat'] = max((float) ($config['heartbeat']), 0); + $config['read_timeout'] = max((float) $config['read_timeout'], 0); + $config['write_timeout'] = max((float) $config['write_timeout'], 0); + $config['connection_timeout'] = max((float) $config['connection_timeout'], 0); + $config['heartbeat'] = max((float) $config['heartbeat'], 0); $config['persisted'] = !empty($config['persisted']); $config['lazy'] = !empty($config['lazy']); $config['qos_global'] = !empty($config['qos_global']); - $config['qos_prefetch_count'] = max((int) ($config['qos_prefetch_count']), 0); - $config['qos_prefetch_size'] = max((int) ($config['qos_prefetch_size']), 0); + $config['qos_prefetch_count'] = max((int) $config['qos_prefetch_count'], 0); + $config['qos_prefetch_size'] = max((int) $config['qos_prefetch_size'], 0); $config['ssl_on'] = !empty($config['ssl_on']); $config['ssl_verify'] = !empty($config['ssl_verify']); $config['ssl_cacert'] = (string) $config['ssl_cacert']; @@ -346,10 +342,8 @@ public function getSslPassPhrase() } /** - * @param string $name - * @param mixed $default - * - * @return mixed + * @param string $name + * @param mixed|null $default */ public function getOption($name, $default = null) { @@ -383,11 +377,7 @@ private function parseDsn($dsn) $supportedSchemes = $this->supportedSchemes; if (false == in_array($dsn->getSchemeProtocol(), $supportedSchemes, true)) { - throw new \LogicException(sprintf( - 'The given scheme protocol "%s" is not supported. It must be one of "%s".', - $dsn->getSchemeProtocol(), - implode('", "', $supportedSchemes) - )); + throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be one of "%s".', $dsn->getSchemeProtocol(), implode('", "', $supportedSchemes))); } $sslOn = false; @@ -406,7 +396,7 @@ private function parseDsn($dsn) 'user' => $dsn->getUser(), 'pass' => $dsn->getPassword(), 'vhost' => null !== ($path = $dsn->getPath()) ? - (0 === strpos($path, '/') ? substr($path, 1) : $path) + (str_starts_with($path, '/') ? substr($path, 1) : $path) : null, 'read_timeout' => $dsn->getFloat('read_timeout'), 'write_timeout' => $dsn->getFloat('write_timeout'), diff --git a/pkg/amqp-tools/DelayStrategyAware.php b/pkg/amqp-tools/DelayStrategyAware.php index f41a856a1..af488ce07 100644 --- a/pkg/amqp-tools/DelayStrategyAware.php +++ b/pkg/amqp-tools/DelayStrategyAware.php @@ -6,5 +6,5 @@ interface DelayStrategyAware { - public function setDelayStrategy(DelayStrategy $delayStrategy = null): self; + public function setDelayStrategy(?DelayStrategy $delayStrategy = null): self; } diff --git a/pkg/amqp-tools/DelayStrategyAwareTrait.php b/pkg/amqp-tools/DelayStrategyAwareTrait.php index 785f12895..b29f05797 100644 --- a/pkg/amqp-tools/DelayStrategyAwareTrait.php +++ b/pkg/amqp-tools/DelayStrategyAwareTrait.php @@ -11,7 +11,7 @@ trait DelayStrategyAwareTrait */ protected $delayStrategy; - public function setDelayStrategy(DelayStrategy $delayStrategy = null): DelayStrategyAware + public function setDelayStrategy(?DelayStrategy $delayStrategy = null): DelayStrategyAware { $this->delayStrategy = $delayStrategy; diff --git a/pkg/amqp-tools/RabbitMqDelayPluginDelayStrategy.php b/pkg/amqp-tools/RabbitMqDelayPluginDelayStrategy.php index 192135965..180d43bd9 100644 --- a/pkg/amqp-tools/RabbitMqDelayPluginDelayStrategy.php +++ b/pkg/amqp-tools/RabbitMqDelayPluginDelayStrategy.php @@ -39,10 +39,7 @@ public function delayMessage(AmqpContext $context, AmqpDestination $dest, AmqpMe $context->declareTopic($delayTopic); $context->bind(new AmqpBind($dest, $delayTopic, $delayMessage->getRoutingKey())); } else { - throw new InvalidDestinationException(sprintf('The destination must be an instance of %s but got %s.', - AmqpTopic::class.'|'.AmqpQueue::class, - get_class($dest) - )); + throw new InvalidDestinationException(sprintf('The destination must be an instance of %s but got %s.', AmqpTopic::class.'|'.AmqpQueue::class, $dest::class)); } $producer = $context->createProducer(); diff --git a/pkg/amqp-tools/RabbitMqDlxDelayStrategy.php b/pkg/amqp-tools/RabbitMqDlxDelayStrategy.php index f0fdd8956..35d9b59fe 100644 --- a/pkg/amqp-tools/RabbitMqDlxDelayStrategy.php +++ b/pkg/amqp-tools/RabbitMqDlxDelayStrategy.php @@ -13,9 +13,6 @@ class RabbitMqDlxDelayStrategy implements DelayStrategy { - /** - * {@inheritdoc} - */ public function delayMessage(AmqpContext $context, AmqpDestination $dest, AmqpMessage $message, int $delay): void { $properties = $message->getProperties(); @@ -44,10 +41,7 @@ public function delayMessage(AmqpContext $context, AmqpDestination $dest, AmqpMe $delayQueue->setArgument('x-dead-letter-exchange', ''); $delayQueue->setArgument('x-dead-letter-routing-key', $dest->getQueueName()); } else { - throw new InvalidDestinationException(sprintf('The destination must be an instance of %s but got %s.', - AmqpTopic::class.'|'.AmqpQueue::class, - get_class($dest) - )); + throw new InvalidDestinationException(sprintf('The destination must be an instance of %s but got %s.', AmqpTopic::class.'|'.AmqpQueue::class, $dest::class)); } $context->declareQueue($delayQueue); diff --git a/pkg/amqp-tools/SignalSocketHelper.php b/pkg/amqp-tools/SignalSocketHelper.php index 0bee8f22e..623a5e3e2 100644 --- a/pkg/amqp-tools/SignalSocketHelper.php +++ b/pkg/amqp-tools/SignalSocketHelper.php @@ -28,7 +28,7 @@ public function beforeSocket(): void return; } - $signals = [SIGTERM, SIGQUIT, SIGINT]; + $signals = [\SIGTERM, \SIGQUIT, \SIGINT]; if ($this->handlers) { throw new \LogicException('The handlers property should be empty but it is not. The afterSocket method might not have been called.'); @@ -60,12 +60,12 @@ public function afterSocket(): void return; } - $signals = [SIGTERM, SIGQUIT, SIGINT]; + $signals = [\SIGTERM, \SIGQUIT, \SIGINT]; $this->wasThereSignal = null; foreach ($signals as $signal) { - $handler = isset($this->handlers[$signal]) ? $this->handlers[$signal] : SIG_DFL; + $handler = isset($this->handlers[$signal]) ? $this->handlers[$signal] : \SIG_DFL; pcntl_signal($signal, $handler); } @@ -73,9 +73,6 @@ public function afterSocket(): void $this->handlers = []; } - /** - * @return bool - */ public function wasThereSignal(): bool { return (bool) $this->wasThereSignal; diff --git a/pkg/amqp-tools/Tests/ConnectionConfigTest.php b/pkg/amqp-tools/Tests/ConnectionConfigTest.php index 67a3f624b..1a1dc477d 100644 --- a/pkg/amqp-tools/Tests/ConnectionConfigTest.php +++ b/pkg/amqp-tools/Tests/ConnectionConfigTest.php @@ -122,9 +122,6 @@ public function testShouldGetSchemeExtensions() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/pkg/amqp-tools/Tests/RabbitMqDelayPluginDelayStrategyTest.php b/pkg/amqp-tools/Tests/RabbitMqDelayPluginDelayStrategyTest.php index de2b77ec5..d20506919 100644 --- a/pkg/amqp-tools/Tests/RabbitMqDelayPluginDelayStrategyTest.php +++ b/pkg/amqp-tools/Tests/RabbitMqDelayPluginDelayStrategyTest.php @@ -192,7 +192,7 @@ public function send(Destination $destination, Message $message): void { } - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { throw new \BadMethodCallException('This should not be called directly'); } @@ -202,7 +202,7 @@ public function getDeliveryDelay(): ?int throw new \BadMethodCallException('This should not be called directly'); } - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { throw new \BadMethodCallException('This should not be called directly'); } @@ -212,7 +212,7 @@ public function getPriority(): ?int throw new \BadMethodCallException('This should not be called directly'); } - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { throw new \BadMethodCallException('This should not be called directly'); } diff --git a/pkg/async-command/CommandResult.php b/pkg/async-command/CommandResult.php index 1c746a9a2..10080d587 100644 --- a/pkg/async-command/CommandResult.php +++ b/pkg/async-command/CommandResult.php @@ -19,11 +19,6 @@ final class CommandResult implements \JsonSerializable */ private $errorOutput; - /** - * @param int $exitCode - * @param string $output - * @param string $errorOutput - */ public function __construct(int $exitCode, string $output, string $errorOutput) { $this->exitCode = $exitCode; @@ -58,12 +53,8 @@ public function jsonSerialize(): array public static function jsonUnserialize(string $json): self { $data = json_decode($json, true); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return new self($data['exitCode'], $data['output'], $data['errorOutput']); diff --git a/pkg/async-command/Commands.php b/pkg/async-command/Commands.php index 0d751accd..abc015cf8 100644 --- a/pkg/async-command/Commands.php +++ b/pkg/async-command/Commands.php @@ -4,5 +4,5 @@ final class Commands { - const RUN_COMMAND = 'run_command'; + public const RUN_COMMAND = 'run_command'; } diff --git a/pkg/async-command/RunCommand.php b/pkg/async-command/RunCommand.php index 437c3a6d9..573a6200b 100644 --- a/pkg/async-command/RunCommand.php +++ b/pkg/async-command/RunCommand.php @@ -20,7 +20,6 @@ final class RunCommand implements \JsonSerializable private $options; /** - * @param string $command * @param string[] $arguments * @param string[] $options */ @@ -64,12 +63,8 @@ public function jsonSerialize(): array public static function jsonUnserialize(string $json): self { $data = json_decode($json, true); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return new self($data['command'], $data['arguments'], $data['options']); diff --git a/pkg/async-event-dispatcher/AsyncEventDispatcher.php b/pkg/async-event-dispatcher/AsyncEventDispatcher.php index fa7393ea6..e39136eff 100644 --- a/pkg/async-event-dispatcher/AsyncEventDispatcher.php +++ b/pkg/async-event-dispatcher/AsyncEventDispatcher.php @@ -4,7 +4,7 @@ class AsyncEventDispatcher extends AbstractAsyncEventDispatcher { - public function dispatch(object $event, string $eventName = null): object + public function dispatch(object $event, ?string $eventName = null): object { $this->parentDispatch($event, $eventName); diff --git a/pkg/async-event-dispatcher/AsyncProcessor.php b/pkg/async-event-dispatcher/AsyncProcessor.php index c89f7e1de..dc61c5381 100644 --- a/pkg/async-event-dispatcher/AsyncProcessor.php +++ b/pkg/async-event-dispatcher/AsyncProcessor.php @@ -25,11 +25,7 @@ public function __construct(Registry $registry, EventDispatcherInterface $dispat $this->registry = $registry; if (false == $dispatcher instanceof AsyncEventDispatcher) { - throw new \InvalidArgumentException(sprintf( - 'The dispatcher argument must be instance of "%s" but got "%s"', - AsyncEventDispatcher::class, - get_class($dispatcher) - )); + throw new \InvalidArgumentException(sprintf('The dispatcher argument must be instance of "%s" but got "%s"', AsyncEventDispatcher::class, $dispatcher::class)); } $this->dispatcher = $dispatcher; diff --git a/pkg/async-event-dispatcher/Commands.php b/pkg/async-event-dispatcher/Commands.php index a00ed6fa9..c2263ee38 100644 --- a/pkg/async-event-dispatcher/Commands.php +++ b/pkg/async-event-dispatcher/Commands.php @@ -4,5 +4,5 @@ final class Commands { - const DISPATCH_ASYNC_EVENTS = 'symfony.dispatch_async_events'; + public const DISPATCH_ASYNC_EVENTS = 'symfony.dispatch_async_events'; } diff --git a/pkg/async-event-dispatcher/DependencyInjection/AsyncTransformersPass.php b/pkg/async-event-dispatcher/DependencyInjection/AsyncTransformersPass.php index afe10217d..89046dd58 100644 --- a/pkg/async-event-dispatcher/DependencyInjection/AsyncTransformersPass.php +++ b/pkg/async-event-dispatcher/DependencyInjection/AsyncTransformersPass.php @@ -7,9 +7,6 @@ class AsyncTransformersPass implements CompilerPassInterface { - /** - * {@inheritdoc} - */ public function process(ContainerBuilder $container) { if (false == $container->hasDefinition('enqueue.events.registry')) { diff --git a/pkg/async-event-dispatcher/EventTransformer.php b/pkg/async-event-dispatcher/EventTransformer.php index cee8635bd..271dffa08 100644 --- a/pkg/async-event-dispatcher/EventTransformer.php +++ b/pkg/async-event-dispatcher/EventTransformer.php @@ -12,15 +12,12 @@ interface EventTransformer * * @return Message */ - public function toMessage($eventName, Event $event = null); + public function toMessage($eventName, ?Event $event = null); /** * If you able to transform message back to event return it. * If you failed to transform for some reason you can return a string status. * - * @param mixed $eventNAme - * @param mixed $eventName - * * @return Event|string|object * * @see Process constants) or an object that implements __toString method. diff --git a/pkg/async-event-dispatcher/PhpSerializerEventTransformer.php b/pkg/async-event-dispatcher/PhpSerializerEventTransformer.php index 1204e9591..9c23883aa 100644 --- a/pkg/async-event-dispatcher/PhpSerializerEventTransformer.php +++ b/pkg/async-event-dispatcher/PhpSerializerEventTransformer.php @@ -6,7 +6,7 @@ class PhpSerializerEventTransformer extends AbstractPhpSerializerEventTransformer implements EventTransformer { - public function toMessage($eventName, Event $event = null) + public function toMessage($eventName, ?Event $event = null) { return $this->context->createMessage(serialize($event)); } diff --git a/pkg/async-event-dispatcher/SimpleRegistry.php b/pkg/async-event-dispatcher/SimpleRegistry.php index 2f39d0cac..e5ba16ef8 100644 --- a/pkg/async-event-dispatcher/SimpleRegistry.php +++ b/pkg/async-event-dispatcher/SimpleRegistry.php @@ -24,9 +24,6 @@ public function __construct(array $eventsMap, array $transformersMap) $this->transformersMap = $transformersMap; } - /** - * {@inheritdoc} - */ public function getTransformerNameForEvent($eventName) { $transformerName = null; @@ -53,9 +50,6 @@ public function getTransformerNameForEvent($eventName) return $transformerName; } - /** - * {@inheritdoc} - */ public function getTransformer($name) { if (false == array_key_exists($name, $this->transformersMap)) { @@ -64,12 +58,8 @@ public function getTransformer($name) $transformer = $this->transformersMap[$name]; - if (false == $transformer instanceof EventTransformer) { - throw new \LogicException(sprintf( - 'The container must return instance of %s but got %s', - EventTransformer::class, - is_object($transformer) ? get_class($transformer) : gettype($transformer) - )); + if (false == $transformer instanceof EventTransformer) { + throw new \LogicException(sprintf('The container must return instance of %s but got %s', EventTransformer::class, is_object($transformer) ? $transformer::class : gettype($transformer))); } return $transformer; diff --git a/pkg/async-event-dispatcher/Tests/SimpleRegistryTest.php b/pkg/async-event-dispatcher/Tests/SimpleRegistryTest.php index 82e1e3fc7..c144e7466 100644 --- a/pkg/async-event-dispatcher/Tests/SimpleRegistryTest.php +++ b/pkg/async-event-dispatcher/Tests/SimpleRegistryTest.php @@ -21,7 +21,7 @@ public function testShouldImplementRegistryInterface() public function testShouldAllowGetTransportNameByEventName() { $registry = new SimpleRegistry([ - 'fooEvent' => 'fooTrans', + 'fooEvent' => 'fooTrans', ], []); $this->assertEquals('fooTrans', $registry->getTransformerNameForEvent('fooEvent')); diff --git a/pkg/dbal/DbalConnectionFactory.php b/pkg/dbal/DbalConnectionFactory.php index 2e0fe702e..305375a89 100644 --- a/pkg/dbal/DbalConnectionFactory.php +++ b/pkg/dbal/DbalConnectionFactory.php @@ -92,7 +92,7 @@ private function establishConnection(): Connection return $this->connection; } - private function parseDsn(string $dsn, array $config = null): array + private function parseDsn(string $dsn, ?array $config = null): array { $parsedDsn = Dsn::parseFirst($dsn); diff --git a/pkg/dbal/DbalContext.php b/pkg/dbal/DbalContext.php index fc1f4a27a..869dd67b8 100644 --- a/pkg/dbal/DbalContext.php +++ b/pkg/dbal/DbalContext.php @@ -56,9 +56,6 @@ public function __construct($connection, array $config = []) } } - /** - * {@inheritdoc} - */ public function createMessage(string $body = '', array $properties = [], array $headers = []): Message { $message = new DbalMessage(); @@ -201,7 +198,7 @@ public function getDbalConnection(): Connection if (false == $this->connection) { $connection = call_user_func($this->connectionFactory); if (false == $connection instanceof Connection) { - throw new \LogicException(sprintf('The factory must return instance of Doctrine\DBAL\Connection. It returns %s', is_object($connection) ? get_class($connection) : gettype($connection))); + throw new \LogicException(sprintf('The factory must return instance of Doctrine\DBAL\Connection. It returns %s', is_object($connection) ? $connection::class : gettype($connection))); } $this->connection = $connection; diff --git a/pkg/dbal/DbalMessage.php b/pkg/dbal/DbalMessage.php index dc5435b17..2485f0691 100644 --- a/pkg/dbal/DbalMessage.php +++ b/pkg/dbal/DbalMessage.php @@ -67,11 +67,6 @@ class DbalMessage implements Message */ private $publishedAt; - /** - * @param string $body - * @param array $properties - * @param array $headers - */ public function __construct(string $body = '', array $properties = [], array $headers = []) { $this->body = $body; @@ -144,7 +139,7 @@ public function setRedelivered(bool $redelivered): void $this->redelivered = $redelivered; } - public function setReplyTo(string $replyTo = null): void + public function setReplyTo(?string $replyTo = null): void { $this->setHeader('reply_to', $replyTo); } @@ -159,7 +154,7 @@ public function getPriority(): ?int return $this->priority; } - public function setPriority(int $priority = null): void + public function setPriority(?int $priority = null): void { $this->priority = $priority; } @@ -172,14 +167,11 @@ public function getDeliveryDelay(): ?int /** * Set delay in milliseconds. */ - public function setDeliveryDelay(int $deliveryDelay = null): void + public function setDeliveryDelay(?int $deliveryDelay = null): void { $this->deliveryDelay = $deliveryDelay; } - /** - * @return int - */ public function getTimeToLive(): ?int { return $this->timeToLive; @@ -188,12 +180,12 @@ public function getTimeToLive(): ?int /** * Set time to live in milliseconds. */ - public function setTimeToLive(int $timeToLive = null): void + public function setTimeToLive(?int $timeToLive = null): void { $this->timeToLive = $timeToLive; } - public function setCorrelationId(string $correlationId = null): void + public function setCorrelationId(?string $correlationId = null): void { $this->setHeader('correlation_id', $correlationId); } @@ -203,7 +195,7 @@ public function getCorrelationId(): ?string return $this->getHeader('correlation_id', null); } - public function setMessageId(string $messageId = null): void + public function setMessageId(?string $messageId = null): void { $this->setHeader('message_id', $messageId); } @@ -220,7 +212,7 @@ public function getTimestamp(): ?int return null === $value ? null : $value; } - public function setTimestamp(int $timestamp = null): void + public function setTimestamp(?int $timestamp = null): void { $this->setHeader('timestamp', $timestamp); } @@ -240,7 +232,7 @@ public function getRedeliverAfter(): int return $this->redeliverAfter; } - public function setRedeliverAfter(int $redeliverAfter = null): void + public function setRedeliverAfter(?int $redeliverAfter = null): void { $this->redeliverAfter = $redeliverAfter; } @@ -250,7 +242,7 @@ public function getPublishedAt(): ?int return $this->publishedAt; } - public function setPublishedAt(int $publishedAt = null): void + public function setPublishedAt(?int $publishedAt = null): void { $this->publishedAt = $publishedAt; } diff --git a/pkg/dbal/DbalProducer.php b/pkg/dbal/DbalProducer.php index f0cdea849..9e3c203dd 100644 --- a/pkg/dbal/DbalProducer.php +++ b/pkg/dbal/DbalProducer.php @@ -81,7 +81,7 @@ public function send(Destination $destination, Message $message): void $delay = $message->getDeliveryDelay(); if ($delay) { if (!is_int($delay)) { - throw new \LogicException(sprintf('Delay must be integer but got: "%s"', is_object($delay) ? get_class($delay) : gettype($delay))); + throw new \LogicException(sprintf('Delay must be integer but got: "%s"', is_object($delay) ? $delay::class : gettype($delay))); } if ($delay <= 0) { @@ -94,7 +94,7 @@ public function send(Destination $destination, Message $message): void $timeToLive = $message->getTimeToLive(); if ($timeToLive) { if (!is_int($timeToLive)) { - throw new \LogicException(sprintf('TimeToLive must be integer but got: "%s"', is_object($timeToLive) ? get_class($timeToLive) : gettype($timeToLive))); + throw new \LogicException(sprintf('TimeToLive must be integer but got: "%s"', is_object($timeToLive) ? $timeToLive::class : gettype($timeToLive))); } if ($timeToLive <= 0) { @@ -128,7 +128,7 @@ public function send(Destination $destination, Message $message): void } } - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { $this->deliveryDelay = $deliveryDelay; @@ -140,7 +140,7 @@ public function getDeliveryDelay(): ?int return $this->deliveryDelay; } - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { $this->priority = $priority; @@ -152,7 +152,7 @@ public function getPriority(): ?int return $this->priority; } - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { $this->timeToLive = $timeToLive; diff --git a/pkg/dbal/DbalSubscriptionConsumer.php b/pkg/dbal/DbalSubscriptionConsumer.php index 145496917..472fdfcb4 100644 --- a/pkg/dbal/DbalSubscriptionConsumer.php +++ b/pkg/dbal/DbalSubscriptionConsumer.php @@ -25,7 +25,7 @@ class DbalSubscriptionConsumer implements SubscriptionConsumer private $subscribers; /** - * @var \Doctrine\DBAL\Connection + * @var Connection */ private $dbal; @@ -139,7 +139,7 @@ public function consume(int $timeout = 0): void public function subscribe(Consumer $consumer, callable $callback): void { if (false == $consumer instanceof DbalConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', DbalConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', DbalConsumer::class, $consumer::class)); } $queueName = $consumer->getQueue()->getQueueName(); @@ -160,7 +160,7 @@ public function subscribe(Consumer $consumer, callable $callback): void public function unsubscribe(Consumer $consumer): void { if (false == $consumer instanceof DbalConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', DbalConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', DbalConsumer::class, $consumer::class)); } $queueName = $consumer->getQueue()->getQueueName(); diff --git a/pkg/dbal/JSON.php b/pkg/dbal/JSON.php index 9f3f4728f..aa4c5f55c 100644 --- a/pkg/dbal/JSON.php +++ b/pkg/dbal/JSON.php @@ -14,10 +14,7 @@ class JSON public static function decode($string) { if (!is_string($string)) { - throw new \InvalidArgumentException(sprintf( - 'Accept only string argument but got: "%s"', - is_object($string) ? get_class($string) : gettype($string) - )); + throw new \InvalidArgumentException(sprintf('Accept only string argument but got: "%s"', is_object($string) ? $string::class : gettype($string))); } // PHP7 fix - empty string and null cause syntax error @@ -26,32 +23,22 @@ public static function decode($string) } $decoded = json_decode($string, true); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return $decoded; } /** - * @param mixed $value - * * @return string */ public static function encode($value) { - $encoded = json_encode($value, JSON_UNESCAPED_UNICODE); - - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'Could not encode value into json. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + $encoded = json_encode($value, \JSON_UNESCAPED_UNICODE); + + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('Could not encode value into json. Error %s and message %s', json_last_error(), json_last_error_msg())); } return $encoded; diff --git a/pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php b/pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php index dda690f9f..5929e1479 100644 --- a/pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php +++ b/pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php @@ -41,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/pkg/dbal/Tests/DbalConsumerTest.php b/pkg/dbal/Tests/DbalConsumerTest.php index 6538af11d..0b78eab00 100644 --- a/pkg/dbal/Tests/DbalConsumerTest.php +++ b/pkg/dbal/Tests/DbalConsumerTest.php @@ -265,7 +265,7 @@ public function isRedelivered(): bool throw new \BadMethodCallException('This should not be called directly'); } - public function setCorrelationId(string $correlationId = null): void + public function setCorrelationId(?string $correlationId = null): void { } @@ -274,7 +274,7 @@ public function getCorrelationId(): ?string throw new \BadMethodCallException('This should not be called directly'); } - public function setMessageId(string $messageId = null): void + public function setMessageId(?string $messageId = null): void { } @@ -288,11 +288,11 @@ public function getTimestamp(): ?int throw new \BadMethodCallException('This should not be called directly'); } - public function setTimestamp(int $timestamp = null): void + public function setTimestamp(?int $timestamp = null): void { } - public function setReplyTo(string $replyTo = null): void + public function setReplyTo(?string $replyTo = null): void { } diff --git a/pkg/dbal/Tests/Functional/DbalConsumerTest.php b/pkg/dbal/Tests/Functional/DbalConsumerTest.php index f5b686cb9..8042598b9 100644 --- a/pkg/dbal/Tests/Functional/DbalConsumerTest.php +++ b/pkg/dbal/Tests/Functional/DbalConsumerTest.php @@ -117,15 +117,15 @@ public function testShouldDeleteExpiredMessage() $this->context->getDbalConnection()->insert( $this->context->getTableName(), [ - 'id' => 'id', - 'published_at' => '123', - 'body' => 'expiredMessage', - 'headers' => json_encode([]), - 'properties' => json_encode([]), - 'queue' => __METHOD__, - 'redelivered' => 0, - 'time_to_live' => time() - 10000, - ]); + 'id' => 'id', + 'published_at' => '123', + 'body' => 'expiredMessage', + 'headers' => json_encode([]), + 'properties' => json_encode([]), + 'queue' => __METHOD__, + 'redelivered' => 0, + 'time_to_live' => time() - 10000, + ]); $message = $context->createMessage('notExpiredMessage'); $message->setRedelivered(false); diff --git a/pkg/dbal/Tests/Spec/DbalConnectionFactoryTest.php b/pkg/dbal/Tests/Spec/DbalConnectionFactoryTest.php index d7fbfcde5..dc39cffe3 100644 --- a/pkg/dbal/Tests/Spec/DbalConnectionFactoryTest.php +++ b/pkg/dbal/Tests/Spec/DbalConnectionFactoryTest.php @@ -7,9 +7,6 @@ class DbalConnectionFactoryTest extends ConnectionFactorySpec { - /** - * {@inheritdoc} - */ protected function createConnectionFactory() { return new DbalConnectionFactory(); diff --git a/pkg/dbal/Tests/Spec/DbalMessageTest.php b/pkg/dbal/Tests/Spec/DbalMessageTest.php index c9ce855df..ee5bdcf6c 100644 --- a/pkg/dbal/Tests/Spec/DbalMessageTest.php +++ b/pkg/dbal/Tests/Spec/DbalMessageTest.php @@ -7,9 +7,6 @@ class DbalMessageTest extends MessageSpec { - /** - * {@inheritdoc} - */ protected function createMessage() { return new DbalMessage(); diff --git a/pkg/dbal/Tests/Spec/DbalQueueTest.php b/pkg/dbal/Tests/Spec/DbalQueueTest.php index a9eebbb88..690f7e1d6 100644 --- a/pkg/dbal/Tests/Spec/DbalQueueTest.php +++ b/pkg/dbal/Tests/Spec/DbalQueueTest.php @@ -7,9 +7,6 @@ class DbalQueueTest extends QueueSpec { - /** - * {@inheritdoc} - */ protected function createQueue() { return new DbalDestination(self::EXPECTED_QUEUE_NAME); diff --git a/pkg/dbal/Tests/Spec/DbalTopicTest.php b/pkg/dbal/Tests/Spec/DbalTopicTest.php index bb9885ea8..4bd554681 100644 --- a/pkg/dbal/Tests/Spec/DbalTopicTest.php +++ b/pkg/dbal/Tests/Spec/DbalTopicTest.php @@ -7,9 +7,6 @@ class DbalTopicTest extends TopicSpec { - /** - * {@inheritdoc} - */ protected function createTopic() { return new DbalDestination(self::EXPECTED_TOPIC_NAME); diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalContextTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalContextTest.php index f147f63b4..f235dd50a 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalContextTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalContextTest.php @@ -11,9 +11,6 @@ class DbalContextTest extends ContextSpec { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalProducerTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalProducerTest.php index 86abe4f63..99cfa2aa6 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalProducerTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalProducerTest.php @@ -11,9 +11,6 @@ class DbalProducerTest extends ProducerSpec { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createProducer() { return $this->createDbalContext()->createProducer(); diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalRequeueMessageTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalRequeueMessageTest.php index 7dcec7a75..a642d7288 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalRequeueMessageTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalRequeueMessageTest.php @@ -11,9 +11,6 @@ class DbalRequeueMessageTest extends RequeueMessageSpec { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveDelayedMessageFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveDelayedMessageFromQueueTest.php index 227ac9705..2455217d6 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveDelayedMessageFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveDelayedMessageFromQueueTest.php @@ -11,9 +11,6 @@ class DbalSendAndReceiveDelayedMessageFromQueueTest extends SendAndReceiveDelaye { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php index 23a5855b5..6926a3d57 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php @@ -32,8 +32,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param DbalContext $context * * @return DbalMessage diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php index fe863e4cc..7ec1dd64f 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php @@ -11,9 +11,6 @@ class DbalSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTi { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromQueueTest.php index 2d8c7979f..798e4b844 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromQueueTest.php @@ -11,9 +11,6 @@ class DbalSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromTopicTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromTopicTest.php index 5a715a414..1d6f99456 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromTopicTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveFromTopicTest.php @@ -11,9 +11,6 @@ class DbalSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromQueueTest.php index 7f64871c4..d96cb85a4 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromQueueTest.php @@ -11,9 +11,6 @@ class DbalSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFrom { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromTopicTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromTopicTest.php index 8ca133dd8..b211fc0ab 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromTopicTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendToAndReceiveNoWaitFromTopicTest.php @@ -11,9 +11,6 @@ class DbalSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFrom { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php index a1ebe3a9b..015f1b716 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php @@ -18,8 +18,6 @@ class DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subscri /** * @return DbalContext - * - * {@inheritdoc} */ protected function createContext() { @@ -28,8 +26,6 @@ protected function createContext() /** * @param DbalContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php index df4b75ee7..37c406804 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php @@ -18,8 +18,6 @@ class DbalSubscriptionConsumerConsumeUntilUnsubscribedTest extends SubscriptionC /** * @return DbalContext - * - * {@inheritdoc} */ protected function createContext() { @@ -28,8 +26,6 @@ protected function createContext() /** * @param DbalContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerStopOnFalseTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerStopOnFalseTest.php index 427195486..ad59c9e6f 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerStopOnFalseTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalSubscriptionConsumerStopOnFalseTest.php @@ -18,8 +18,6 @@ class DbalSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerStopOn /** * @return DbalContext - * - * {@inheritdoc} */ protected function createContext() { @@ -28,8 +26,6 @@ protected function createContext() /** * @param DbalContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalContextTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalContextTest.php index 89aa1d45d..b07978cbd 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalContextTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalContextTest.php @@ -11,9 +11,6 @@ class DbalContextTest extends ContextSpec { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalProducerTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalProducerTest.php index 533d032e9..aa8894de3 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalProducerTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalProducerTest.php @@ -11,9 +11,6 @@ class DbalProducerTest extends ProducerSpec { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createProducer() { return $this->createDbalContext()->createProducer(); diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalRequeueMessageTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalRequeueMessageTest.php index e61f5a352..300a572eb 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalRequeueMessageTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalRequeueMessageTest.php @@ -11,9 +11,6 @@ class DbalRequeueMessageTest extends RequeueMessageSpec { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveDelayedMessageFromQueueTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveDelayedMessageFromQueueTest.php index f33c5688b..4d915c3b5 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveDelayedMessageFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveDelayedMessageFromQueueTest.php @@ -11,9 +11,6 @@ class DbalSendAndReceiveDelayedMessageFromQueueTest extends SendAndReceiveDelaye { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php index f6d048549..556f53b00 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php @@ -32,8 +32,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param DbalContext $context * * @return DbalMessage diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php index 99b007770..db92febe3 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceiveTimeToLiveMessagesFromQueueTest.php @@ -11,9 +11,6 @@ class DbalSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTi { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromQueueTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromQueueTest.php index c486f0f37..63e4456f0 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromQueueTest.php @@ -11,9 +11,6 @@ class DbalSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromTopicTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromTopicTest.php index 0802c0935..a2989fd54 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromTopicTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveFromTopicTest.php @@ -11,9 +11,6 @@ class DbalSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromQueueTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromQueueTest.php index 74e13d89f..9a08f3676 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromQueueTest.php @@ -11,9 +11,6 @@ class DbalSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFrom { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromTopicTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromTopicTest.php index 0b6b30c17..4383acd36 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromTopicTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendToAndReceiveNoWaitFromTopicTest.php @@ -11,9 +11,6 @@ class DbalSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFrom { use CreateDbalContextTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->createDbalContext(); diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php index d50da8acf..d2c8ee22e 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php @@ -18,8 +18,6 @@ class DbalSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subscri /** * @return DbalContext - * - * {@inheritdoc} */ protected function createContext() { @@ -28,8 +26,6 @@ protected function createContext() /** * @param DbalContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php index 64473a30f..892adf372 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerConsumeUntilUnsubscribedTest.php @@ -18,8 +18,6 @@ class DbalSubscriptionConsumerConsumeUntilUnsubscribedTest extends SubscriptionC /** * @return DbalContext - * - * {@inheritdoc} */ protected function createContext() { @@ -28,8 +26,6 @@ protected function createContext() /** * @param DbalContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerStopOnFalseTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerStopOnFalseTest.php index 2b493ba84..9eeb918b8 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerStopOnFalseTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSubscriptionConsumerStopOnFalseTest.php @@ -18,8 +18,6 @@ class DbalSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerStopOn /** * @return DbalContext - * - * {@inheritdoc} */ protected function createContext() { @@ -28,8 +26,6 @@ protected function createContext() /** * @param DbalContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/dbal/examples/consume.php b/pkg/dbal/examples/consume.php index 6b404c93a..f63cf8a77 100644 --- a/pkg/dbal/examples/consume.php +++ b/pkg/dbal/examples/consume.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\Dbal\DbalConnectionFactory; @@ -35,7 +35,7 @@ while (true) { if ($m = $consumer->receive(1000)) { $consumer->acknowledge($m); - echo 'Received message: '.$m->getBody().PHP_EOL; + echo 'Received message: '.$m->getBody().\PHP_EOL; } } diff --git a/pkg/dbal/examples/produce.php b/pkg/dbal/examples/produce.php index c13b4f3b0..9f282bd0b 100644 --- a/pkg/dbal/examples/produce.php +++ b/pkg/dbal/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\Dbal\DbalConnectionFactory; @@ -34,7 +34,7 @@ while (true) { $context->createProducer()->send($destination, $message); - echo 'Sent message: '.$message->getBody().PHP_EOL; + echo 'Sent message: '.$message->getBody().\PHP_EOL; sleep(1); } diff --git a/pkg/dsn/Dsn.php b/pkg/dsn/Dsn.php index a5cc139b2..f46d7c056 100644 --- a/pkg/dsn/Dsn.php +++ b/pkg/dsn/Dsn.php @@ -66,7 +66,7 @@ public function __construct( ?int $port, ?string $path, ?string $queryString, - array $query + array $query, ) { $this->scheme = $scheme; $this->schemeProtocol = $schemeProtocol; @@ -140,27 +140,27 @@ public function getQuery(): array return $this->queryBag->toArray(); } - public function getString(string $name, string $default = null): ?string + public function getString(string $name, ?string $default = null): ?string { return $this->queryBag->getString($name, $default); } - public function getDecimal(string $name, int $default = null): ?int + public function getDecimal(string $name, ?int $default = null): ?int { return $this->queryBag->getDecimal($name, $default); } - public function getOctal(string $name, int $default = null): ?int + public function getOctal(string $name, ?int $default = null): ?int { return $this->queryBag->getOctal($name, $default); } - public function getFloat(string $name, float $default = null): ?float + public function getFloat(string $name, ?float $default = null): ?float { return $this->queryBag->getFloat($name, $default); } - public function getBool(string $name, bool $default = null): ?bool + public function getBool(string $name, ?bool $default = null): ?bool { return $this->queryBag->getBool($name, $default); } @@ -192,14 +192,12 @@ public static function parseFirst(string $dsn): ?self } /** - * @param string $dsn - * * @return Dsn[] */ public static function parse(string $dsn): array { - if (false === strpos($dsn, ':')) { - throw new \LogicException(sprintf('The DSN is invalid. It does not have scheme separator ":".')); + if (!str_contains($dsn, ':')) { + throw new \LogicException('The DSN is invalid. It does not have scheme separator ":".'); } list($scheme, $dsnWithoutScheme) = explode(':', $dsn, 2); @@ -215,28 +213,28 @@ public static function parse(string $dsn): array unset($schemeParts[0]); $schemeExtensions = array_values($schemeParts); - $user = parse_url($dsn, PHP_URL_USER) ?: null; + $user = parse_url($dsn, \PHP_URL_USER) ?: null; if (is_string($user)) { $user = rawurldecode($user); } - $password = parse_url($dsn, PHP_URL_PASS) ?: null; + $password = parse_url($dsn, \PHP_URL_PASS) ?: null; if (is_string($password)) { $password = rawurldecode($password); } - $path = parse_url($dsn, PHP_URL_PATH) ?: null; + $path = parse_url($dsn, \PHP_URL_PATH) ?: null; if ($path) { $path = rawurldecode($path); } $query = []; - $queryString = parse_url($dsn, PHP_URL_QUERY) ?: null; + $queryString = parse_url($dsn, \PHP_URL_QUERY) ?: null; if (is_string($queryString)) { - $query = self::httpParseQuery($queryString, '&', PHP_QUERY_RFC3986); + $query = self::httpParseQuery($queryString, '&', \PHP_QUERY_RFC3986); } $hostsPorts = ''; - if (0 === strpos($dsnWithoutScheme, '//')) { + if (str_starts_with($dsnWithoutScheme, '//')) { $dsnWithoutScheme = substr($dsnWithoutScheme, 2); $dsnWithoutUserPassword = explode('@', $dsnWithoutScheme, 2); $dsnWithoutUserPassword = 2 === count($dsnWithoutUserPassword) ? @@ -299,7 +297,7 @@ public static function parse(string $dsn): array /** * based on http://php.net/manual/en/function.parse-str.php#119484 with some slight modifications. */ - private static function httpParseQuery(string $queryString, string $argSeparator = '&', int $decType = PHP_QUERY_RFC1738): array + private static function httpParseQuery(string $queryString, string $argSeparator = '&', int $decType = \PHP_QUERY_RFC1738): array { $result = []; $parts = explode($argSeparator, $queryString); @@ -308,11 +306,11 @@ private static function httpParseQuery(string $queryString, string $argSeparator list($paramName, $paramValue) = explode('=', $part, 2); switch ($decType) { - case PHP_QUERY_RFC3986: + case \PHP_QUERY_RFC3986: $paramName = rawurldecode($paramName); $paramValue = rawurldecode($paramValue); break; - case PHP_QUERY_RFC1738: + case \PHP_QUERY_RFC1738: default: $paramName = urldecode($paramName); $paramValue = urldecode($paramValue); diff --git a/pkg/dsn/QueryBag.php b/pkg/dsn/QueryBag.php index 53d82b8ed..ea15aa854 100644 --- a/pkg/dsn/QueryBag.php +++ b/pkg/dsn/QueryBag.php @@ -21,12 +21,12 @@ public function toArray(): array return $this->query; } - public function getString(string $name, string $default = null): ?string + public function getString(string $name, ?string $default = null): ?string { return array_key_exists($name, $this->query) ? $this->query[$name] : $default; } - public function getDecimal(string $name, int $default = null): ?int + public function getDecimal(string $name, ?int $default = null): ?int { $value = $this->getString($name); if (null === $value) { @@ -40,7 +40,7 @@ public function getDecimal(string $name, int $default = null): ?int return (int) $value; } - public function getOctal(string $name, int $default = null): ?int + public function getOctal(string $name, ?int $default = null): ?int { $value = $this->getString($name); if (null === $value) { @@ -54,7 +54,7 @@ public function getOctal(string $name, int $default = null): ?int return intval($value, 8); } - public function getFloat(string $name, float $default = null): ?float + public function getFloat(string $name, ?float $default = null): ?float { $value = $this->getString($name); if (null === $value) { @@ -68,7 +68,7 @@ public function getFloat(string $name, float $default = null): ?float return (float) $value; } - public function getBool(string $name, bool $default = null): ?bool + public function getBool(string $name, ?bool $default = null): ?bool { $value = $this->getString($name); if (null === $value) { diff --git a/pkg/enqueue-bundle/Consumption/Extension/DoctrinePingConnectionExtension.php b/pkg/enqueue-bundle/Consumption/Extension/DoctrinePingConnectionExtension.php index 7cc53688d..7fd9527db 100644 --- a/pkg/enqueue-bundle/Consumption/Extension/DoctrinePingConnectionExtension.php +++ b/pkg/enqueue-bundle/Consumption/Extension/DoctrinePingConnectionExtension.php @@ -6,8 +6,6 @@ use Doctrine\Persistence\ManagerRegistry; use Enqueue\Consumption\Context\MessageReceived; use Enqueue\Consumption\MessageReceivedExtensionInterface; -use ErrorException; -use Throwable; class DoctrinePingConnectionExtension implements MessageReceivedExtensionInterface { @@ -49,7 +47,7 @@ public function onMessageReceived(MessageReceived $context): void private function ping(Connection $connection): bool { set_error_handler(static function (int $severity, string $message, string $file, int $line): bool { - throw new ErrorException($message, $severity, $severity, $file, $line); + throw new \ErrorException($message, $severity, $severity, $file, $line); }); try { @@ -58,7 +56,7 @@ private function ping(Connection $connection): bool $connection->executeQuery($dummySelectSQL); return true; - } catch (Throwable $exception) { + } catch (\Throwable $exception) { return false; } finally { restore_error_handler(); diff --git a/pkg/enqueue-bundle/EnqueueBundle.php b/pkg/enqueue-bundle/EnqueueBundle.php index 195013578..5010ba0ed 100644 --- a/pkg/enqueue-bundle/EnqueueBundle.php +++ b/pkg/enqueue-bundle/EnqueueBundle.php @@ -23,11 +23,11 @@ class EnqueueBundle extends Bundle { public function build(ContainerBuilder $container): void { - //transport passes + // transport passes $container->addCompilerPass(new BuildConsumptionExtensionsPass()); $container->addCompilerPass(new BuildProcessorRegistryPass()); - //client passes + // client passes $container->addCompilerPass(new BuildClientConsumptionExtensionsPass()); $container->addCompilerPass(new BuildClientExtensionsPass()); $container->addCompilerPass(new BuildClientTopicSubscriberRoutesPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 100); diff --git a/pkg/enqueue-bundle/Tests/Functional/App/TestAsyncEventTransformer.php b/pkg/enqueue-bundle/Tests/Functional/App/TestAsyncEventTransformer.php index 2a734682d..0a83a04b6 100644 --- a/pkg/enqueue-bundle/Tests/Functional/App/TestAsyncEventTransformer.php +++ b/pkg/enqueue-bundle/Tests/Functional/App/TestAsyncEventTransformer.php @@ -21,9 +21,9 @@ public function __construct(Context $context) $this->context = $context; } - public function toMessage($eventName, Event $event = null) + public function toMessage($eventName, ?Event $event = null) { - if (Event::class === get_class($event)) { + if (Event::class === $event::class) { return $this->context->createMessage(json_encode('')); } diff --git a/pkg/enqueue-bundle/Tests/Functional/Client/ProducerTest.php b/pkg/enqueue-bundle/Tests/Functional/Client/ProducerTest.php index 51db9dc25..29a96aa7d 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Client/ProducerTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Client/ProducerTest.php @@ -4,7 +4,6 @@ use Enqueue\Bundle\Tests\Functional\WebTestCase; use Enqueue\Client\Message; -use Enqueue\Client\Producer; use Enqueue\Client\ProducerInterface; use Enqueue\Client\TraceableProducer; use Enqueue\Rpc\Promise; diff --git a/pkg/enqueue-bundle/Tests/Functional/TestCommandProcessor.php b/pkg/enqueue-bundle/Tests/Functional/TestCommandProcessor.php index 5875a865b..dfc2bb864 100644 --- a/pkg/enqueue-bundle/Tests/Functional/TestCommandProcessor.php +++ b/pkg/enqueue-bundle/Tests/Functional/TestCommandProcessor.php @@ -9,7 +9,7 @@ class TestCommandProcessor implements Processor, CommandSubscriberInterface { - const COMMAND = 'test-command'; + public const COMMAND = 'test-command'; /** * @var Message diff --git a/pkg/enqueue-bundle/Tests/Functional/TestProcessor.php b/pkg/enqueue-bundle/Tests/Functional/TestProcessor.php index 8d21cb7ac..9b54bdf2d 100644 --- a/pkg/enqueue-bundle/Tests/Functional/TestProcessor.php +++ b/pkg/enqueue-bundle/Tests/Functional/TestProcessor.php @@ -9,7 +9,7 @@ class TestProcessor implements Processor, TopicSubscriberInterface { - const TOPIC = 'test-topic'; + public const TOPIC = 'test-topic'; /** * @var Message diff --git a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/ResetServicesExtensionTest.php b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/ResetServicesExtensionTest.php index 76fe29b94..63282a255 100644 --- a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/ResetServicesExtensionTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/ResetServicesExtensionTest.php @@ -16,7 +16,6 @@ class ResetServicesExtensionTest extends TestCase { - public function testItShouldResetServices() { $resetter = $this->createResetterMock(); diff --git a/pkg/enqueue-bundle/Tests/fix_composer_json.php b/pkg/enqueue-bundle/Tests/fix_composer_json.php index 6cc24aa03..5c80237ea 100644 --- a/pkg/enqueue-bundle/Tests/fix_composer_json.php +++ b/pkg/enqueue-bundle/Tests/fix_composer_json.php @@ -7,4 +7,4 @@ $composerJson['config']['platform']['ext-amqp'] = '1.9.3'; $composerJson['config']['platform']['ext-mongo'] = '1.6.14'; -file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, JSON_PRETTY_PRINT)); +file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, \JSON_PRETTY_PRINT)); diff --git a/pkg/enqueue/Client/ChainExtension.php b/pkg/enqueue/Client/ChainExtension.php index d01da379f..655b75f6a 100644 --- a/pkg/enqueue/Client/ChainExtension.php +++ b/pkg/enqueue/Client/ChainExtension.php @@ -67,7 +67,7 @@ public function __construct(array $extensions) } if (false == $extensionValid) { - throw new \LogicException(sprintf('Invalid extension given %s', get_class($extension))); + throw new \LogicException(sprintf('Invalid extension given %s', $extension::class)); } }); } diff --git a/pkg/enqueue/Client/Config.php b/pkg/enqueue/Client/Config.php index 888384207..34057e1c1 100644 --- a/pkg/enqueue/Client/Config.php +++ b/pkg/enqueue/Client/Config.php @@ -4,13 +4,13 @@ class Config { - const TOPIC = 'enqueue.topic'; - const COMMAND = 'enqueue.command'; - const PROCESSOR = 'enqueue.processor'; - const EXPIRE = 'enqueue.expire'; - const PRIORITY = 'enqueue.priority'; - const DELAY = 'enqueue.delay'; - const CONTENT_TYPE = 'enqueue.content_type'; + public const TOPIC = 'enqueue.topic'; + public const COMMAND = 'enqueue.command'; + public const PROCESSOR = 'enqueue.processor'; + public const EXPIRE = 'enqueue.expire'; + public const PRIORITY = 'enqueue.priority'; + public const DELAY = 'enqueue.delay'; + public const CONTENT_TYPE = 'enqueue.content_type'; /** * @var string @@ -66,7 +66,7 @@ public function __construct( string $defaultQueue, string $routerProcessor, array $transportConfig, - array $driverConfig + array $driverConfig, ) { $this->prefix = trim($prefix); $this->app = trim($app); @@ -153,15 +153,15 @@ public function getDriverOptions(): array } public static function create( - string $prefix = null, - string $separator = null, - string $app = null, - string $routerTopic = null, - string $routerQueue = null, - string $defaultQueue = null, - string $routerProcessor = null, + ?string $prefix = null, + ?string $separator = null, + ?string $app = null, + ?string $routerTopic = null, + ?string $routerQueue = null, + ?string $defaultQueue = null, + ?string $routerProcessor = null, array $transportConfig = [], - array $driverConfig = [] + array $driverConfig = [], ): self { return new static( $prefix ?: '', diff --git a/pkg/enqueue/Client/ConsumptionExtension/DelayRedeliveredMessageExtension.php b/pkg/enqueue/Client/ConsumptionExtension/DelayRedeliveredMessageExtension.php index 77e3bc451..475e2cf5b 100644 --- a/pkg/enqueue/Client/ConsumptionExtension/DelayRedeliveredMessageExtension.php +++ b/pkg/enqueue/Client/ConsumptionExtension/DelayRedeliveredMessageExtension.php @@ -9,7 +9,7 @@ class DelayRedeliveredMessageExtension implements MessageReceivedExtensionInterface { - const PROPERTY_REDELIVER_COUNT = 'enqueue.redelivery_count'; + public const PROPERTY_REDELIVER_COUNT = 'enqueue.redelivery_count'; /** * @var DriverInterface @@ -24,8 +24,7 @@ class DelayRedeliveredMessageExtension implements MessageReceivedExtensionInterf private $delay; /** - * @param DriverInterface $driver - * @param int $delay The number of seconds the message should be delayed + * @param int $delay The number of seconds the message should be delayed */ public function __construct(DriverInterface $driver, $delay) { diff --git a/pkg/enqueue/Client/ConsumptionExtension/SetRouterPropertiesExtension.php b/pkg/enqueue/Client/ConsumptionExtension/SetRouterPropertiesExtension.php index c7682f60e..0d2278349 100644 --- a/pkg/enqueue/Client/ConsumptionExtension/SetRouterPropertiesExtension.php +++ b/pkg/enqueue/Client/ConsumptionExtension/SetRouterPropertiesExtension.php @@ -14,9 +14,6 @@ class SetRouterPropertiesExtension implements MessageReceivedExtensionInterface */ private $driver; - /** - * @param DriverInterface $driver - */ public function __construct(DriverInterface $driver) { $this->driver = $driver; diff --git a/pkg/enqueue/Client/ConsumptionExtension/SetupBrokerExtension.php b/pkg/enqueue/Client/ConsumptionExtension/SetupBrokerExtension.php index e35580794..44d610fb9 100644 --- a/pkg/enqueue/Client/ConsumptionExtension/SetupBrokerExtension.php +++ b/pkg/enqueue/Client/ConsumptionExtension/SetupBrokerExtension.php @@ -18,9 +18,6 @@ class SetupBrokerExtension implements StartExtensionInterface */ private $isDone; - /** - * @param DriverInterface $driver - */ public function __construct(DriverInterface $driver) { $this->driver = $driver; diff --git a/pkg/enqueue/Client/DelegateProcessor.php b/pkg/enqueue/Client/DelegateProcessor.php index 0fbe9c200..7582c52dc 100644 --- a/pkg/enqueue/Client/DelegateProcessor.php +++ b/pkg/enqueue/Client/DelegateProcessor.php @@ -20,8 +20,6 @@ public function __construct(ProcessorRegistryInterface $registry) } /** - * {@inheritdoc} - * * @return string|object */ public function process(InteropMessage $message, Context $context) diff --git a/pkg/enqueue/Client/Driver/AmqpDriver.php b/pkg/enqueue/Client/Driver/AmqpDriver.php index be62753bf..1def3fb23 100644 --- a/pkg/enqueue/Client/Driver/AmqpDriver.php +++ b/pkg/enqueue/Client/Driver/AmqpDriver.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Enqueue\Client\Driver; +namespace Enqueue\Client\Driver; use Enqueue\AmqpExt\AmqpProducer; use Enqueue\Client\Message; @@ -45,11 +45,7 @@ public function createTransportMessage(Message $clientMessage): InteropMessage $priorityMap = $this->getPriorityMap(); if ($priority = $clientMessage->getPriority()) { if (false == array_key_exists($priority, $priorityMap)) { - throw new \InvalidArgumentException(sprintf( - 'Cant convert client priority "%s" to transport one. Could be one of "%s"', - $priority, - implode('", "', array_keys($priorityMap)) - )); + throw new \InvalidArgumentException(sprintf('Cant convert client priority "%s" to transport one. Could be one of "%s"', $priority, implode('", "', array_keys($priorityMap)))); } $transportMessage->setPriority($priorityMap[$priority]); @@ -58,7 +54,7 @@ public function createTransportMessage(Message $clientMessage): InteropMessage return $transportMessage; } - public function setupBroker(LoggerInterface $logger = null): void + public function setupBroker(?LoggerInterface $logger = null): void { $logger = $logger ?: new NullLogger(); $log = function ($text, ...$args) use ($logger) { diff --git a/pkg/enqueue/Client/Driver/DbalDriver.php b/pkg/enqueue/Client/Driver/DbalDriver.php index 8b1f32655..34875eff7 100644 --- a/pkg/enqueue/Client/Driver/DbalDriver.php +++ b/pkg/enqueue/Client/Driver/DbalDriver.php @@ -16,7 +16,7 @@ public function __construct(DbalContext $context, ...$args) parent::__construct($context, ...$args); } - public function setupBroker(LoggerInterface $logger = null): void + public function setupBroker(?LoggerInterface $logger = null): void { $logger = $logger ?: new NullLogger(); $log = function ($text, ...$args) use ($logger) { diff --git a/pkg/enqueue/Client/Driver/FsDriver.php b/pkg/enqueue/Client/Driver/FsDriver.php index 9de59c23b..f578b172d 100644 --- a/pkg/enqueue/Client/Driver/FsDriver.php +++ b/pkg/enqueue/Client/Driver/FsDriver.php @@ -1,6 +1,6 @@ context = $context; $this->config = $config; @@ -120,7 +120,7 @@ public function sendToProcessor(Message $message): DriverSendResult return new DriverSendResult($queue, $transportMessage); } - public function setupBroker(LoggerInterface $logger = null): void + public function setupBroker(?LoggerInterface $logger = null): void { } diff --git a/pkg/enqueue/Client/Driver/GpsDriver.php b/pkg/enqueue/Client/Driver/GpsDriver.php index 37a7110c1..32d14f721 100644 --- a/pkg/enqueue/Client/Driver/GpsDriver.php +++ b/pkg/enqueue/Client/Driver/GpsDriver.php @@ -20,7 +20,7 @@ public function __construct(GpsContext $context, ...$args) parent::__construct($context, ...$args); } - public function setupBroker(LoggerInterface $logger = null): void + public function setupBroker(?LoggerInterface $logger = null): void { $logger = $logger ?: new NullLogger(); $log = function ($text, ...$args) use ($logger) { diff --git a/pkg/enqueue/Client/Driver/MongodbDriver.php b/pkg/enqueue/Client/Driver/MongodbDriver.php index 19f2c57d3..1c9cff4bc 100644 --- a/pkg/enqueue/Client/Driver/MongodbDriver.php +++ b/pkg/enqueue/Client/Driver/MongodbDriver.php @@ -16,7 +16,7 @@ public function __construct(MongodbContext $context, ...$args) parent::__construct($context, ...$args); } - public function setupBroker(LoggerInterface $logger = null): void + public function setupBroker(?LoggerInterface $logger = null): void { $logger = $logger ?: new NullLogger(); $log = function ($text, ...$args) use ($logger) { diff --git a/pkg/enqueue/Client/Driver/RabbitMqDriver.php b/pkg/enqueue/Client/Driver/RabbitMqDriver.php index 096de6d26..f215d555e 100644 --- a/pkg/enqueue/Client/Driver/RabbitMqDriver.php +++ b/pkg/enqueue/Client/Driver/RabbitMqDriver.php @@ -1,6 +1,6 @@ debug('[RdKafkaDriver] setup broker'); diff --git a/pkg/enqueue/Client/Driver/SnsQsDriver.php b/pkg/enqueue/Client/Driver/SnsQsDriver.php index 2b1d4f233..f4bde10c2 100644 --- a/pkg/enqueue/Client/Driver/SnsQsDriver.php +++ b/pkg/enqueue/Client/Driver/SnsQsDriver.php @@ -19,7 +19,7 @@ public function __construct(SnsQsContext $context, ...$args) parent::__construct($context, ...$args); } - public function setupBroker(LoggerInterface $logger = null): void + public function setupBroker(?LoggerInterface $logger = null): void { $logger = $logger ?: new NullLogger(); $log = function ($text, ...$args) use ($logger) { diff --git a/pkg/enqueue/Client/Driver/SqsDriver.php b/pkg/enqueue/Client/Driver/SqsDriver.php index bf66c050c..49b696aae 100644 --- a/pkg/enqueue/Client/Driver/SqsDriver.php +++ b/pkg/enqueue/Client/Driver/SqsDriver.php @@ -18,7 +18,7 @@ public function __construct(SqsContext $context, ...$args) parent::__construct($context, ...$args); } - public function setupBroker(LoggerInterface $logger = null): void + public function setupBroker(?LoggerInterface $logger = null): void { $logger = $logger ?: new NullLogger(); $log = function ($text, ...$args) use ($logger) { diff --git a/pkg/enqueue/Client/Driver/StompDriver.php b/pkg/enqueue/Client/Driver/StompDriver.php index 7040c71dd..811ad76e7 100644 --- a/pkg/enqueue/Client/Driver/StompDriver.php +++ b/pkg/enqueue/Client/Driver/StompDriver.php @@ -22,7 +22,7 @@ public function __construct(StompContext $context, ...$args) parent::__construct($context, ...$args); } - public function setupBroker(LoggerInterface $logger = null): void + public function setupBroker(?LoggerInterface $logger = null): void { $logger = $logger ?: new NullLogger(); $logger->debug('[StompDriver] Stomp protocol does not support broker configuration'); diff --git a/pkg/enqueue/Client/Driver/StompManagementClient.php b/pkg/enqueue/Client/Driver/StompManagementClient.php index c068a57df..5880672b5 100644 --- a/pkg/enqueue/Client/Driver/StompManagementClient.php +++ b/pkg/enqueue/Client/Driver/StompManagementClient.php @@ -37,7 +37,7 @@ public function declareExchange(string $name, array $options) return $this->client->exchanges()->create($this->vhost, $name, $options); } - public function bind(string $exchange, string $queue, string $routingKey = null, $arguments = null) + public function bind(string $exchange, string $queue, ?string $routingKey = null, $arguments = null) { return $this->client->bindings()->create($this->vhost, $exchange, $queue, $routingKey, $arguments); } diff --git a/pkg/enqueue/Client/DriverFactory.php b/pkg/enqueue/Client/DriverFactory.php index 0dd9412d8..1d383ac86 100644 --- a/pkg/enqueue/Client/DriverFactory.php +++ b/pkg/enqueue/Client/DriverFactory.php @@ -31,18 +31,10 @@ public function create(ConnectionFactory $factory, Config $config, RouteCollecti $knownDrivers = Resources::getKnownDrivers(); if ($driverInfo = $this->findDriverInfo($dsn, $knownDrivers)) { - throw new \LogicException(sprintf( - 'To use given scheme "%s" a package has to be installed. Run "composer req %s" to add it.', - $dsn->getScheme(), - implode(' ', $driverInfo['packages']) - )); + throw new \LogicException(sprintf('To use given scheme "%s" a package has to be installed. Run "composer req %s" to add it.', $dsn->getScheme(), implode(' ', $driverInfo['packages']))); } - throw new \LogicException(sprintf( - 'A given scheme "%s" is not supported. Maybe it is a custom driver, make sure you registered it with "%s::addDriver".', - $dsn->getScheme(), - Resources::class - )); + throw new \LogicException(sprintf('A given scheme "%s" is not supported. Maybe it is a custom driver, make sure you registered it with "%s::addDriver".', $dsn->getScheme(), Resources::class)); } private function findDriverInfo(Dsn $dsn, array $factories): ?array diff --git a/pkg/enqueue/Client/DriverInterface.php b/pkg/enqueue/Client/DriverInterface.php index 1832e0f9a..9d1dde679 100644 --- a/pkg/enqueue/Client/DriverInterface.php +++ b/pkg/enqueue/Client/DriverInterface.php @@ -27,7 +27,7 @@ public function createRouteQueue(Route $route): InteropQueue; * Prepare broker for work. * Creates all required queues, exchanges, topics, bindings etc. */ - public function setupBroker(LoggerInterface $logger = null): void; + public function setupBroker(?LoggerInterface $logger = null): void; public function getConfig(): Config; diff --git a/pkg/enqueue/Client/Extension/PrepareBodyExtension.php b/pkg/enqueue/Client/Extension/PrepareBodyExtension.php index eeb0ded03..e7924548c 100644 --- a/pkg/enqueue/Client/Extension/PrepareBodyExtension.php +++ b/pkg/enqueue/Client/Extension/PrepareBodyExtension.php @@ -32,10 +32,7 @@ private function prepareBody(Message $message): void // only array of scalars is allowed. array_walk_recursive($body, function ($value) { if (!is_scalar($value) && null !== $value) { - throw new \LogicException(sprintf( - 'The message\'s body must be an array of scalars. Found not scalar in the array: %s', - is_object($value) ? get_class($value) : gettype($value) - )); + throw new \LogicException(sprintf('The message\'s body must be an array of scalars. Found not scalar in the array: %s', is_object($value) ? $value::class : gettype($value))); } }); @@ -45,10 +42,7 @@ private function prepareBody(Message $message): void $contentType = $contentType ?: 'application/json'; $body = JSON::encode($body); } else { - throw new \InvalidArgumentException(sprintf( - 'The message\'s body must be either null, scalar, array or object (implements \JsonSerializable). Got: %s', - is_object($body) ? get_class($body) : gettype($body) - )); + throw new \InvalidArgumentException(sprintf('The message\'s body must be either null, scalar, array or object (implements \JsonSerializable). Got: %s', is_object($body) ? $body::class : gettype($body))); } $message->setContentType($contentType); diff --git a/pkg/enqueue/Client/Message.php b/pkg/enqueue/Client/Message.php index b1cc9c27a..7e51ea10d 100644 --- a/pkg/enqueue/Client/Message.php +++ b/pkg/enqueue/Client/Message.php @@ -7,12 +7,12 @@ class Message /** * @const string */ - const SCOPE_MESSAGE_BUS = 'enqueue.scope.message_bus'; + public const SCOPE_MESSAGE_BUS = 'enqueue.scope.message_bus'; /** * @const string */ - const SCOPE_APP = 'enqueue.scope.app'; + public const SCOPE_APP = 'enqueue.scope.app'; /** * @var string|null @@ -256,10 +256,8 @@ public function getHeaders() } /** - * @param string $name - * @param mixed $default - * - * @return mixed + * @param string $name + * @param mixed|null $default */ public function getHeader($name, $default = null) { @@ -268,16 +266,12 @@ public function getHeader($name, $default = null) /** * @param string $name - * @param mixed $value */ public function setHeader($name, $value) { $this->headers[$name] = $value; } - /** - * @param array $headers - */ public function setHeaders(array $headers) { $this->headers = $headers; @@ -291,19 +285,14 @@ public function getProperties() return $this->properties; } - /** - * @param array $properties - */ public function setProperties(array $properties) { $this->properties = $properties; } /** - * @param string $name - * @param mixed $default - * - * @return mixed + * @param string $name + * @param mixed|null $default */ public function getProperty($name, $default = null) { @@ -312,7 +301,6 @@ public function getProperty($name, $default = null) /** * @param string $name - * @param mixed $value */ public function setProperty($name, $value) { diff --git a/pkg/enqueue/Client/MessagePriority.php b/pkg/enqueue/Client/MessagePriority.php index efa658c14..e14be9a7d 100644 --- a/pkg/enqueue/Client/MessagePriority.php +++ b/pkg/enqueue/Client/MessagePriority.php @@ -4,9 +4,9 @@ class MessagePriority { - const VERY_LOW = 'enqueue.message_queue.client.very_low_message_priority'; - const LOW = 'enqueue.message_queue.client.low_message_priority'; - const NORMAL = 'enqueue.message_queue.client.normal_message_priority'; - const HIGH = 'enqueue.message_queue.client.high_message_priority'; - const VERY_HIGH = 'enqueue.message_queue.client.very_high_message_priority'; + public const VERY_LOW = 'enqueue.message_queue.client.very_low_message_priority'; + public const LOW = 'enqueue.message_queue.client.low_message_priority'; + public const NORMAL = 'enqueue.message_queue.client.normal_message_priority'; + public const HIGH = 'enqueue.message_queue.client.high_message_priority'; + public const VERY_HIGH = 'enqueue.message_queue.client.very_high_message_priority'; } diff --git a/pkg/enqueue/Client/PostSend.php b/pkg/enqueue/Client/PostSend.php index 7bce74155..5d9526ea4 100644 --- a/pkg/enqueue/Client/PostSend.php +++ b/pkg/enqueue/Client/PostSend.php @@ -22,7 +22,7 @@ public function __construct( ProducerInterface $producer, DriverInterface $driver, Destination $transportDestination, - TransportMessage $transportMessage + TransportMessage $transportMessage, ) { $this->message = $message; $this->producer = $producer; diff --git a/pkg/enqueue/Client/PreSend.php b/pkg/enqueue/Client/PreSend.php index afd64012f..b60f90b08 100644 --- a/pkg/enqueue/Client/PreSend.php +++ b/pkg/enqueue/Client/PreSend.php @@ -18,7 +18,7 @@ public function __construct( string $commandOrTopic, Message $message, ProducerInterface $producer, - DriverInterface $driver + DriverInterface $driver, ) { $this->message = $message; $this->commandOrTopic = $commandOrTopic; @@ -48,7 +48,7 @@ public function changeTopic(string $newTopic): void $this->commandOrTopic = $newTopic; } - public function changeBody($body, string $contentType = null): void + public function changeBody($body, ?string $contentType = null): void { $this->message->setBody($body); diff --git a/pkg/enqueue/Client/Producer.php b/pkg/enqueue/Client/Producer.php index 6ea612b8c..db50744a2 100644 --- a/pkg/enqueue/Client/Producer.php +++ b/pkg/enqueue/Client/Producer.php @@ -27,7 +27,7 @@ final class Producer implements ProducerInterface public function __construct( DriverInterface $driver, RpcFactory $rpcFactory, - ExtensionInterface $extension = null + ?ExtensionInterface $extension = null, ) { $this->driver = $driver; $this->rpcFactory = $rpcFactory; @@ -97,10 +97,7 @@ public function sendCommand(string $command, $message, bool $needReply = false): private function doSend(Message $message): void { if (false === is_string($message->getBody())) { - throw new \LogicException(sprintf( - 'The message body must be string at this stage, got "%s". Make sure you passed string as message or there is an extension that converts custom input to string.', - is_object($message->getBody()) ? get_class($message->getBody()) : gettype($message->getBody()) - )); + throw new \LogicException(sprintf('The message body must be string at this stage, got "%s". Make sure you passed string as message or there is an extension that converts custom input to string.', is_object($message->getBody()) ? get_class($message->getBody()) : gettype($message->getBody()))); } if ($message->getProperty(Config::PROCESSOR)) { diff --git a/pkg/enqueue/Client/Resources.php b/pkg/enqueue/Client/Resources.php index 6ea5988a1..a5cc6847c 100644 --- a/pkg/enqueue/Client/Resources.php +++ b/pkg/enqueue/Client/Resources.php @@ -26,7 +26,7 @@ final class Resources * * @var array */ - private static $knownDrivers = null; + private static $knownDrivers; private function __construct() { diff --git a/pkg/enqueue/Client/Route.php b/pkg/enqueue/Client/Route.php index 5c98fa6b8..8b9e31e36 100644 --- a/pkg/enqueue/Client/Route.php +++ b/pkg/enqueue/Client/Route.php @@ -4,9 +4,9 @@ final class Route { - const TOPIC = 'enqueue.client.topic_route'; + public const TOPIC = 'enqueue.client.topic_route'; - const COMMAND = 'enqueue.client.command_route'; + public const COMMAND = 'enqueue.client.command_route'; /** * @var string @@ -32,7 +32,7 @@ public function __construct( string $source, string $sourceType, string $processor, - array $options = [] + array $options = [], ) { $this->source = $source; $this->sourceType = $sourceType; diff --git a/pkg/enqueue/Client/TraceableProducer.php b/pkg/enqueue/Client/TraceableProducer.php index 59b0c7b01..b0bd613c3 100644 --- a/pkg/enqueue/Client/TraceableProducer.php +++ b/pkg/enqueue/Client/TraceableProducer.php @@ -71,7 +71,7 @@ public function clearTraces(): void $this->traces = []; } - private function collectTrace(string $topic = null, string $command = null, $message): void + private function collectTrace(?string $topic, ?string $command, $message): void { $trace = [ 'topic' => $topic, diff --git a/pkg/enqueue/ConnectionFactoryFactory.php b/pkg/enqueue/ConnectionFactoryFactory.php index d89c671e7..d23518c1b 100644 --- a/pkg/enqueue/ConnectionFactoryFactory.php +++ b/pkg/enqueue/ConnectionFactoryFactory.php @@ -29,18 +29,10 @@ public function create($config): ConnectionFactory $knownConnections = Resources::getKnownConnections(); if ($factoryClass = $this->findFactoryClass($dsn, $knownConnections)) { - throw new \LogicException(sprintf( - 'To use given scheme "%s" a package has to be installed. Run "composer req %s" to add it.', - $dsn->getScheme(), - $knownConnections[$factoryClass]['package'] - )); + throw new \LogicException(sprintf('To use given scheme "%s" a package has to be installed. Run "composer req %s" to add it.', $dsn->getScheme(), $knownConnections[$factoryClass]['package'])); } - throw new \LogicException(sprintf( - 'A given scheme "%s" is not supported. Maybe it is a custom connection, make sure you registered it with "%s::addConnection".', - $dsn->getScheme(), - Resources::class - )); + throw new \LogicException(sprintf('A given scheme "%s" is not supported. Maybe it is a custom connection, make sure you registered it with "%s::addConnection".', $dsn->getScheme(), Resources::class)); } private function findFactoryClass(Dsn $dsn, array $factories): ?string diff --git a/pkg/enqueue/ConnectionFactoryFactoryInterface.php b/pkg/enqueue/ConnectionFactoryFactoryInterface.php index d55808cdb..f4ca4a6d3 100644 --- a/pkg/enqueue/ConnectionFactoryFactoryInterface.php +++ b/pkg/enqueue/ConnectionFactoryFactoryInterface.php @@ -13,7 +13,6 @@ interface ConnectionFactoryFactoryInterface * The other array options are treated as default values. * Options from DSN overwrite them. * - * * @param string|array $config * * @throws \InvalidArgumentException if invalid config provided diff --git a/pkg/enqueue/Consumption/CallbackProcessor.php b/pkg/enqueue/Consumption/CallbackProcessor.php index 988b76529..d15978fcb 100644 --- a/pkg/enqueue/Consumption/CallbackProcessor.php +++ b/pkg/enqueue/Consumption/CallbackProcessor.php @@ -13,17 +13,11 @@ class CallbackProcessor implements Processor */ private $callback; - /** - * @param callable $callback - */ public function __construct(callable $callback) { $this->callback = $callback; } - /** - * {@inheritdoc} - */ public function process(InteropMessage $message, Context $context) { return call_user_func($this->callback, $message, $context); diff --git a/pkg/enqueue/Consumption/ChainExtension.php b/pkg/enqueue/Consumption/ChainExtension.php index e2c11a1f6..83b4eba3a 100644 --- a/pkg/enqueue/Consumption/ChainExtension.php +++ b/pkg/enqueue/Consumption/ChainExtension.php @@ -117,7 +117,7 @@ public function __construct(array $extensions) } if (false == $extensionValid) { - throw new \LogicException(sprintf('Invalid extension given %s', get_class($extension))); + throw new \LogicException(sprintf('Invalid extension given %s', $extension::class)); } }); } diff --git a/pkg/enqueue/Consumption/Context/End.php b/pkg/enqueue/Consumption/Context/End.php index ec8c1f7df..07853b3d3 100644 --- a/pkg/enqueue/Consumption/Context/End.php +++ b/pkg/enqueue/Consumption/Context/End.php @@ -37,7 +37,7 @@ public function __construct( int $startTime, int $endTime, LoggerInterface $logger, - ?int $exitStatus = null + ?int $exitStatus = null, ) { $this->context = $context; $this->logger = $logger; diff --git a/pkg/enqueue/Consumption/Context/MessageReceived.php b/pkg/enqueue/Consumption/Context/MessageReceived.php index ad6b6b969..35abf1ca8 100644 --- a/pkg/enqueue/Consumption/Context/MessageReceived.php +++ b/pkg/enqueue/Consumption/Context/MessageReceived.php @@ -52,7 +52,7 @@ public function __construct( Message $message, Processor $processor, int $receivedAt, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->context = $context; $this->consumer = $consumer; diff --git a/pkg/enqueue/Consumption/Context/PostMessageReceived.php b/pkg/enqueue/Consumption/Context/PostMessageReceived.php index 91b532656..23df2c849 100644 --- a/pkg/enqueue/Consumption/Context/PostMessageReceived.php +++ b/pkg/enqueue/Consumption/Context/PostMessageReceived.php @@ -56,7 +56,7 @@ public function __construct( Message $message, $result, int $receivedAt, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->context = $context; $this->consumer = $consumer; diff --git a/pkg/enqueue/Consumption/Exception/InvalidArgumentException.php b/pkg/enqueue/Consumption/Exception/InvalidArgumentException.php index da6015d27..76ea83ad7 100644 --- a/pkg/enqueue/Consumption/Exception/InvalidArgumentException.php +++ b/pkg/enqueue/Consumption/Exception/InvalidArgumentException.php @@ -5,7 +5,6 @@ class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { /** - * @param mixed $argument * @param string $class * * @throws static @@ -13,11 +12,7 @@ class InvalidArgumentException extends \InvalidArgumentException implements Exce public static function assertInstanceOf($argument, $class) { if (false == $argument instanceof $class) { - throw new static(sprintf( - 'The argument must be an instance of %s but got %s.', - $class, - is_object($argument) ? get_class($argument) : gettype($argument) - )); + throw new static(sprintf('The argument must be an instance of %s but got %s.', $class, is_object($argument) ? $argument::class : gettype($argument))); } } } diff --git a/pkg/enqueue/Consumption/Extension/LimitConsumedMessagesExtension.php b/pkg/enqueue/Consumption/Extension/LimitConsumedMessagesExtension.php index e89957a72..0dc6feceb 100644 --- a/pkg/enqueue/Consumption/Extension/LimitConsumedMessagesExtension.php +++ b/pkg/enqueue/Consumption/Extension/LimitConsumedMessagesExtension.php @@ -20,9 +20,6 @@ class LimitConsumedMessagesExtension implements PreConsumeExtensionInterface, Po */ protected $messageConsumed; - /** - * @param int $messageLimit - */ public function __construct(int $messageLimit) { $this->messageLimit = $messageLimit; diff --git a/pkg/enqueue/Consumption/Extension/LimitConsumerMemoryExtension.php b/pkg/enqueue/Consumption/Extension/LimitConsumerMemoryExtension.php index 13d4a2898..7edbf232c 100644 --- a/pkg/enqueue/Consumption/Extension/LimitConsumerMemoryExtension.php +++ b/pkg/enqueue/Consumption/Extension/LimitConsumerMemoryExtension.php @@ -23,10 +23,7 @@ class LimitConsumerMemoryExtension implements PreConsumeExtensionInterface, Post public function __construct($memoryLimit) { if (false == is_int($memoryLimit)) { - throw new \InvalidArgumentException(sprintf( - 'Expected memory limit is int but got: "%s"', - is_object($memoryLimit) ? get_class($memoryLimit) : gettype($memoryLimit) - )); + throw new \InvalidArgumentException(sprintf('Expected memory limit is int but got: "%s"', is_object($memoryLimit) ? $memoryLimit::class : gettype($memoryLimit))); } $this->memoryLimit = $memoryLimit * 1024 * 1024; diff --git a/pkg/enqueue/Consumption/Extension/LimitConsumptionTimeExtension.php b/pkg/enqueue/Consumption/Extension/LimitConsumptionTimeExtension.php index f0a577930..1953aa2e6 100644 --- a/pkg/enqueue/Consumption/Extension/LimitConsumptionTimeExtension.php +++ b/pkg/enqueue/Consumption/Extension/LimitConsumptionTimeExtension.php @@ -17,9 +17,6 @@ class LimitConsumptionTimeExtension implements PreConsumeExtensionInterface, Pos */ protected $timeLimit; - /** - * @param \DateTime $timeLimit - */ public function __construct(\DateTime $timeLimit) { $this->timeLimit = $timeLimit; @@ -53,8 +50,8 @@ protected function shouldBeStopped(LoggerInterface $logger): bool $logger->debug(sprintf( '[LimitConsumptionTimeExtension] Execution interrupted as limit time has passed.'. ' now: "%s", time-limit: "%s"', - $now->format(DATE_ISO8601), - $this->timeLimit->format(DATE_ISO8601) + $now->format(\DATE_ISO8601), + $this->timeLimit->format(\DATE_ISO8601) )); return true; diff --git a/pkg/enqueue/Consumption/Extension/LoggerExtension.php b/pkg/enqueue/Consumption/Extension/LoggerExtension.php index 0de2739c1..90e92be8a 100644 --- a/pkg/enqueue/Consumption/Extension/LoggerExtension.php +++ b/pkg/enqueue/Consumption/Extension/LoggerExtension.php @@ -13,9 +13,6 @@ class LoggerExtension implements InitLoggerExtensionInterface */ private $logger; - /** - * @param LoggerInterface $logger - */ public function __construct(LoggerInterface $logger) { $this->logger = $logger; @@ -28,7 +25,7 @@ public function onInitLogger(InitLogger $context): void if ($previousLogger !== $this->logger) { $context->changeLogger($this->logger); - $this->logger->debug(sprintf('Change logger from "%s" to "%s"', get_class($previousLogger), get_class($this->logger))); + $this->logger->debug(sprintf('Change logger from "%s" to "%s"', $previousLogger::class, get_class($this->logger))); } } } diff --git a/pkg/enqueue/Consumption/Extension/NicenessExtension.php b/pkg/enqueue/Consumption/Extension/NicenessExtension.php index 983e04b0e..436a8ec0f 100644 --- a/pkg/enqueue/Consumption/Extension/NicenessExtension.php +++ b/pkg/enqueue/Consumption/Extension/NicenessExtension.php @@ -20,10 +20,7 @@ class NicenessExtension implements StartExtensionInterface public function __construct($niceness) { if (false === is_int($niceness)) { - throw new \InvalidArgumentException(sprintf( - 'Expected niceness value is int but got: "%s"', - is_object($niceness) ? get_class($niceness) : gettype($niceness) - )); + throw new \InvalidArgumentException(sprintf('Expected niceness value is int but got: "%s"', is_object($niceness) ? $niceness::class : gettype($niceness))); } $this->niceness = $niceness; @@ -34,10 +31,7 @@ public function onStart(Start $context): void if (0 !== $this->niceness) { $changed = @proc_nice($this->niceness); if (!$changed) { - throw new \InvalidArgumentException(sprintf( - 'Cannot change process niceness, got warning: "%s"', - error_get_last()['message'] - )); + throw new \InvalidArgumentException(sprintf('Cannot change process niceness, got warning: "%s"', error_get_last()['message'])); } } } diff --git a/pkg/enqueue/Consumption/Extension/SignalExtension.php b/pkg/enqueue/Consumption/Extension/SignalExtension.php index 67354b99d..8ea5307d5 100644 --- a/pkg/enqueue/Consumption/Extension/SignalExtension.php +++ b/pkg/enqueue/Consumption/Extension/SignalExtension.php @@ -33,9 +33,9 @@ public function onStart(Start $context): void pcntl_async_signals(true); - pcntl_signal(SIGTERM, [$this, 'handleSignal']); - pcntl_signal(SIGQUIT, [$this, 'handleSignal']); - pcntl_signal(SIGINT, [$this, 'handleSignal']); + pcntl_signal(\SIGTERM, [$this, 'handleSignal']); + pcntl_signal(\SIGQUIT, [$this, 'handleSignal']); + pcntl_signal(\SIGINT, [$this, 'handleSignal']); $this->logger = $context->getLogger(); $this->interruptConsumption = false; @@ -71,9 +71,9 @@ public function handleSignal(int $signal): void } switch ($signal) { - case SIGTERM: // 15 : supervisor default stop - case SIGQUIT: // 3 : kill -s QUIT - case SIGINT: // 2 : ctrl+c + case \SIGTERM: // 15 : supervisor default stop + case \SIGQUIT: // 3 : kill -s QUIT + case \SIGINT: // 2 : ctrl+c if ($this->logger) { $this->logger->debug('[SignalExtension] Interrupt consumption'); } diff --git a/pkg/enqueue/Consumption/QueueConsumer.php b/pkg/enqueue/Consumption/QueueConsumer.php index 80936bf58..f43f5c41b 100644 --- a/pkg/enqueue/Consumption/QueueConsumer.php +++ b/pkg/enqueue/Consumption/QueueConsumer.php @@ -63,10 +63,10 @@ final class QueueConsumer implements QueueConsumerInterface */ public function __construct( InteropContext $interopContext, - ExtensionInterface $extension = null, + ?ExtensionInterface $extension = null, array $boundProcessors = [], - LoggerInterface $logger = null, - int $receiveTimeout = 10000 + ?LoggerInterface $logger = null, + int $receiveTimeout = 10000, ) { $this->interopContext = $interopContext; $this->receiveTimeout = $receiveTimeout; @@ -122,7 +122,7 @@ public function bindCallback($queue, callable $processor): QueueConsumerInterfac return $this->bind($queue, new CallbackProcessor($processor)); } - public function consume(ExtensionInterface $runtimeExtension = null): void + public function consume(?ExtensionInterface $runtimeExtension = null): void { $extension = $runtimeExtension ? new ChainExtension([$this->staticExtension, $runtimeExtension]) : @@ -195,7 +195,7 @@ public function consume(ExtensionInterface $runtimeExtension = null): void if (null === $result) { try { $result = $processor->process($message, $this->interopContext); - } catch (\Exception | \Throwable $e) { + } catch (\Exception|\Throwable $e) { $result = $this->onProcessorException($extension, $consumer, $message, $e, $receivedAt); } } @@ -278,15 +278,13 @@ public function consume(ExtensionInterface $runtimeExtension = null): void /** * @internal - * - * @param SubscriptionConsumer $fallbackSubscriptionConsumer */ public function setFallbackSubscriptionConsumer(SubscriptionConsumer $fallbackSubscriptionConsumer): void { $this->fallbackSubscriptionConsumer = $fallbackSubscriptionConsumer; } - private function onEnd(ExtensionInterface $extension, int $startTime, ?int $exitStatus = null, SubscriptionConsumer $subscriptionConsumer = null): void + private function onEnd(ExtensionInterface $extension, int $startTime, ?int $exitStatus = null, ?SubscriptionConsumer $subscriptionConsumer = null): void { $endTime = (int) (microtime(true) * 1000); diff --git a/pkg/enqueue/Consumption/QueueConsumerInterface.php b/pkg/enqueue/Consumption/QueueConsumerInterface.php index 430aa8786..ee2565252 100644 --- a/pkg/enqueue/Consumption/QueueConsumerInterface.php +++ b/pkg/enqueue/Consumption/QueueConsumerInterface.php @@ -34,9 +34,7 @@ public function bindCallback($queueName, callable $processor): self; * Runtime extension - is an extension or a collection of extensions which could be set on runtime. * Here's a good example: @see LimitsExtensionsCommandTrait. * - * @param ExtensionInterface|null $runtimeExtension - * * @throws \Exception */ - public function consume(ExtensionInterface $runtimeExtension = null): void; + public function consume(?ExtensionInterface $runtimeExtension = null): void; } diff --git a/pkg/enqueue/Consumption/Result.php b/pkg/enqueue/Consumption/Result.php index c5659bc92..efa929c7d 100644 --- a/pkg/enqueue/Consumption/Result.php +++ b/pkg/enqueue/Consumption/Result.php @@ -10,19 +10,19 @@ class Result /** * @see Processor::ACK for more details */ - const ACK = Processor::ACK; + public const ACK = Processor::ACK; /** * @see Processor::REJECT for more details */ - const REJECT = Processor::REJECT; + public const REJECT = Processor::REJECT; /** * @see Processor::REQUEUE for more details */ - const REQUEUE = Processor::REQUEUE; + public const REQUEUE = Processor::REQUEUE; - const ALREADY_ACKNOWLEDGED = 'enqueue.already_acknowledged'; + public const ALREADY_ACKNOWLEDGED = 'enqueue.already_acknowledged'; /** * @var string @@ -39,10 +39,6 @@ class Result */ private $reply; - /** - * @param mixed $status - * @param mixed $reason - */ public function __construct($status, $reason = '') { $this->status = (string) $status; @@ -81,10 +77,7 @@ public function getReply() return $this->reply; } - /** - * @param InteropMessage|null $reply - */ - public function setReply(InteropMessage $reply = null) + public function setReply(?InteropMessage $reply = null) { $this->reply = $reply; } @@ -120,9 +113,8 @@ public static function requeue($reason = '') } /** - * @param InteropMessage $replyMessage - * @param string $status - * @param string|null $reason + * @param string $status + * @param string|null $reason * * @return static */ diff --git a/pkg/enqueue/Resources.php b/pkg/enqueue/Resources.php index 713450fed..4c500006f 100644 --- a/pkg/enqueue/Resources.php +++ b/pkg/enqueue/Resources.php @@ -31,7 +31,7 @@ final class Resources * * @var array */ - private static $knownConnections = null; + private static $knownConnections; private function __construct() { diff --git a/pkg/enqueue/Router/Recipient.php b/pkg/enqueue/Router/Recipient.php index c7eac6af6..d2f668f42 100644 --- a/pkg/enqueue/Router/Recipient.php +++ b/pkg/enqueue/Router/Recipient.php @@ -17,10 +17,6 @@ class Recipient */ private $message; - /** - * @param Destination $destination - * @param InteropMessage $message - */ public function __construct(Destination $destination, InteropMessage $message) { $this->destination = $destination; diff --git a/pkg/enqueue/Router/RecipientListRouterInterface.php b/pkg/enqueue/Router/RecipientListRouterInterface.php index d00dd2abb..6bb950fdc 100644 --- a/pkg/enqueue/Router/RecipientListRouterInterface.php +++ b/pkg/enqueue/Router/RecipientListRouterInterface.php @@ -7,8 +7,6 @@ interface RecipientListRouterInterface { /** - * @param InteropMessage $message - * * @return \Traversable|Recipient[] */ public function route(InteropMessage $message); diff --git a/pkg/enqueue/Router/RouteRecipientListProcessor.php b/pkg/enqueue/Router/RouteRecipientListProcessor.php index 22e32e2ca..22488e33f 100644 --- a/pkg/enqueue/Router/RouteRecipientListProcessor.php +++ b/pkg/enqueue/Router/RouteRecipientListProcessor.php @@ -13,17 +13,11 @@ class RouteRecipientListProcessor implements Processor */ private $router; - /** - * @param RecipientListRouterInterface $router - */ public function __construct(RecipientListRouterInterface $router) { $this->router = $router; } - /** - * {@inheritdoc} - */ public function process(InteropMessage $message, Context $context) { $producer = $context->createProducer(); diff --git a/pkg/enqueue/Rpc/Promise.php b/pkg/enqueue/Rpc/Promise.php index 0a5d28f0c..01b47e1f6 100644 --- a/pkg/enqueue/Rpc/Promise.php +++ b/pkg/enqueue/Rpc/Promise.php @@ -31,11 +31,6 @@ class Promise */ private $message; - /** - * @param \Closure $receiveCallback - * @param \Closure $receiveNoWaitCallback - * @param \Closure $finallyCallback - */ public function __construct(\Closure $receiveCallback, \Closure $receiveNoWaitCallback, \Closure $finallyCallback) { $this->receiveCallback = $receiveCallback; @@ -106,8 +101,7 @@ public function isDeleteReplyQueue() } /** - * @param \Closure $cb - * @param array $args + * @param array $args * * @return InteropMessage */ @@ -116,8 +110,7 @@ private function doReceive(\Closure $cb, ...$args) $message = call_user_func_array($cb, $args); if (null !== $message && false == $message instanceof InteropMessage) { - throw new \RuntimeException(sprintf( - 'Expected "%s" but got: "%s"', InteropMessage::class, is_object($message) ? get_class($message) : gettype($message))); + throw new \RuntimeException(sprintf('Expected "%s" but got: "%s"', InteropMessage::class, is_object($message) ? $message::class : gettype($message))); } return $message; diff --git a/pkg/enqueue/Rpc/RpcClient.php b/pkg/enqueue/Rpc/RpcClient.php index 591a4cc19..bd3d7cedb 100644 --- a/pkg/enqueue/Rpc/RpcClient.php +++ b/pkg/enqueue/Rpc/RpcClient.php @@ -19,20 +19,14 @@ class RpcClient */ private $rpcFactory; - /** - * @param Context $context - * @param RpcFactory $promiseFactory - */ - public function __construct(Context $context, RpcFactory $promiseFactory = null) + public function __construct(Context $context, ?RpcFactory $promiseFactory = null) { $this->context = $context; $this->rpcFactory = $promiseFactory ?: new RpcFactory($context); } /** - * @param Destination $destination - * @param InteropMessage $message - * @param int $timeout + * @param int $timeout * * @throws TimeoutException if the wait timeout is reached * @@ -44,9 +38,7 @@ public function call(Destination $destination, InteropMessage $message, $timeout } /** - * @param Destination $destination - * @param InteropMessage $message - * @param int $timeout + * @param int $timeout * * @return Promise */ diff --git a/pkg/enqueue/Rpc/RpcFactory.php b/pkg/enqueue/Rpc/RpcFactory.php index bd054b186..9100babd3 100644 --- a/pkg/enqueue/Rpc/RpcFactory.php +++ b/pkg/enqueue/Rpc/RpcFactory.php @@ -11,9 +11,6 @@ class RpcFactory */ private $context; - /** - * @param Context $context - */ public function __construct(Context $context) { $this->context = $context; diff --git a/pkg/enqueue/Symfony/Client/DependencyInjection/AnalyzeRouteCollectionPass.php b/pkg/enqueue/Symfony/Client/DependencyInjection/AnalyzeRouteCollectionPass.php index c541f4179..577f15902 100644 --- a/pkg/enqueue/Symfony/Client/DependencyInjection/AnalyzeRouteCollectionPass.php +++ b/pkg/enqueue/Symfony/Client/DependencyInjection/AnalyzeRouteCollectionPass.php @@ -38,11 +38,7 @@ private function exclusiveCommandsCouldNotBeRunOnDefaultQueue(RouteCollection $c { foreach ($collection->all() as $route) { if ($route->isCommand() && $route->isProcessorExclusive() && false == $route->getQueue()) { - throw new \LogicException(sprintf( - 'The command "%s" processor "%s" is exclusive but queue is not specified. Exclusive processors could not be run on a default queue.', - $route->getSource(), - $route->getProcessor() - )); + throw new \LogicException(sprintf('The command "%s" processor "%s" is exclusive but queue is not specified. Exclusive processors could not be run on a default queue.', $route->getSource(), $route->getProcessor())); } } } @@ -61,25 +57,13 @@ private function exclusiveCommandProcessorMustBeSingleOnGivenQueue(RouteCollecti if ($route->isPrefixQueue()) { if (array_key_exists($route->getQueue(), $prefixedQueues)) { - throw new \LogicException(sprintf( - 'The command "%s" processor "%s" is exclusive. The queue "%s" already has another exclusive command processor "%s" bound to it.', - $route->getSource(), - $route->getProcessor(), - $route->getQueue(), - $prefixedQueues[$route->getQueue()] - )); + throw new \LogicException(sprintf('The command "%s" processor "%s" is exclusive. The queue "%s" already has another exclusive command processor "%s" bound to it.', $route->getSource(), $route->getProcessor(), $route->getQueue(), $prefixedQueues[$route->getQueue()])); } $prefixedQueues[$route->getQueue()] = $route->getProcessor(); } else { if (array_key_exists($route->getQueue(), $queues)) { - throw new \LogicException(sprintf( - 'The command "%s" processor "%s" is exclusive. The queue "%s" already has another exclusive command processor "%s" bound to it.', - $route->getSource(), - $route->getProcessor(), - $route->getQueue(), - $queues[$route->getQueue()] - )); + throw new \LogicException(sprintf('The command "%s" processor "%s" is exclusive. The queue "%s" already has another exclusive command processor "%s" bound to it.', $route->getSource(), $route->getProcessor(), $route->getQueue(), $queues[$route->getQueue()])); } $queues[$route->getQueue()] = $route->getProcessor(); @@ -102,7 +86,7 @@ private function customQueueNamesUnique(RouteCollection $collection): void $notPrefixedQueues = []; foreach ($collection->all() as $route) { - //default queue + // default queue $queueName = $route->getQueue(); if (false == $queueName) { return; diff --git a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildClientExtensionsPass.php b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildClientExtensionsPass.php index 5ad45fd90..92124f243 100644 --- a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildClientExtensionsPass.php +++ b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildClientExtensionsPass.php @@ -46,7 +46,7 @@ public function process(ContainerBuilder $container): void } } - krsort($groupByPriority, SORT_NUMERIC); + krsort($groupByPriority, \SORT_NUMERIC); $flatExtensions = []; foreach ($groupByPriority as $extension) { diff --git a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPass.php b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPass.php index 5eee3efdb..4adc09e9d 100644 --- a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPass.php +++ b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPass.php @@ -68,7 +68,7 @@ public function process(ContainerBuilder $container): void // 0.8 command subscriber if (isset($commands['processorName'])) { - @trigger_error('The command subscriber 0.8 syntax is deprecated since Enqueue 0.9.', E_USER_DEPRECATED); + @trigger_error('The command subscriber 0.8 syntax is deprecated since Enqueue 0.9.', \E_USER_DEPRECATED); $source = $commands['processorName']; $processor = $params['processorName'] ?? $serviceId; @@ -117,11 +117,7 @@ public function process(ContainerBuilder $container): void $routeCollection->add(new Route($source, Route::COMMAND, $processor, $options)); } else { - throw new \LogicException(sprintf( - 'Command subscriber configuration is invalid for "%s::getSubscribedCommand()". "%s"', - $processorClass, - json_encode($processorClass::getSubscribedCommand()) - )); + throw new \LogicException(sprintf('Command subscriber configuration is invalid for "%s::getSubscribedCommand()". "%s"', $processorClass, json_encode($processorClass::getSubscribedCommand()))); } } } diff --git a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPass.php b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPass.php index c1f1ce970..274847c90 100644 --- a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPass.php +++ b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPass.php @@ -46,7 +46,7 @@ public function process(ContainerBuilder $container): void } } - krsort($groupByPriority, SORT_NUMERIC); + krsort($groupByPriority, \SORT_NUMERIC); $flatExtensions = []; foreach ($groupByPriority as $extension) { diff --git a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPass.php b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPass.php index 4999921cc..ef01e6fcf 100644 --- a/pkg/enqueue/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPass.php +++ b/pkg/enqueue/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPass.php @@ -72,7 +72,7 @@ public function process(ContainerBuilder $container): void // 0.8 topic subscriber } elseif (is_array($params) && is_string($key)) { - @trigger_error('The topic subscriber 0.8 syntax is deprecated since Enqueue 0.9.', E_USER_DEPRECATED); + @trigger_error('The topic subscriber 0.8 syntax is deprecated since Enqueue 0.9.', \E_USER_DEPRECATED); $source = $key; $processor = $params['processorName'] ?? $serviceId; @@ -109,11 +109,7 @@ public function process(ContainerBuilder $container): void $routeCollection->add(new Route($source, Route::TOPIC, $processor, $options)); } else { - throw new \LogicException(sprintf( - 'Topic subscriber configuration is invalid for "%s::getSubscribedTopics()". Got "%s"', - $processorClass, - json_encode($processorClass::getSubscribedTopics()) - )); + throw new \LogicException(sprintf('Topic subscriber configuration is invalid for "%s::getSubscribedTopics()". Got "%s"', $processorClass, json_encode($processorClass::getSubscribedTopics()))); } } } diff --git a/pkg/enqueue/Symfony/Client/FlushSpoolProducerListener.php b/pkg/enqueue/Symfony/Client/FlushSpoolProducerListener.php index 8fa6fb4f6..00543f6de 100644 --- a/pkg/enqueue/Symfony/Client/FlushSpoolProducerListener.php +++ b/pkg/enqueue/Symfony/Client/FlushSpoolProducerListener.php @@ -24,9 +24,6 @@ public function flushMessages() $this->producer->flush(); } - /** - * {@inheritdoc} - */ public static function getSubscribedEvents(): array { $events = []; diff --git a/pkg/enqueue/Symfony/Client/SetupBrokerExtensionCommandTrait.php b/pkg/enqueue/Symfony/Client/SetupBrokerExtensionCommandTrait.php index 2888f5636..96e0d2d6b 100644 --- a/pkg/enqueue/Symfony/Client/SetupBrokerExtensionCommandTrait.php +++ b/pkg/enqueue/Symfony/Client/SetupBrokerExtensionCommandTrait.php @@ -10,9 +10,6 @@ trait SetupBrokerExtensionCommandTrait { - /** - * {@inheritdoc} - */ protected function configureSetupBrokerExtension() { $this @@ -21,9 +18,6 @@ protected function configureSetupBrokerExtension() } /** - * @param InputInterface $input - * @param DriverInterface $driver - * * @return ExtensionInterface */ protected function getSetupBrokerExtension(InputInterface $input, DriverInterface $driver) diff --git a/pkg/enqueue/Symfony/Consumption/LimitsExtensionsCommandTrait.php b/pkg/enqueue/Symfony/Consumption/LimitsExtensionsCommandTrait.php index d7363db09..d8351acc5 100644 --- a/pkg/enqueue/Symfony/Consumption/LimitsExtensionsCommandTrait.php +++ b/pkg/enqueue/Symfony/Consumption/LimitsExtensionsCommandTrait.php @@ -23,9 +23,6 @@ protected function configureLimitsExtensions() } /** - * @param InputInterface $input - * @param OutputInterface $output - * * @throws \Exception * * @return ExtensionInterface[] diff --git a/pkg/enqueue/Symfony/Consumption/QueueConsumerOptionsCommandTrait.php b/pkg/enqueue/Symfony/Consumption/QueueConsumerOptionsCommandTrait.php index 9df852df9..fd736f226 100644 --- a/pkg/enqueue/Symfony/Consumption/QueueConsumerOptionsCommandTrait.php +++ b/pkg/enqueue/Symfony/Consumption/QueueConsumerOptionsCommandTrait.php @@ -8,9 +8,6 @@ trait QueueConsumerOptionsCommandTrait { - /** - * {@inheritdoc} - */ protected function configureQueueConsumerOptions() { $this @@ -18,10 +15,6 @@ protected function configureQueueConsumerOptions() ; } - /** - * @param QueueConsumerInterface $consumer - * @param InputInterface $input - */ protected function setQueueConsumerOptions(QueueConsumerInterface $consumer, InputInterface $input) { if (null !== $receiveTimeout = $input->getOption('receive-timeout')) { diff --git a/pkg/enqueue/Symfony/DependencyInjection/BuildConsumptionExtensionsPass.php b/pkg/enqueue/Symfony/DependencyInjection/BuildConsumptionExtensionsPass.php index 352682b19..99f274ec5 100644 --- a/pkg/enqueue/Symfony/DependencyInjection/BuildConsumptionExtensionsPass.php +++ b/pkg/enqueue/Symfony/DependencyInjection/BuildConsumptionExtensionsPass.php @@ -43,7 +43,7 @@ public function process(ContainerBuilder $container): void } } - krsort($groupByPriority, SORT_NUMERIC); + krsort($groupByPriority, \SORT_NUMERIC); $flatExtensions = []; foreach ($groupByPriority as $extension) { diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php index 56b855f0c..a660126ad 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php @@ -23,7 +23,6 @@ class DelayRedeliveredMessageExtensionTest extends TestCase { - public function testShouldSendDelayedMessageAndRejectOriginalMessage() { $queue = new NullQueue('queue'); diff --git a/pkg/enqueue/Tests/Client/DriverFactoryTest.php b/pkg/enqueue/Tests/Client/DriverFactoryTest.php index ef504e0e0..3d9d7b9b5 100644 --- a/pkg/enqueue/Tests/Client/DriverFactoryTest.php +++ b/pkg/enqueue/Tests/Client/DriverFactoryTest.php @@ -105,7 +105,7 @@ public function testReturnsExpectedFactories( string $connectionFactoryClass, string $contextClass, array $conifg, - string $expectedDriverClass + string $expectedDriverClass, ) { $connectionFactoryMock = $this->createMock($connectionFactoryClass); $connectionFactoryMock @@ -134,7 +134,7 @@ public static function provideDSN() yield ['file:', FsConnectionFactory::class, FsContext::class, [], FsDriver::class]; // https://github.com/php-enqueue/enqueue-dev/issues/511 -// yield ['gearman:', GearmanConnectionFactory::class, NullContext::class, [], NullDriver::class]; + // yield ['gearman:', GearmanConnectionFactory::class, NullContext::class, [], NullDriver::class]; yield ['gps:', GpsConnectionFactory::class, GpsContext::class, [], GpsDriver::class]; diff --git a/pkg/enqueue/Tests/Client/Extension/PrepareBodyExtensionTest.php b/pkg/enqueue/Tests/Client/Extension/PrepareBodyExtensionTest.php index d1c260388..c3032ccc8 100644 --- a/pkg/enqueue/Tests/Client/Extension/PrepareBodyExtensionTest.php +++ b/pkg/enqueue/Tests/Client/Extension/PrepareBodyExtensionTest.php @@ -25,14 +25,13 @@ public function testShouldImplementExtensionInterface() /** * @dataProvider provideMessages * - * @param mixed $body * @param mixed|null $contentType */ public function testShouldSendStringUnchangedAndAddPlainTextContentTypeIfEmpty( $body, $contentType, string $expectedBody, - string $expectedContentType + string $expectedContentType, ) { $message = new Message($body); $message->setContentType($contentType); diff --git a/pkg/enqueue/Tests/Client/PreSendTest.php b/pkg/enqueue/Tests/Client/PreSendTest.php index ae9400338..01a7e5055 100644 --- a/pkg/enqueue/Tests/Client/PreSendTest.php +++ b/pkg/enqueue/Tests/Client/PreSendTest.php @@ -51,7 +51,7 @@ public function testCouldChangeTopic() $this->createDriverMock() ); - //guard + // guard $this->assertSame('aCommandOrTopic', $context->getTopic()); $context->changeTopic('theChangedTopic'); @@ -68,7 +68,7 @@ public function testCouldChangeCommand() $this->createDriverMock() ); - //guard + // guard $this->assertSame('aCommandOrTopic', $context->getCommand()); $context->changeCommand('theChangedCommand'); @@ -85,7 +85,7 @@ public function testCouldChangeBody() $this->createDriverMock() ); - //guard + // guard $this->assertSame('aBody', $context->getMessage()->getBody()); $this->assertNull($context->getMessage()->getContentType()); diff --git a/pkg/enqueue/Tests/Client/ProducerTest.php b/pkg/enqueue/Tests/Client/ProducerTest.php index 9d4e2a304..23b004ac3 100644 --- a/pkg/enqueue/Tests/Client/ProducerTest.php +++ b/pkg/enqueue/Tests/Client/ProducerTest.php @@ -3,7 +3,6 @@ namespace Enqueue\Tests\Client; use Enqueue\Client\DriverInterface; -use Enqueue\Client\ExtensionInterface; use Enqueue\Client\Producer; use Enqueue\Client\ProducerInterface; use Enqueue\Rpc\RpcFactory; diff --git a/pkg/enqueue/Tests/Client/RouterProcessorTest.php b/pkg/enqueue/Tests/Client/RouterProcessorTest.php index e2611d09c..7d2971189 100644 --- a/pkg/enqueue/Tests/Client/RouterProcessorTest.php +++ b/pkg/enqueue/Tests/Client/RouterProcessorTest.php @@ -188,7 +188,7 @@ public function testShouldDoNotModifyOriginalMessage() $result = $processor->process($message, new NullContext()); - //guard + // guard $this->assertEquals(Result::ACK, $result->getStatus()); $this->assertSame('theBody', $message->getBody()); diff --git a/pkg/enqueue/Tests/Client/TraceableProducerTest.php b/pkg/enqueue/Tests/Client/TraceableProducerTest.php index ff042857c..b0df066ce 100644 --- a/pkg/enqueue/Tests/Client/TraceableProducerTest.php +++ b/pkg/enqueue/Tests/Client/TraceableProducerTest.php @@ -272,8 +272,8 @@ public function testShouldAllowGetInfoSentToSameTopic() $producer->sendEvent('aFooTopic', 'aFooBody'); Assert::assertArraySubset([ - ['topic' => 'aFooTopic', 'body' => 'aFooBody'], - ['topic' => 'aFooTopic', 'body' => 'aFooBody'], + ['topic' => 'aFooTopic', 'body' => 'aFooBody'], + ['topic' => 'aFooTopic', 'body' => 'aFooBody'], ], $producer->getTraces()); } @@ -354,7 +354,7 @@ public function testShouldAllowClearStoredTraces() $producer->sendEvent('aFooTopic', 'aFooBody'); - //guard + // guard $this->assertNotEmpty($producer->getTraces()); $producer->clearTraces(); diff --git a/pkg/enqueue/Tests/ConnectionFactoryFactoryTest.php b/pkg/enqueue/Tests/ConnectionFactoryFactoryTest.php index fe2de69a0..b6b5b4d67 100644 --- a/pkg/enqueue/Tests/ConnectionFactoryFactoryTest.php +++ b/pkg/enqueue/Tests/ConnectionFactoryFactoryTest.php @@ -158,7 +158,7 @@ public static function provideDSN() yield ['file:', FsConnectionFactory::class]; // https://github.com/php-enqueue/enqueue-dev/issues/511 -// yield ['gearman:', GearmanConnectionFactory::class]; + // yield ['gearman:', GearmanConnectionFactory::class]; yield ['gps:', GpsConnectionFactory::class]; diff --git a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumerMemoryExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumerMemoryExtensionTest.php index 15482997d..25ac85895 100644 --- a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumerMemoryExtensionTest.php +++ b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumerMemoryExtensionTest.php @@ -124,7 +124,7 @@ public function testOnPreConsumeShouldNotInterruptExecutionIfMemoryLimitIsNotRea $this->assertFalse($context->isExecutionInterrupted()); // test - $extension = new LimitConsumerMemoryExtension(PHP_INT_MAX); + $extension = new LimitConsumerMemoryExtension(\PHP_INT_MAX); $extension->onPreConsume($context); $this->assertFalse($context->isExecutionInterrupted()); @@ -145,7 +145,7 @@ public function testOnPostConsumeShouldNotInterruptExecutionIfMemoryLimitIsNotRe $this->assertFalse($postConsume->isExecutionInterrupted()); // test - $extension = new LimitConsumerMemoryExtension(PHP_INT_MAX); + $extension = new LimitConsumerMemoryExtension(\PHP_INT_MAX); $extension->onPostConsume($postConsume); $this->assertFalse($postConsume->isExecutionInterrupted()); @@ -166,7 +166,7 @@ public function testOnPostMessageReceivedShouldNotInterruptExecutionIfMemoryLimi $this->assertFalse($postReceivedMessage->isExecutionInterrupted()); // test - $extension = new LimitConsumerMemoryExtension(PHP_INT_MAX); + $extension = new LimitConsumerMemoryExtension(\PHP_INT_MAX); $extension->onPostMessageReceived($postReceivedMessage); $this->assertFalse($postReceivedMessage->isExecutionInterrupted()); diff --git a/pkg/enqueue/Tests/Consumption/Extension/LoggerExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/LoggerExtensionTest.php index 455468ed2..666892e0e 100644 --- a/pkg/enqueue/Tests/Consumption/Extension/LoggerExtensionTest.php +++ b/pkg/enqueue/Tests/Consumption/Extension/LoggerExtensionTest.php @@ -42,7 +42,7 @@ public function testShouldAddInfoMessageOnStart() $logger ->expects($this->once()) ->method('debug') - ->with(sprintf('Change logger from "%s" to "%s"', get_class($logger), get_class($previousLogger))) + ->with(sprintf('Change logger from "%s" to "%s"', $logger::class, $previousLogger::class)) ; $extension = new LoggerExtension($logger); diff --git a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php index 06edab31b..2bcc253e7 100644 --- a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php +++ b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php @@ -1455,7 +1455,7 @@ private function createContextWithoutSubscriptionConsumerMock(): InteropContext /** * @return \PHPUnit\Framework\MockObject\MockObject|InteropContext */ - private function createContextStub(Consumer $consumer = null): InteropContext + private function createContextStub(?Consumer $consumer = null): InteropContext { $context = $this->createContextWithoutSubscriptionConsumerMock(); $context diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php index 1a5f65a4f..14a48be93 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php @@ -154,7 +154,7 @@ public function testShouldRegisterProcessorIfCommandsIsString() $container->setParameter('enqueue.clients', ['foo']); $container->setParameter('enqueue.default_client', 'foo'); $container->setDefinition('enqueue.client.foo.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.command_subscriber') ; @@ -188,7 +188,7 @@ public function testThrowIfCommandSubscriberReturnsNothing() $container->setParameter('enqueue.clients', ['foo']); $container->setParameter('enqueue.default_client', 'foo'); $container->setDefinition('enqueue.client.foo.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.command_subscriber') ; @@ -210,7 +210,7 @@ public function testShouldRegisterProcessorIfCommandsAreStrings() $container->setParameter('enqueue.clients', ['foo']); $container->setParameter('enqueue.default_client', 'foo'); $container->setDefinition('enqueue.client.foo.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.command_subscriber') ; @@ -254,7 +254,7 @@ public function testShouldRegisterProcessorIfParamSingleCommandArray() $container->setParameter('enqueue.clients', ['foo']); $container->setParameter('enqueue.default_client', 'foo'); $container->setDefinition('enqueue.client.foo.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.command_subscriber') ; @@ -293,7 +293,7 @@ public function testShouldRegisterProcessorIfCommandsAreParamArrays() $container->setParameter('enqueue.clients', ['foo']); $container->setParameter('enqueue.default_client', 'foo'); $container->setDefinition('enqueue.client.foo.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.command_subscriber') ; @@ -335,7 +335,7 @@ public function testThrowIfCommandSubscriberParamsInvalid() $container->setParameter('enqueue.clients', ['foo']); $container->setParameter('enqueue.default_client', 'foo'); $container->setDefinition('enqueue.client.foo.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.command_subscriber') ; @@ -360,7 +360,7 @@ public function testShouldMergeExtractedRoutesWithAlreadySetInCollection() $container->setParameter('enqueue.clients', ['foo']); $container->setParameter('enqueue.default_client', 'foo'); $container->setDefinition('enqueue.client.foo.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.command_subscriber') ; @@ -410,7 +410,7 @@ public function testShouldRegister08CommandProcessor() $container->setParameter('enqueue.clients', ['default']); $container->setParameter('enqueue.default_client', 'default'); $container->setDefinition('enqueue.client.default.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.command_subscriber') ; @@ -438,7 +438,7 @@ public function testShouldRegister08CommandProcessor() private function createCommandSubscriberProcessor($commandSubscriberReturns = ['aCommand']) { - $processor = new class() implements Processor, CommandSubscriberInterface { + $processor = new class implements Processor, CommandSubscriberInterface { public static $return; public function process(InteropMessage $message, Context $context) diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php index b642b9001..b9d798c11 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php @@ -154,7 +154,7 @@ public function testShouldRegisterProcessorIfTopicsIsString() $container->setParameter('enqueue.clients', ['foo']); $container->setParameter('enqueue.default_client', 'foo'); $container->setDefinition('enqueue.client.foo.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.topic_subscriber') ; @@ -188,7 +188,7 @@ public function testThrowIfTopicSubscriberReturnsNothing() $container->setParameter('enqueue.clients', ['foo']); $container->setParameter('enqueue.default_client', 'foo'); $container->setDefinition('enqueue.client.foo.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.topic_subscriber') ; @@ -210,7 +210,7 @@ public function testShouldRegisterProcessorIfTopicsAreStrings() $container->setParameter('enqueue.clients', ['foo']); $container->setParameter('enqueue.default_client', 'foo'); $container->setDefinition('enqueue.client.foo.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.topic_subscriber') ; @@ -253,7 +253,7 @@ public function testShouldRegisterProcessorIfTopicsAreParamArrays() $container->setParameter('enqueue.clients', ['foo']); $container->setParameter('enqueue.default_client', 'foo'); $container->setDefinition('enqueue.client.foo.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.topic_subscriber') ; @@ -295,7 +295,7 @@ public function testThrowIfTopicSubscriberParamsInvalid() $container->setParameter('enqueue.clients', ['foo']); $container->setParameter('enqueue.default_client', 'foo'); $container->setDefinition('enqueue.client.foo.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.topic_subscriber') ; @@ -320,7 +320,7 @@ public function testShouldMergeExtractedRoutesWithAlreadySetInCollection() $container->setParameter('enqueue.clients', ['foo']); $container->setParameter('enqueue.default_client', 'foo'); $container->setDefinition('enqueue.client.foo.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.topic_subscriber') ; @@ -367,7 +367,7 @@ public function testShouldRegister08TopicSubscriber() $container->setParameter('enqueue.clients', ['default']); $container->setParameter('enqueue.default_client', 'default'); $container->setDefinition('enqueue.client.default.route_collection', $routeCollection); - $container->register('aFooProcessor', get_class($processor)) + $container->register('aFooProcessor', $processor::class) ->addTag('enqueue.topic_subscriber') ; @@ -402,7 +402,7 @@ public function testShouldRegister08TopicSubscriber() private function createTopicSubscriberProcessor($topicSubscriberReturns = ['aTopic']) { - $processor = new class() implements Processor, TopicSubscriberInterface { + $processor = new class implements Processor, TopicSubscriberInterface { public static $return; public function process(InteropMessage $message, Context $context) diff --git a/pkg/enqueue/Tests/Symfony/Consumption/LimitsExtensionsCommandTraitTest.php b/pkg/enqueue/Tests/Symfony/Consumption/LimitsExtensionsCommandTraitTest.php index e92912355..f47a32161 100644 --- a/pkg/enqueue/Tests/Symfony/Consumption/LimitsExtensionsCommandTraitTest.php +++ b/pkg/enqueue/Tests/Symfony/Consumption/LimitsExtensionsCommandTraitTest.php @@ -109,8 +109,6 @@ public function testShouldAddThreeLimitExtensions() } /** - * @param mixed $inputValue - * @param bool $enabled * @dataProvider provideNicenessValues */ public function testShouldAddNicenessExtension($inputValue, bool $enabled) diff --git a/pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php b/pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php index c5ff1c818..909407452 100644 --- a/pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php +++ b/pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php @@ -148,7 +148,7 @@ public function testThrowIfFactoryClassAndFactoryServiceSetAtTheSameTime() 'dsn' => 'foo:', 'factory_class' => 'aFactoryClass', 'factory_service' => 'aFactoryService', - ], ]]); + ], ]]); } public function testThrowIfConnectionFactoryClassUsedWithFactoryClassAtTheSameTime() @@ -166,7 +166,7 @@ public function testThrowIfConnectionFactoryClassUsedWithFactoryClassAtTheSameTi 'dsn' => 'foo:', 'connection_factory_class' => 'aFactoryClass', 'factory_service' => 'aFactoryService', - ], ]]); + ], ]]); } public function testThrowIfConnectionFactoryClassUsedWithFactoryServiceAtTheSameTime() @@ -183,7 +183,7 @@ public function testThrowIfConnectionFactoryClassUsedWithFactoryServiceAtTheSame 'dsn' => 'foo:', 'connection_factory_class' => 'aFactoryClass', 'factory_service' => 'aFactoryService', - ], ]]); + ], ]]); } public function testShouldAllowSetFactoryClass() @@ -197,7 +197,7 @@ public function testShouldAllowSetFactoryClass() 'transport' => [ 'dsn' => 'foo:', 'factory_class' => 'theFactoryClass', - ], ]]); + ], ]]); $this->assertArrayHasKey('factory_class', $config['transport']); $this->assertSame('theFactoryClass', $config['transport']['factory_class']); @@ -214,7 +214,7 @@ public function testShouldAllowSetFactoryService() 'transport' => [ 'dsn' => 'foo:', 'factory_service' => 'theFactoryService', - ], ]]); + ], ]]); $this->assertArrayHasKey('factory_service', $config['transport']); $this->assertSame('theFactoryService', $config['transport']['factory_service']); @@ -231,7 +231,7 @@ public function testShouldAllowSetConnectionFactoryClass() 'transport' => [ 'dsn' => 'foo:', 'connection_factory_class' => 'theFactoryClass', - ], ]]); + ], ]]); $this->assertArrayHasKey('connection_factory_class', $config['transport']); $this->assertSame('theFactoryClass', $config['transport']['connection_factory_class']); diff --git a/pkg/enqueue/Tests/Util/JSONTest.php b/pkg/enqueue/Tests/Util/JSONTest.php index a6f583387..1a3df4211 100644 --- a/pkg/enqueue/Tests/Util/JSONTest.php +++ b/pkg/enqueue/Tests/Util/JSONTest.php @@ -39,8 +39,6 @@ public function nonStringDataProvider() /** * @dataProvider nonStringDataProvider - * - * @param mixed $value */ public function testShouldThrowExceptionIfInputIsNotString($value) { diff --git a/pkg/enqueue/Tests/Util/VarExportTest.php b/pkg/enqueue/Tests/Util/VarExportTest.php index e8034a1c7..b71e78a65 100644 --- a/pkg/enqueue/Tests/Util/VarExportTest.php +++ b/pkg/enqueue/Tests/Util/VarExportTest.php @@ -9,9 +9,6 @@ class VarExportTest extends TestCase { /** * @dataProvider provideValues - * - * @param mixed $value - * @param mixed $expected */ public function testShouldConvertValueToStringUsingVarExportFunction($value, $expected) { diff --git a/pkg/enqueue/Tests/fix_composer_json.php b/pkg/enqueue/Tests/fix_composer_json.php index dfbec62fb..324f1840b 100644 --- a/pkg/enqueue/Tests/fix_composer_json.php +++ b/pkg/enqueue/Tests/fix_composer_json.php @@ -8,4 +8,4 @@ $composerJson['config']['platform']['ext-rdkafka'] = '3.3'; $composerJson['config']['platform']['ext-gearman'] = '2'; -file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, JSON_PRETTY_PRINT)); +file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, \JSON_PRETTY_PRINT)); diff --git a/pkg/enqueue/Util/JSON.php b/pkg/enqueue/Util/JSON.php index f85738e1d..67411af16 100644 --- a/pkg/enqueue/Util/JSON.php +++ b/pkg/enqueue/Util/JSON.php @@ -14,10 +14,7 @@ class JSON public static function decode($string) { if (!is_string($string)) { - throw new \InvalidArgumentException(sprintf( - 'Accept only string argument but got: "%s"', - is_object($string) ? get_class($string) : gettype($string) - )); + throw new \InvalidArgumentException(sprintf('Accept only string argument but got: "%s"', is_object($string) ? $string::class : gettype($string))); } // PHP7 fix - empty string and null cause syntax error @@ -26,32 +23,22 @@ public static function decode($string) } $decoded = json_decode($string, true); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return $decoded; } /** - * @param mixed $value - * * @return string */ public static function encode($value) { - $encoded = json_encode($value, JSON_UNESCAPED_UNICODE); - - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'Could not encode value into json. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + $encoded = json_encode($value, \JSON_UNESCAPED_UNICODE); + + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('Could not encode value into json. Error %s and message %s', json_last_error(), json_last_error_msg())); } return $encoded; diff --git a/pkg/enqueue/Util/Stringify.php b/pkg/enqueue/Util/Stringify.php index 39b1f1305..12358d785 100644 --- a/pkg/enqueue/Util/Stringify.php +++ b/pkg/enqueue/Util/Stringify.php @@ -7,14 +7,8 @@ */ class Stringify { - /** - * @var mixed - */ private $value; - /** - * @param mixed $value - */ public function __construct($value) { $this->value = $value; @@ -26,7 +20,7 @@ public function __toString(): string return $this->value; } - return json_encode($this->value, JSON_UNESCAPED_SLASHES); + return json_encode($this->value, \JSON_UNESCAPED_SLASHES); } public static function that($value): self diff --git a/pkg/enqueue/Util/VarExport.php b/pkg/enqueue/Util/VarExport.php index 4a48afadd..9a914706d 100644 --- a/pkg/enqueue/Util/VarExport.php +++ b/pkg/enqueue/Util/VarExport.php @@ -7,14 +7,8 @@ */ class VarExport { - /** - * @var mixed - */ private $value; - /** - * @param mixed $value - */ public function __construct($value) { $this->value = $value; diff --git a/pkg/fs/FsConnectionFactory.php b/pkg/fs/FsConnectionFactory.php index ad13e9eb6..9c4ba17e5 100644 --- a/pkg/fs/FsConnectionFactory.php +++ b/pkg/fs/FsConnectionFactory.php @@ -74,11 +74,7 @@ private function parseDsn(string $dsn): array $supportedSchemes = ['file']; if (false == in_array($dsn->getSchemeProtocol(), $supportedSchemes, true)) { - throw new \LogicException(sprintf( - 'The given scheme protocol "%s" is not supported. It must be one of "%s"', - $dsn->getSchemeProtocol(), - implode('", "', $supportedSchemes) - )); + throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be one of "%s"', $dsn->getSchemeProtocol(), implode('", "', $supportedSchemes))); } return array_filter(array_replace($dsn->getQuery(), [ diff --git a/pkg/fs/FsConsumer.php b/pkg/fs/FsConsumer.php index 46e7b96ba..614461eb2 100644 --- a/pkg/fs/FsConsumer.php +++ b/pkg/fs/FsConsumer.php @@ -112,7 +112,7 @@ public function receiveNoWait(): ?Message while ($count) { $frame = $this->readFrame($file, 1); - //guards + // guards if ($frame && false == ('|' == $frame[0] || ' ' == $frame[0])) { throw new \LogicException(sprintf('The frame could start from either " " or "|". The malformed frame starts with "%s".', $frame[0])); } @@ -188,13 +188,13 @@ private function readFrame($file, int $frameNumber): string $frameSize = 64; $offset = $frameNumber * $frameSize; - fseek($file, -$offset, SEEK_END); + fseek($file, -$offset, \SEEK_END); $frame = fread($file, $frameSize); if ('' == $frame) { return ''; } - if (false !== strpos($frame, '|{')) { + if (str_contains($frame, '|{')) { return $frame; } diff --git a/pkg/fs/FsContext.php b/pkg/fs/FsContext.php index 480074e03..c735e13aa 100644 --- a/pkg/fs/FsContext.php +++ b/pkg/fs/FsContext.php @@ -83,7 +83,7 @@ public function createQueue(string $queueName): Queue public function declareDestination(FsDestination $destination): void { - //InvalidDestinationException::assertDestinationInstanceOf($destination, FsDestination::class); + // InvalidDestinationException::assertDestinationInstanceOf($destination, FsDestination::class); set_error_handler(function ($severity, $message, $file, $line) { throw new \ErrorException($message, 0, $severity, $file, $line); @@ -105,7 +105,7 @@ public function workWithFile(FsDestination $destination, string $mode, callable set_error_handler(function ($severity, $message, $file, $line) { throw new \ErrorException($message, 0, $severity, $file, $line); - }, E_ALL & ~E_USER_DEPRECATED); + }, \E_ALL & ~\E_USER_DEPRECATED); try { $file = fopen((string) $destination->getFileInfo(), $mode); diff --git a/pkg/fs/FsMessage.php b/pkg/fs/FsMessage.php index d66ee52cd..45312e52c 100644 --- a/pkg/fs/FsMessage.php +++ b/pkg/fs/FsMessage.php @@ -96,7 +96,7 @@ public function setRedelivered(bool $redelivered): void $this->redelivered = $redelivered; } - public function setCorrelationId(string $correlationId = null): void + public function setCorrelationId(?string $correlationId = null): void { $this->setHeader('correlation_id', (string) $correlationId); } @@ -106,7 +106,7 @@ public function getCorrelationId(): ?string return $this->getHeader('correlation_id'); } - public function setMessageId(string $messageId = null): void + public function setMessageId(?string $messageId = null): void { $this->setHeader('message_id', (string) $messageId); } @@ -123,12 +123,12 @@ public function getTimestamp(): ?int return null === $value ? null : (int) $value; } - public function setTimestamp(int $timestamp = null): void + public function setTimestamp(?int $timestamp = null): void { $this->setHeader('timestamp', $timestamp); } - public function setReplyTo(string $replyTo = null): void + public function setReplyTo(?string $replyTo = null): void { $this->setHeader('reply_to', $replyTo); } @@ -150,12 +150,8 @@ public function jsonSerialize(): array public static function jsonUnserialize(string $json): self { $data = json_decode($json, true); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return new self($data['body'], $data['properties'], $data['headers']); diff --git a/pkg/fs/FsProducer.php b/pkg/fs/FsProducer.php index 55ff88cc3..067e54b36 100644 --- a/pkg/fs/FsProducer.php +++ b/pkg/fs/FsProducer.php @@ -53,12 +53,8 @@ public function send(Destination $destination, Message $message): void $rawMessage = str_replace('|{', '\|\{', $rawMessage); $rawMessage = '|'.$rawMessage; - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'Could not encode value into json. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('Could not encode value into json. Error %s and message %s', json_last_error(), json_last_error_msg())); } $rawMessage = str_repeat(' ', 64 - (strlen($rawMessage) % 64)).$rawMessage; @@ -67,7 +63,7 @@ public function send(Destination $destination, Message $message): void }); } - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { if (null === $deliveryDelay) { return $this; @@ -81,7 +77,7 @@ public function getDeliveryDelay(): ?int return null; } - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { if (null === $priority) { return $this; @@ -95,7 +91,7 @@ public function getPriority(): ?int return null; } - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { $this->timeToLive = $timeToLive; diff --git a/pkg/fs/LegacyFilesystemLock.php b/pkg/fs/LegacyFilesystemLock.php index a765d2ced..328fb7098 100644 --- a/pkg/fs/LegacyFilesystemLock.php +++ b/pkg/fs/LegacyFilesystemLock.php @@ -19,9 +19,6 @@ public function __construct() $this->lockHandlers = []; } - /** - * {@inheritdoc} - */ public function lock(FsDestination $destination) { $lockHandler = $this->getLockHandler($destination); @@ -31,9 +28,6 @@ public function lock(FsDestination $destination) } } - /** - * {@inheritdoc} - */ public function release(FsDestination $destination) { $lockHandler = $this->getLockHandler($destination); @@ -51,8 +45,6 @@ public function releaseAll() } /** - * @param FsDestination $destination - * * @return LockHandler */ private function getLockHandler(FsDestination $destination) @@ -161,7 +153,7 @@ public function lock($blocking = false) // On Windows, even if PHP doc says the contrary, LOCK_NB works, see // https://bugs.php.net/54129 - if (!flock($this->handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) { + if (!flock($this->handle, \LOCK_EX | ($blocking ? 0 : \LOCK_NB))) { fclose($this->handle); $this->handle = null; @@ -177,7 +169,7 @@ public function lock($blocking = false) public function release() { if ($this->handle) { - flock($this->handle, LOCK_UN | LOCK_NB); + flock($this->handle, \LOCK_UN | \LOCK_NB); fclose($this->handle); $this->handle = null; } diff --git a/pkg/fs/Lock.php b/pkg/fs/Lock.php index 91125faa8..16349f22c 100644 --- a/pkg/fs/Lock.php +++ b/pkg/fs/Lock.php @@ -10,15 +10,10 @@ interface Lock * Returns the control If the look has been obtained * If not, should throw CannotObtainLockException exception. * - * @param FsDestination $destination - * * @throws CannotObtainLockException if look could not be obtained */ public function lock(FsDestination $destination); - /** - * @param FsDestination $destination - */ public function release(FsDestination $destination); public function releaseAll(); diff --git a/pkg/fs/Tests/FsConnectionFactoryConfigTest.php b/pkg/fs/Tests/FsConnectionFactoryConfigTest.php index 970fef395..0b3411f2c 100644 --- a/pkg/fs/Tests/FsConnectionFactoryConfigTest.php +++ b/pkg/fs/Tests/FsConnectionFactoryConfigTest.php @@ -51,9 +51,6 @@ public function testThrowIfArrayConfigGivenWithEmptyPath() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/pkg/fs/Tests/FsMessageTest.php b/pkg/fs/Tests/FsMessageTest.php index c2f788d04..90655b620 100644 --- a/pkg/fs/Tests/FsMessageTest.php +++ b/pkg/fs/Tests/FsMessageTest.php @@ -89,7 +89,7 @@ public function testCouldBeUnserializedFromJson() $json = json_encode($message); - //guard + // guard $this->assertNotEmpty($json); $unserializedMessage = FsMessage::jsonUnserialize($json); diff --git a/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php b/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php index 7abb9d91c..b96091e7f 100644 --- a/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php +++ b/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php @@ -111,7 +111,7 @@ public function testConsumerReceiveMessageWithZeroTimeout() $topic = $this->fsContext->createTopic('fs_test_queue_exchange'); $consumer = $this->fsContext->createConsumer($topic); - //guard + // guard $this->assertNull($consumer->receive(1000)); $message = $this->fsContext->createMessage(__METHOD__); diff --git a/pkg/fs/Tests/Functional/FsConsumerTest.php b/pkg/fs/Tests/Functional/FsConsumerTest.php index 984ea160a..3be009b02 100644 --- a/pkg/fs/Tests/Functional/FsConsumerTest.php +++ b/pkg/fs/Tests/Functional/FsConsumerTest.php @@ -159,7 +159,7 @@ public function testShouldThrowExceptionWhenFrameSizeNotDivideExactly() $context->workWithFile($queue, 'a+', function (FsDestination $destination, $file) { $msg = '|{"body":""}'; - //guard + // guard $this->assertNotSame(0, strlen($msg) % 64); fwrite($file, $msg); diff --git a/pkg/fs/Tests/Functional/FsContextTest.php b/pkg/fs/Tests/Functional/FsContextTest.php index 287fd6c04..806b9f56a 100644 --- a/pkg/fs/Tests/Functional/FsContextTest.php +++ b/pkg/fs/Tests/Functional/FsContextTest.php @@ -14,7 +14,7 @@ class FsContextTest extends TestCase */ private $fsContext; - public function tearDown(): void + protected function tearDown(): void { $fs = new Filesystem(); $fs->remove(sys_get_temp_dir().'/enqueue'); diff --git a/pkg/fs/Tests/Spec/FsMessageTest.php b/pkg/fs/Tests/Spec/FsMessageTest.php index 20dd4beca..f1ece8ecb 100644 --- a/pkg/fs/Tests/Spec/FsMessageTest.php +++ b/pkg/fs/Tests/Spec/FsMessageTest.php @@ -7,9 +7,6 @@ class FsMessageTest extends MessageSpec { - /** - * {@inheritdoc} - */ protected function createMessage() { return new FsMessage(); diff --git a/pkg/fs/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/fs/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php index 3dd1697c7..d6a76ca94 100644 --- a/pkg/fs/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php +++ b/pkg/fs/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php @@ -9,8 +9,6 @@ class FsSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTimeToLiveMessagesFromQueueSpec { /** - * {@inheritdoc} - * * @return FsContext */ protected function createContext() diff --git a/pkg/gearman/GearmanConsumer.php b/pkg/gearman/GearmanConsumer.php index 7c1dea0a1..e834fe469 100644 --- a/pkg/gearman/GearmanConsumer.php +++ b/pkg/gearman/GearmanConsumer.php @@ -27,8 +27,6 @@ class GearmanConsumer implements Consumer /** * Message content. - * - * @var mixed */ private $message; diff --git a/pkg/gearman/GearmanMessage.php b/pkg/gearman/GearmanMessage.php index 625566d62..ee93a78dd 100644 --- a/pkg/gearman/GearmanMessage.php +++ b/pkg/gearman/GearmanMessage.php @@ -101,7 +101,7 @@ public function setRedelivered(bool $redelivered): void $this->redelivered = $redelivered; } - public function setCorrelationId(string $correlationId = null): void + public function setCorrelationId(?string $correlationId = null): void { $this->setHeader('correlation_id', (string) $correlationId); } @@ -111,7 +111,7 @@ public function getCorrelationId(): ?string return $this->getHeader('correlation_id'); } - public function setMessageId(string $messageId = null): void + public function setMessageId(?string $messageId = null): void { $this->setHeader('message_id', (string) $messageId); } @@ -128,12 +128,12 @@ public function getTimestamp(): ?int return null === $value ? null : (int) $value; } - public function setTimestamp(int $timestamp = null): void + public function setTimestamp(?int $timestamp = null): void { $this->setHeader('timestamp', $timestamp); } - public function setReplyTo(string $replyTo = null): void + public function setReplyTo(?string $replyTo = null): void { $this->setHeader('reply_to', $replyTo); } @@ -155,12 +155,8 @@ public function jsonSerialize(): array public static function jsonUnserialize(string $json): self { $data = json_decode($json, true); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return new self($data['body'], $data['properties'], $data['headers']); @@ -171,7 +167,7 @@ public function getJob(): ?\GearmanJob return $this->job; } - public function setJob(\GearmanJob $job = null): void + public function setJob(?\GearmanJob $job = null): void { $this->job = $job; } diff --git a/pkg/gearman/GearmanProducer.php b/pkg/gearman/GearmanProducer.php index c297e71b2..870bdcb03 100644 --- a/pkg/gearman/GearmanProducer.php +++ b/pkg/gearman/GearmanProducer.php @@ -40,7 +40,7 @@ public function send(Destination $destination, Message $message): void } } - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { if (null === $deliveryDelay) { return $this; @@ -54,7 +54,7 @@ public function getDeliveryDelay(): ?int return null; } - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { if (null === $priority) { return $this; @@ -68,7 +68,7 @@ public function getPriority(): ?int return null; } - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { if (null === $timeToLive) { return $this; diff --git a/pkg/gearman/Tests/GearmanConnectionFactoryConfigTest.php b/pkg/gearman/Tests/GearmanConnectionFactoryConfigTest.php index 84826d5f9..8fc7a6b1e 100644 --- a/pkg/gearman/Tests/GearmanConnectionFactoryConfigTest.php +++ b/pkg/gearman/Tests/GearmanConnectionFactoryConfigTest.php @@ -42,9 +42,6 @@ public function testThrowIfDsnCouldNotBeParsed() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/pkg/gearman/Tests/Spec/GearmanConnectionFactoryTest.php b/pkg/gearman/Tests/Spec/GearmanConnectionFactoryTest.php index 148bf66d2..05418febc 100644 --- a/pkg/gearman/Tests/Spec/GearmanConnectionFactoryTest.php +++ b/pkg/gearman/Tests/Spec/GearmanConnectionFactoryTest.php @@ -10,9 +10,6 @@ class GearmanConnectionFactoryTest extends ConnectionFactorySpec { use SkipIfGearmanExtensionIsNotInstalledTrait; - /** - * {@inheritdoc} - */ protected function createConnectionFactory() { return new GearmanConnectionFactory(); diff --git a/pkg/gearman/Tests/Spec/GearmanContextTest.php b/pkg/gearman/Tests/Spec/GearmanContextTest.php index 7bfeee374..d5f879f12 100644 --- a/pkg/gearman/Tests/Spec/GearmanContextTest.php +++ b/pkg/gearman/Tests/Spec/GearmanContextTest.php @@ -11,9 +11,6 @@ */ class GearmanContextTest extends ContextSpec { - /** - * {@inheritdoc} - */ protected function createContext() { return (new GearmanConnectionFactory(getenv('GEARMAN_DSN')))->createContext(); diff --git a/pkg/gearman/Tests/Spec/GearmanMessageTest.php b/pkg/gearman/Tests/Spec/GearmanMessageTest.php index 7ad01d6db..37aa71e62 100644 --- a/pkg/gearman/Tests/Spec/GearmanMessageTest.php +++ b/pkg/gearman/Tests/Spec/GearmanMessageTest.php @@ -10,9 +10,6 @@ class GearmanMessageTest extends MessageSpec { use SkipIfGearmanExtensionIsNotInstalledTrait; - /** - * {@inheritdoc} - */ protected function createMessage() { return new GearmanMessage(); diff --git a/pkg/gearman/Tests/Spec/GearmanQueueTest.php b/pkg/gearman/Tests/Spec/GearmanQueueTest.php index 3d486849e..abf6be603 100644 --- a/pkg/gearman/Tests/Spec/GearmanQueueTest.php +++ b/pkg/gearman/Tests/Spec/GearmanQueueTest.php @@ -10,9 +10,6 @@ class GearmanQueueTest extends QueueSpec { use SkipIfGearmanExtensionIsNotInstalledTrait; - /** - * {@inheritdoc} - */ protected function createQueue() { return new GearmanDestination(self::EXPECTED_QUEUE_NAME); diff --git a/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveFromQueueTest.php index 47bf182c2..10a284987 100644 --- a/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveFromQueueTest.php +++ b/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveFromQueueTest.php @@ -13,9 +13,6 @@ */ class GearmanSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new GearmanConnectionFactory(getenv('GEARMAN_DSN')); diff --git a/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveNoWaitFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveNoWaitFromQueueTest.php index 86ce5b189..e2164ea7a 100644 --- a/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveNoWaitFromQueueTest.php +++ b/pkg/gearman/Tests/Spec/GearmanSendToAndReceiveNoWaitFromQueueTest.php @@ -12,9 +12,6 @@ */ class GearmanSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new GearmanConnectionFactory(getenv('GEARMAN_DSN')); @@ -22,9 +19,6 @@ protected function createContext() return $factory->createContext(); } - /** - * {@inheritdoc} - */ protected function createQueue(Context $context, $queueName) { return $context->createQueue($queueName.time()); diff --git a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php index c3f470528..32463cce1 100644 --- a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php +++ b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php @@ -19,9 +19,6 @@ protected function setUp(): void $this->time = time(); } - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new GearmanConnectionFactory(getenv('GEARMAN_DSN')); @@ -29,17 +26,11 @@ protected function createContext() return $factory->createContext(); } - /** - * {@inheritdoc} - */ protected function createQueue(Context $context, $queueName) { return $context->createQueue($queueName.$this->time); } - /** - * {@inheritdoc} - */ protected function createTopic(Context $context, $topicName) { return $context->createTopic($topicName.$this->time); diff --git a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php index 25c3596a1..993dc3f25 100644 --- a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php +++ b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php @@ -19,9 +19,6 @@ protected function setUp(): void $this->time = time(); } - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new GearmanConnectionFactory(getenv('GEARMAN_DSN')); @@ -29,17 +26,11 @@ protected function createContext() return $factory->createContext(); } - /** - * {@inheritdoc} - */ protected function createQueue(Context $context, $queueName) { return $context->createQueue($queueName.$this->time); } - /** - * {@inheritdoc} - */ protected function createTopic(Context $context, $topicName) { return $context->createTopic($topicName.$this->time); diff --git a/pkg/gearman/Tests/Spec/GearmanTopicTest.php b/pkg/gearman/Tests/Spec/GearmanTopicTest.php index 336c37f7d..826344e8b 100644 --- a/pkg/gearman/Tests/Spec/GearmanTopicTest.php +++ b/pkg/gearman/Tests/Spec/GearmanTopicTest.php @@ -10,9 +10,6 @@ class GearmanTopicTest extends TopicSpec { use SkipIfGearmanExtensionIsNotInstalledTrait; - /** - * {@inheritdoc} - */ protected function createTopic() { return new GearmanDestination(self::EXPECTED_TOPIC_NAME); diff --git a/pkg/gps/GpsConnectionFactory.php b/pkg/gps/GpsConnectionFactory.php index c15854763..e45f8cbe3 100644 --- a/pkg/gps/GpsConnectionFactory.php +++ b/pkg/gps/GpsConnectionFactory.php @@ -88,10 +88,7 @@ private function parseDsn(string $dsn): array $dsn = Dsn::parseFirst($dsn); if ('gps' !== $dsn->getSchemeProtocol()) { - throw new \LogicException(sprintf( - 'The given scheme protocol "%s" is not supported. It must be "gps"', - $dsn->getSchemeProtocol() - )); + throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "gps"', $dsn->getSchemeProtocol())); } $emulatorHost = $dsn->getString('emulatorHost'); diff --git a/pkg/gps/GpsContext.php b/pkg/gps/GpsContext.php index 77e6200cf..27625992a 100644 --- a/pkg/gps/GpsContext.php +++ b/pkg/gps/GpsContext.php @@ -52,11 +52,7 @@ public function __construct($client, array $options = []) } elseif (is_callable($client)) { $this->clientFactory = $client; } else { - throw new \InvalidArgumentException(sprintf( - 'The $client argument must be either %s or callable that returns %s once called.', - PubSubClient::class, - PubSubClient::class - )); + throw new \InvalidArgumentException(sprintf('The $client argument must be either %s or callable that returns %s once called.', PubSubClient::class, PubSubClient::class)); } } @@ -148,11 +144,7 @@ public function getClient(): PubSubClient if (false == $this->client) { $client = call_user_func($this->clientFactory); if (false == $client instanceof PubSubClient) { - throw new \LogicException(sprintf( - 'The factory must return instance of %s. It returned %s', - PubSubClient::class, - is_object($client) ? get_class($client) : gettype($client) - )); + throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', PubSubClient::class, is_object($client) ? $client::class : gettype($client))); } $this->client = $client; diff --git a/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php b/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php index 039e86cd4..474149497 100644 --- a/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php +++ b/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php @@ -41,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveFromQueueTest.php b/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveFromQueueTest.php index 30485b072..4bcaf357b 100644 --- a/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveFromQueueTest.php +++ b/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveFromQueueTest.php @@ -23,7 +23,6 @@ protected function createContext() /** * @param GpsContext $context - * @param mixed $queueName */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveNoWaitFromQueueTest.php index 240c71a3b..3a96bb533 100644 --- a/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveNoWaitFromQueueTest.php +++ b/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveNoWaitFromQueueTest.php @@ -23,7 +23,6 @@ protected function createContext() /** * @param GpsContext $context - * @param mixed $queueName */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/job-queue/CalculateRootJobStatusProcessor.php b/pkg/job-queue/CalculateRootJobStatusProcessor.php index b9b0c4dfb..96e7db2e8 100644 --- a/pkg/job-queue/CalculateRootJobStatusProcessor.php +++ b/pkg/job-queue/CalculateRootJobStatusProcessor.php @@ -38,7 +38,7 @@ public function __construct( JobStorage $jobStorage, CalculateRootJobStatusService $calculateRootJobStatusCase, ProducerInterface $producer, - LoggerInterface $logger + LoggerInterface $logger, ) { $this->jobStorage = $jobStorage; $this->calculateRootJobStatusService = $calculateRootJobStatusCase; diff --git a/pkg/job-queue/Commands.php b/pkg/job-queue/Commands.php index 57966c30c..ae744c991 100644 --- a/pkg/job-queue/Commands.php +++ b/pkg/job-queue/Commands.php @@ -4,5 +4,5 @@ class Commands { - const CALCULATE_ROOT_JOB_STATUS = 'enqueue.message_queue.job.calculate_root_job_status'; + public const CALCULATE_ROOT_JOB_STATUS = 'enqueue.message_queue.job.calculate_root_job_status'; } diff --git a/pkg/job-queue/DependentJobProcessor.php b/pkg/job-queue/DependentJobProcessor.php index 4916c7031..ac3055b5f 100644 --- a/pkg/job-queue/DependentJobProcessor.php +++ b/pkg/job-queue/DependentJobProcessor.php @@ -37,9 +37,6 @@ public function __construct(JobStorage $jobStorage, ProducerInterface $producer, $this->logger = $logger; } - /** - * {@inheritdoc} - */ public function process(Message $message, Context $context) { $data = JSON::decode($message->getBody()); diff --git a/pkg/job-queue/Doctrine/JobStorage.php b/pkg/job-queue/Doctrine/JobStorage.php index 0ee459e50..4db585696 100644 --- a/pkg/job-queue/Doctrine/JobStorage.php +++ b/pkg/job-queue/Doctrine/JobStorage.php @@ -124,11 +124,11 @@ public function createJob() /** * @throws DuplicateJobException */ - public function saveJob(Job $job, \Closure $lockCallback = null) + public function saveJob(Job $job, ?\Closure $lockCallback = null) { $class = $this->getEntityRepository()->getClassName(); if (!$job instanceof $class) { - throw new \LogicException(sprintf('Got unexpected job instance: expected: "%s", actual" "%s"', $class, get_class($job))); + throw new \LogicException(sprintf('Got unexpected job instance: expected: "%s", actual" "%s"', $class, $job::class)); } if ($lockCallback) { diff --git a/pkg/job-queue/Job.php b/pkg/job-queue/Job.php index ef0c42c4e..ddf53c2e3 100644 --- a/pkg/job-queue/Job.php +++ b/pkg/job-queue/Job.php @@ -4,11 +4,11 @@ class Job { - const STATUS_NEW = 'enqueue.job_queue.status.new'; - const STATUS_RUNNING = 'enqueue.job_queue.status.running'; - const STATUS_SUCCESS = 'enqueue.job_queue.status.success'; - const STATUS_FAILED = 'enqueue.job_queue.status.failed'; - const STATUS_CANCELLED = 'enqueue.job_queue.status.cancelled'; + public const STATUS_NEW = 'enqueue.job_queue.status.new'; + public const STATUS_RUNNING = 'enqueue.job_queue.status.running'; + public const STATUS_SUCCESS = 'enqueue.job_queue.status.success'; + public const STATUS_FAILED = 'enqueue.job_queue.status.failed'; + public const STATUS_CANCELLED = 'enqueue.job_queue.status.cancelled'; /** * @var int @@ -216,8 +216,6 @@ public function getRootJob() * Do not call from the outside. * * @internal - * - * @param Job $rootJob */ public function setRootJob(self $rootJob) { diff --git a/pkg/job-queue/JobRunner.php b/pkg/job-queue/JobRunner.php index e8d7eaa27..e21e524d6 100644 --- a/pkg/job-queue/JobRunner.php +++ b/pkg/job-queue/JobRunner.php @@ -14,10 +14,7 @@ class JobRunner */ private $rootJob; - /** - * @param Job $rootJob - */ - public function __construct(JobProcessor $jobProcessor, Job $rootJob = null) + public function __construct(JobProcessor $jobProcessor, ?Job $rootJob = null) { $this->jobProcessor = $jobProcessor; $this->rootJob = $rootJob; @@ -28,8 +25,6 @@ public function __construct(JobProcessor $jobProcessor, Job $rootJob = null) * @param string $name * * @throws \Throwable|\Exception if $runCallback triggers an exception - * - * @return mixed */ public function runUnique($ownerId, $name, callable $runCallback) { @@ -69,8 +64,6 @@ public function runUnique($ownerId, $name, callable $runCallback) /** * @param string $name - * - * @return mixed */ public function createDelayed($name, callable $startCallback) { @@ -83,8 +76,6 @@ public function createDelayed($name, callable $startCallback) /** * @param string $jobId - * - * @return mixed */ public function runDelayed($jobId, callable $runCallback) { diff --git a/pkg/job-queue/Test/DbalPersistedConnection.php b/pkg/job-queue/Test/DbalPersistedConnection.php index add0f3ddc..6e1dc4ca6 100644 --- a/pkg/job-queue/Test/DbalPersistedConnection.php +++ b/pkg/job-queue/Test/DbalPersistedConnection.php @@ -22,9 +22,6 @@ class DbalPersistedConnection extends Connection */ protected static $persistedTransactionNestingLevels; - /** - * {@inheritdoc} - */ public function connect() { if ($this->isConnected()) { @@ -41,25 +38,16 @@ public function connect() return true; } - /** - * {@inheritdoc} - */ public function beginTransaction() { $this->wrapTransactionNestingLevel('beginTransaction'); } - /** - * {@inheritdoc} - */ public function commit() { $this->wrapTransactionNestingLevel('commit'); } - /** - * {@inheritdoc} - */ public function rollBack() { $this->wrapTransactionNestingLevel('rollBack'); diff --git a/pkg/job-queue/Test/JobRunner.php b/pkg/job-queue/Test/JobRunner.php index 62d9f9a52..6194fbcee 100644 --- a/pkg/job-queue/Test/JobRunner.php +++ b/pkg/job-queue/Test/JobRunner.php @@ -26,9 +26,6 @@ public function __construct() { } - /** - * {@inheritdoc} - */ public function runUnique($ownerId, $jobName, \Closure $runCallback) { $this->runUniqueJobs[] = ['ownerId' => $ownerId, 'jobName' => $jobName, 'runCallback' => $runCallback]; @@ -36,11 +33,6 @@ public function runUnique($ownerId, $jobName, \Closure $runCallback) return call_user_func($runCallback, $this, new Job()); } - /** - * {@inheritdoc} - * - * @return mixed - */ public function createDelayed($jobName, \Closure $startCallback) { $this->createDelayedJobs[] = ['jobName' => $jobName, 'runCallback' => $startCallback]; @@ -48,11 +40,6 @@ public function createDelayed($jobName, \Closure $startCallback) return call_user_func($startCallback, $this, new Job()); } - /** - * {@inheritdoc} - * - * @return mixed - */ public function runDelayed($jobId, \Closure $runCallback) { $this->runDelayedJobs[] = ['jobId' => $jobId, 'runCallback' => $runCallback]; diff --git a/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php b/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php index 695c08e6e..a0f1b4c86 100644 --- a/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php +++ b/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php @@ -20,8 +20,6 @@ public function stopStatusProvider() /** * @dataProvider stopStatusProvider - * - * @param mixed $status */ public function testShouldDoNothingIfRootJobHasStopState($status) { @@ -70,8 +68,6 @@ public function testShouldCalculateRootJobStatus() /** * @dataProvider stopStatusProvider - * - * @param mixed $stopStatus */ public function testShouldCalculateRootJobStatusAndSetStoppedAtTimeIfGotStopStatus($stopStatus) { @@ -356,7 +352,7 @@ public function testShouldSetStatusSuccessIfAllAreSuccess() } /** - * @return MockObject|\Enqueue\JobQueue\Doctrine\JobStorage + * @return MockObject|JobStorage */ private function createJobStorageMock() { diff --git a/pkg/job-queue/Tests/DependentJobProcessorTest.php b/pkg/job-queue/Tests/DependentJobProcessorTest.php index fff9517a4..dcebf0d49 100644 --- a/pkg/job-queue/Tests/DependentJobProcessorTest.php +++ b/pkg/job-queue/Tests/DependentJobProcessorTest.php @@ -326,7 +326,7 @@ private function createContextMock() } /** - * @return MockObject|\Enqueue\JobQueue\Doctrine\JobStorage + * @return MockObject|JobStorage */ private function createJobStorageMock() { diff --git a/pkg/job-queue/Tests/DependentJobServiceTest.php b/pkg/job-queue/Tests/DependentJobServiceTest.php index e8809b4b0..c2a1c7b1a 100644 --- a/pkg/job-queue/Tests/DependentJobServiceTest.php +++ b/pkg/job-queue/Tests/DependentJobServiceTest.php @@ -63,7 +63,7 @@ public function testShouldSaveDependentJobs() } /** - * @return MockObject|\Enqueue\JobQueue\Doctrine\JobStorage + * @return MockObject|JobStorage */ private function createJobStorageMock() { diff --git a/pkg/job-queue/Tests/Functional/Job/JobStorageTest.php b/pkg/job-queue/Tests/Functional/Job/JobStorageTest.php index c2c8fb94d..e884c31e8 100644 --- a/pkg/job-queue/Tests/Functional/Job/JobStorageTest.php +++ b/pkg/job-queue/Tests/Functional/Job/JobStorageTest.php @@ -142,7 +142,7 @@ private function getEntityManager() } /** - * @return \Enqueue\JobQueue\Doctrine\JobStorage + * @return JobStorage */ private function getJobStorage() { diff --git a/pkg/job-queue/Tests/Functional/WebTestCase.php b/pkg/job-queue/Tests/Functional/WebTestCase.php index cd990384a..781bb5da4 100644 --- a/pkg/job-queue/Tests/Functional/WebTestCase.php +++ b/pkg/job-queue/Tests/Functional/WebTestCase.php @@ -58,9 +58,9 @@ protected function startTransaction() protected function rollbackTransaction() { - //the error can be thrown during setUp - //It would be caught by phpunit and tearDown called. - //In this case we could not rollback since container may not exist. + // the error can be thrown during setUp + // It would be caught by phpunit and tearDown called. + // In this case we could not rollback since container may not exist. if (false == static::$container) { return; } diff --git a/pkg/job-queue/Topics.php b/pkg/job-queue/Topics.php index 61b424b25..891ea26f7 100644 --- a/pkg/job-queue/Topics.php +++ b/pkg/job-queue/Topics.php @@ -4,5 +4,5 @@ class Topics { - const ROOT_JOB_STOPPED = 'enqueue.message_queue.job.root_job_stopped'; + public const ROOT_JOB_STOPPED = 'enqueue.message_queue.job.root_job_stopped'; } diff --git a/pkg/mongodb/JSON.php b/pkg/mongodb/JSON.php index 84cac50da..481b7f9ff 100644 --- a/pkg/mongodb/JSON.php +++ b/pkg/mongodb/JSON.php @@ -14,10 +14,7 @@ class JSON public static function decode($string) { if (!is_string($string)) { - throw new \InvalidArgumentException(sprintf( - 'Accept only string argument but got: "%s"', - is_object($string) ? get_class($string) : gettype($string) - )); + throw new \InvalidArgumentException(sprintf('Accept only string argument but got: "%s"', is_object($string) ? $string::class : gettype($string))); } // PHP7 fix - empty string and null cause syntax error @@ -26,32 +23,22 @@ public static function decode($string) } $decoded = json_decode($string, true); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return $decoded; } /** - * @param mixed $value - * * @return string */ public static function encode($value) { - $encoded = json_encode($value, JSON_UNESCAPED_UNICODE); - - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'Could not encode value into json. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + $encoded = json_encode($value, \JSON_UNESCAPED_UNICODE); + + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('Could not encode value into json. Error %s and message %s', json_last_error(), json_last_error_msg())); } return $encoded; diff --git a/pkg/mongodb/MongodbConnectionFactory.php b/pkg/mongodb/MongodbConnectionFactory.php index 3d7624904..3d34f7369 100644 --- a/pkg/mongodb/MongodbConnectionFactory.php +++ b/pkg/mongodb/MongodbConnectionFactory.php @@ -89,7 +89,7 @@ public static function parseDsn(string $dsn): array // see: https://github.com/php-enqueue/enqueue-dev/issues/1027 if (isset($parsedUrl['path']) && '/' !== $parsedUrl['path']) { $pathParts = explode('/', $parsedUrl['path']); - //DB name + // DB name if ($pathParts[1]) { $config['dbname'] = $pathParts[1]; } @@ -97,7 +97,7 @@ public static function parseDsn(string $dsn): array if (isset($parsedUrl['query'])) { $queryParts = null; parse_str($parsedUrl['query'], $queryParts); - //get enqueue attributes values + // get enqueue attributes values if (!empty($queryParts['polling_interval'])) { $config['polling_interval'] = (int) $queryParts['polling_interval']; } diff --git a/pkg/mongodb/MongodbMessage.php b/pkg/mongodb/MongodbMessage.php index fbfbd75d6..fadc5dd4e 100644 --- a/pkg/mongodb/MongodbMessage.php +++ b/pkg/mongodb/MongodbMessage.php @@ -65,7 +65,7 @@ public function __construct(string $body = '', array $properties = [], array $he $this->redelivered = false; } - public function setId(string $id = null): void + public function setId(?string $id = null): void { $this->id = $id; } @@ -135,7 +135,7 @@ public function setRedelivered(bool $redelivered): void $this->redelivered = $redelivered; } - public function setReplyTo(string $replyTo = null): void + public function setReplyTo(?string $replyTo = null): void { $this->setHeader('reply_to', $replyTo); } @@ -150,7 +150,7 @@ public function getPriority(): ?int return $this->priority; } - public function setPriority(int $priority = null): void + public function setPriority(?int $priority = null): void { $this->priority = $priority; } @@ -163,7 +163,7 @@ public function getDeliveryDelay(): ?int /** * In milliseconds. */ - public function setDeliveryDelay(int $deliveryDelay = null): void + public function setDeliveryDelay(?int $deliveryDelay = null): void { $this->deliveryDelay = $deliveryDelay; } @@ -176,12 +176,12 @@ public function getTimeToLive(): ?int /** * In milliseconds. */ - public function setTimeToLive(int $timeToLive = null): void + public function setTimeToLive(?int $timeToLive = null): void { $this->timeToLive = $timeToLive; } - public function setCorrelationId(string $correlationId = null): void + public function setCorrelationId(?string $correlationId = null): void { $this->setHeader('correlation_id', $correlationId); } @@ -191,7 +191,7 @@ public function getCorrelationId(): ?string return $this->getHeader('correlation_id', null); } - public function setMessageId(string $messageId = null): void + public function setMessageId(?string $messageId = null): void { $this->setHeader('message_id', $messageId); } @@ -208,7 +208,7 @@ public function getTimestamp(): ?int return null === $value ? null : (int) $value; } - public function setTimestamp(int $timestamp = null): void + public function setTimestamp(?int $timestamp = null): void { $this->setHeader('timestamp', $timestamp); } @@ -221,7 +221,7 @@ public function getPublishedAt(): ?int /** * In milliseconds. */ - public function setPublishedAt(int $publishedAt = null): void + public function setPublishedAt(?int $publishedAt = null): void { $this->publishedAt = $publishedAt; } diff --git a/pkg/mongodb/MongodbProducer.php b/pkg/mongodb/MongodbProducer.php index d26696cf8..ed28a6681 100644 --- a/pkg/mongodb/MongodbProducer.php +++ b/pkg/mongodb/MongodbProducer.php @@ -77,7 +77,7 @@ public function send(Destination $destination, Message $message): void $delay = $message->getDeliveryDelay(); if ($delay) { if (!is_int($delay)) { - throw new \LogicException(sprintf('Delay must be integer but got: "%s"', is_object($delay) ? get_class($delay) : gettype($delay))); + throw new \LogicException(sprintf('Delay must be integer but got: "%s"', is_object($delay) ? $delay::class : gettype($delay))); } if ($delay <= 0) { @@ -90,7 +90,7 @@ public function send(Destination $destination, Message $message): void $timeToLive = $message->getTimeToLive(); if ($timeToLive) { if (!is_int($timeToLive)) { - throw new \LogicException(sprintf('TimeToLive must be integer but got: "%s"', is_object($timeToLive) ? get_class($timeToLive) : gettype($timeToLive))); + throw new \LogicException(sprintf('TimeToLive must be integer but got: "%s"', is_object($timeToLive) ? $timeToLive::class : gettype($timeToLive))); } if ($timeToLive <= 0) { @@ -111,7 +111,7 @@ public function send(Destination $destination, Message $message): void /** * @return self */ - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { $this->deliveryDelay = $deliveryDelay; @@ -126,7 +126,7 @@ public function getDeliveryDelay(): ?int /** * @return self */ - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { $this->priority = $priority; @@ -141,7 +141,7 @@ public function getPriority(): ?int /** * @return self */ - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { $this->timeToLive = $timeToLive; diff --git a/pkg/mongodb/MongodbSubscriptionConsumer.php b/pkg/mongodb/MongodbSubscriptionConsumer.php index 59063dd82..9fa6245f4 100644 --- a/pkg/mongodb/MongodbSubscriptionConsumer.php +++ b/pkg/mongodb/MongodbSubscriptionConsumer.php @@ -21,9 +21,6 @@ class MongodbSubscriptionConsumer implements SubscriptionConsumer */ private $subscribers; - /** - * @param MongodbContext $context - */ public function __construct(MongodbContext $context) { $this->context = $context; @@ -92,7 +89,7 @@ public function consume(int $timeout = 0): void public function subscribe(Consumer $consumer, callable $callback): void { if (false == $consumer instanceof MongodbConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', MongodbConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', MongodbConsumer::class, $consumer::class)); } $queueName = $consumer->getQueue()->getQueueName(); @@ -113,7 +110,7 @@ public function subscribe(Consumer $consumer, callable $callback): void public function unsubscribe(Consumer $consumer): void { if (false == $consumer instanceof MongodbConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', MongodbConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', MongodbConsumer::class, $consumer::class)); } $queueName = $consumer->getQueue()->getQueueName(); diff --git a/pkg/mongodb/Tests/MongodbConsumerTest.php b/pkg/mongodb/Tests/MongodbConsumerTest.php index c6a642500..6cd597514 100644 --- a/pkg/mongodb/Tests/MongodbConsumerTest.php +++ b/pkg/mongodb/Tests/MongodbConsumerTest.php @@ -181,7 +181,7 @@ public function isRedelivered(): bool throw new \BadMethodCallException('This should not be called directly'); } - public function setCorrelationId(string $correlationId = null): void + public function setCorrelationId(?string $correlationId = null): void { } @@ -190,7 +190,7 @@ public function getCorrelationId(): ?string throw new \BadMethodCallException('This should not be called directly'); } - public function setMessageId(string $messageId = null): void + public function setMessageId(?string $messageId = null): void { } @@ -204,11 +204,11 @@ public function getTimestamp(): ?int throw new \BadMethodCallException('This should not be called directly'); } - public function setTimestamp(int $timestamp = null): void + public function setTimestamp(?int $timestamp = null): void { } - public function setReplyTo(string $replyTo = null): void + public function setReplyTo(?string $replyTo = null): void { } diff --git a/pkg/mongodb/Tests/Spec/MongodbConnectionFactoryTest.php b/pkg/mongodb/Tests/Spec/MongodbConnectionFactoryTest.php index 359b23eff..9f0d195ba 100644 --- a/pkg/mongodb/Tests/Spec/MongodbConnectionFactoryTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbConnectionFactoryTest.php @@ -10,9 +10,6 @@ */ class MongodbConnectionFactoryTest extends ConnectionFactorySpec { - /** - * {@inheritdoc} - */ protected function createConnectionFactory() { return new MongodbConnectionFactory(); diff --git a/pkg/mongodb/Tests/Spec/MongodbContextTest.php b/pkg/mongodb/Tests/Spec/MongodbContextTest.php index 22f2f3210..dfd5de3cb 100644 --- a/pkg/mongodb/Tests/Spec/MongodbContextTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbContextTest.php @@ -13,9 +13,6 @@ class MongodbContextTest extends ContextSpec { use MongodbExtensionTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildMongodbContext(); diff --git a/pkg/mongodb/Tests/Spec/MongodbMessageTest.php b/pkg/mongodb/Tests/Spec/MongodbMessageTest.php index 5efccfa01..92983d430 100644 --- a/pkg/mongodb/Tests/Spec/MongodbMessageTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbMessageTest.php @@ -10,9 +10,6 @@ */ class MongodbMessageTest extends MessageSpec { - /** - * {@inheritdoc} - */ protected function createMessage() { return new MongodbMessage(); diff --git a/pkg/mongodb/Tests/Spec/MongodbProducerTest.php b/pkg/mongodb/Tests/Spec/MongodbProducerTest.php index 9b4e18793..68b6007ec 100644 --- a/pkg/mongodb/Tests/Spec/MongodbProducerTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbProducerTest.php @@ -13,9 +13,6 @@ class MongodbProducerTest extends ProducerSpec { use MongodbExtensionTrait; - /** - * {@inheritdoc} - */ protected function createProducer() { return $this->buildMongodbContext()->createProducer(); diff --git a/pkg/mongodb/Tests/Spec/MongodbQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbQueueTest.php index f737d765f..25e437ba6 100644 --- a/pkg/mongodb/Tests/Spec/MongodbQueueTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbQueueTest.php @@ -10,9 +10,6 @@ */ class MongodbQueueTest extends QueueSpec { - /** - * {@inheritdoc} - */ protected function createQueue() { return new MongodbDestination(self::EXPECTED_QUEUE_NAME); diff --git a/pkg/mongodb/Tests/Spec/MongodbRequeueMessageTest.php b/pkg/mongodb/Tests/Spec/MongodbRequeueMessageTest.php index 454d357ad..8a9072470 100644 --- a/pkg/mongodb/Tests/Spec/MongodbRequeueMessageTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbRequeueMessageTest.php @@ -13,9 +13,6 @@ class MongodbRequeueMessageTest extends RequeueMessageSpec { use MongodbExtensionTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildMongodbContext(); diff --git a/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveDelayedMessageFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveDelayedMessageFromQueueTest.php index a5eb3511d..f54513fae 100644 --- a/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveDelayedMessageFromQueueTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveDelayedMessageFromQueueTest.php @@ -13,9 +13,6 @@ class MongodbSendAndReceiveDelayedMessageFromQueueTest extends SendAndReceiveDel { use MongodbExtensionTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildMongodbContext(); diff --git a/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php index ab9b13aaa..6aadef7ba 100644 --- a/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php @@ -34,8 +34,6 @@ protected function createContext() } /** - * {@inheritdoc} - * * @param MongodbContext $context * * @return MongodbMessage diff --git a/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveTimeToLiveMessagesFromQueueTest.php index d87ac10e9..f16e80b60 100644 --- a/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveTimeToLiveMessagesFromQueueTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbSendAndReceiveTimeToLiveMessagesFromQueueTest.php @@ -13,9 +13,6 @@ class MongodbSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiv { use MongodbExtensionTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildMongodbContext(); diff --git a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromQueueTest.php index 992c0626e..c9b9cb2d1 100644 --- a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromQueueTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromQueueTest.php @@ -13,9 +13,6 @@ class MongodbSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec { use MongodbExtensionTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildMongodbContext(); diff --git a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromTopicTest.php b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromTopicTest.php index c539386f7..a416d3c11 100644 --- a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromTopicTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveFromTopicTest.php @@ -13,9 +13,6 @@ class MongodbSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec { use MongodbExtensionTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildMongodbContext(); diff --git a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromQueueTest.php index ea4febcc2..43ae34c6b 100644 --- a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromQueueTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromQueueTest.php @@ -13,9 +13,6 @@ class MongodbSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitF { use MongodbExtensionTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildMongodbContext(); diff --git a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromTopicTest.php b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromTopicTest.php index 1e1be32c1..0fe9f0e56 100644 --- a/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromTopicTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbSendToAndReceiveNoWaitFromTopicTest.php @@ -13,9 +13,6 @@ class MongodbSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitF { use MongodbExtensionTrait; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildMongodbContext(); diff --git a/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php index 664990a68..2fe16e860 100644 --- a/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php @@ -20,8 +20,6 @@ class MongodbSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subs /** * @return MongodbContext - * - * {@inheritdoc} */ protected function createContext() { @@ -30,8 +28,6 @@ protected function createContext() /** * @param MongodbContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeUntilUnsubscribedTest.php index 1071c1267..b18e0bf0d 100644 --- a/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeUntilUnsubscribedTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerConsumeUntilUnsubscribedTest.php @@ -20,8 +20,6 @@ class MongodbSubscriptionConsumerConsumeUntilUnsubscribedTest extends Subscripti /** * @return MongodbContext - * - * {@inheritdoc} */ protected function createContext() { @@ -30,8 +28,6 @@ protected function createContext() /** * @param MongodbContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerStopOnFalseTest.php b/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerStopOnFalseTest.php index 321e16bba..3acfa94ed 100644 --- a/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerStopOnFalseTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbSubscriptionConsumerStopOnFalseTest.php @@ -20,8 +20,6 @@ class MongodbSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerSto /** * @return MongodbContext - * - * {@inheritdoc} */ protected function createContext() { @@ -30,8 +28,6 @@ protected function createContext() /** * @param MongodbContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/mongodb/Tests/Spec/MongodbTopicTest.php b/pkg/mongodb/Tests/Spec/MongodbTopicTest.php index ec524e519..ab5c025a2 100644 --- a/pkg/mongodb/Tests/Spec/MongodbTopicTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbTopicTest.php @@ -10,9 +10,6 @@ */ class MongodbTopicTest extends TopicSpec { - /** - * {@inheritdoc} - */ protected function createTopic() { return new MongodbDestination(self::EXPECTED_TOPIC_NAME); diff --git a/pkg/monitoring/ConsumedMessageStats.php b/pkg/monitoring/ConsumedMessageStats.php index 928bce0de..077ceebdf 100644 --- a/pkg/monitoring/ConsumedMessageStats.php +++ b/pkg/monitoring/ConsumedMessageStats.php @@ -6,10 +6,10 @@ class ConsumedMessageStats implements Stats { - const STATUS_ACK = 'acknowledged'; - const STATUS_REJECTED = 'rejected'; - const STATUS_REQUEUED = 'requeued'; - const STATUS_FAILED = 'failed'; + public const STATUS_ACK = 'acknowledged'; + public const STATUS_REJECTED = 'rejected'; + public const STATUS_REQUEUED = 'requeued'; + public const STATUS_FAILED = 'failed'; /** * @var string @@ -102,12 +102,12 @@ public function __construct( array $properties, bool $redelivered, string $status, - string $errorClass = null, - string $errorMessage = null, - int $errorCode = null, - string $errorFile = null, - int $errorLine = null, - string $trace = null + ?string $errorClass = null, + ?string $errorMessage = null, + ?int $errorCode = null, + ?string $errorFile = null, + ?int $errorLine = null, + ?string $trace = null, ) { $this->consumerId = $consumerId; $this->timestampMs = $timestampMs; diff --git a/pkg/monitoring/ConsumerStats.php b/pkg/monitoring/ConsumerStats.php index d1a745d14..d281b532d 100644 --- a/pkg/monitoring/ConsumerStats.php +++ b/pkg/monitoring/ConsumerStats.php @@ -121,12 +121,12 @@ public function __construct( int $requeued, int $memoryUsage, float $systemLoad, - string $errorClass = null, - string $errorMessage = null, - int $errorCode = null, - string $errorFile = null, - int $errorLine = null, - string $trace = null + ?string $errorClass = null, + ?string $errorMessage = null, + ?int $errorCode = null, + ?string $errorFile = null, + ?int $errorLine = null, + ?string $trace = null, ) { $this->consumerId = $consumerId; $this->timestampMs = $timestampMs; diff --git a/pkg/monitoring/DatadogStorage.php b/pkg/monitoring/DatadogStorage.php index 82e841a3f..c10cbc671 100644 --- a/pkg/monitoring/DatadogStorage.php +++ b/pkg/monitoring/DatadogStorage.php @@ -30,7 +30,7 @@ public function __construct($config = 'datadog:') $this->config = $this->prepareConfig($config); if (null === $this->datadog) { - if (true === filter_var($this->config['batched'], FILTER_VALIDATE_BOOLEAN)) { + if (true === filter_var($this->config['batched'], \FILTER_VALIDATE_BOOLEAN)) { $this->datadog = new BatchedDogStatsd($this->config); } else { $this->datadog = new DogStatsd($this->config); @@ -104,10 +104,7 @@ private function parseDsn(string $dsn): array $dsn = Dsn::parseFirst($dsn); if ('datadog' !== $dsn->getSchemeProtocol()) { - throw new \LogicException(sprintf( - 'The given scheme protocol "%s" is not supported. It must be "datadog"', - $dsn->getSchemeProtocol() - )); + throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "datadog"', $dsn->getSchemeProtocol())); } return array_filter(array_replace($dsn->getQuery(), [ @@ -132,11 +129,6 @@ private function parseDsn(string $dsn): array }); } - /** - * @param $config - * - * @return array - */ private function prepareConfig($config): array { if (empty($config)) { diff --git a/pkg/monitoring/InfluxDbStorage.php b/pkg/monitoring/InfluxDbStorage.php index ff5f6c3b0..3084864f8 100644 --- a/pkg/monitoring/InfluxDbStorage.php +++ b/pkg/monitoring/InfluxDbStorage.php @@ -67,9 +67,9 @@ public function __construct($config = 'influxdb:') // and causes library to use defaults. @trigger_error( sprintf('Passing %s as %s argument is deprecated. Pass it as "client" array property or use createWithClient instead', - Client::class, - __METHOD__ - ), E_USER_DEPRECATED); + Client::class, + __METHOD__ + ), \E_USER_DEPRECATED); $this->client = $config; $config = []; } else { @@ -91,12 +91,7 @@ public function __construct($config = 'influxdb:') if (null !== $config['client']) { if (!$config['client'] instanceof Client) { - throw new \InvalidArgumentException(sprintf( - '%s configuration property is expected to be an instance of %s class. %s was passed instead.', - 'client', - Client::class, - gettype($config['client']) - )); + throw new \InvalidArgumentException(sprintf('%s configuration property is expected to be an instance of %s class. %s was passed instead.', 'client', Client::class, gettype($config['client']))); } $this->client = $config['client']; } @@ -105,10 +100,7 @@ public function __construct($config = 'influxdb:') } /** - * @param Client $client * @param string $config - * - * @return InfluxDbStorage */ public static function createWithClient(Client $client, $config = 'influxdb:'): self { @@ -254,10 +246,7 @@ private static function parseDsn(string $dsn): array $dsn = Dsn::parseFirst($dsn); if (false === in_array($dsn->getSchemeProtocol(), ['influxdb'], true)) { - throw new \LogicException(sprintf( - 'The given scheme protocol "%s" is not supported. It must be "influxdb"', - $dsn->getSchemeProtocol() - )); + throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "influxdb"', $dsn->getSchemeProtocol())); } return array_filter(array_replace($dsn->getQuery(), [ diff --git a/pkg/monitoring/JsonSerializer.php b/pkg/monitoring/JsonSerializer.php index 1edb60e61..8d046092a 100644 --- a/pkg/monitoring/JsonSerializer.php +++ b/pkg/monitoring/JsonSerializer.php @@ -22,12 +22,8 @@ public function toString(Stats $stats): string $json = json_encode($data); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return $json; diff --git a/pkg/monitoring/Resources.php b/pkg/monitoring/Resources.php index 2a5995fa3..409d9861f 100644 --- a/pkg/monitoring/Resources.php +++ b/pkg/monitoring/Resources.php @@ -7,7 +7,7 @@ final class Resources /** * @var array */ - private static $knownStorages = null; + private static $knownStorages; private function __construct() { diff --git a/pkg/monitoring/SentMessageStats.php b/pkg/monitoring/SentMessageStats.php index 6106d3df8..f8ddc73be 100644 --- a/pkg/monitoring/SentMessageStats.php +++ b/pkg/monitoring/SentMessageStats.php @@ -48,7 +48,7 @@ public function __construct( ?string $messageId, ?string $correlationId, array $headers, - array $properties + array $properties, ) { $this->timestampMs = $timestampMs; $this->destination = $destination; diff --git a/pkg/monitoring/WampStorage.php b/pkg/monitoring/WampStorage.php index 44623d4e5..0d5ba1801 100644 --- a/pkg/monitoring/WampStorage.php +++ b/pkg/monitoring/WampStorage.php @@ -195,10 +195,7 @@ private function parseDsn(string $dsn): array $dsn = Dsn::parseFirst($dsn); if (false === in_array($dsn->getSchemeProtocol(), ['wamp', 'ws'], true)) { - throw new \LogicException(sprintf( - 'The given scheme protocol "%s" is not supported. It must be "wamp"', - $dsn->getSchemeProtocol() - )); + throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "wamp"', $dsn->getSchemeProtocol())); } return array_filter(array_replace($dsn->getQuery(), [ diff --git a/pkg/null/NullMessage.php b/pkg/null/NullMessage.php index bd48a387e..93fc57c3d 100644 --- a/pkg/null/NullMessage.php +++ b/pkg/null/NullMessage.php @@ -97,7 +97,7 @@ public function setRedelivered(bool $redelivered): void $this->redelivered = $redelivered; } - public function setCorrelationId(string $correlationId = null): void + public function setCorrelationId(?string $correlationId = null): void { $headers = $this->getHeaders(); $headers['correlation_id'] = (string) $correlationId; @@ -110,7 +110,7 @@ public function getCorrelationId(): ?string return $this->getHeader('correlation_id'); } - public function setMessageId(string $messageId = null): void + public function setMessageId(?string $messageId = null): void { $headers = $this->getHeaders(); $headers['message_id'] = (string) $messageId; @@ -130,7 +130,7 @@ public function getTimestamp(): ?int return null === $value ? null : (int) $value; } - public function setTimestamp(int $timestamp = null): void + public function setTimestamp(?int $timestamp = null): void { $headers = $this->getHeaders(); $headers['timestamp'] = (int) $timestamp; @@ -138,7 +138,7 @@ public function setTimestamp(int $timestamp = null): void $this->setHeaders($headers); } - public function setReplyTo(string $replyTo = null): void + public function setReplyTo(?string $replyTo = null): void { $this->setHeader('reply_to', $replyTo); } diff --git a/pkg/null/NullProducer.php b/pkg/null/NullProducer.php index 47235e7f6..1349de9ba 100644 --- a/pkg/null/NullProducer.php +++ b/pkg/null/NullProducer.php @@ -23,7 +23,7 @@ public function send(Destination $destination, Message $message): void /** * @return NullProducer */ - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { $this->deliveryDelay = $deliveryDelay; @@ -38,7 +38,7 @@ public function getDeliveryDelay(): ?int /** * @return NullProducer */ - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { $this->priority = $priority; @@ -53,7 +53,7 @@ public function getPriority(): ?int /** * @return NullProducer */ - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { $this->timeToLive = $timeToLive; diff --git a/pkg/null/Tests/Spec/NullMessageTest.php b/pkg/null/Tests/Spec/NullMessageTest.php index 34c6863ed..6bacc9294 100644 --- a/pkg/null/Tests/Spec/NullMessageTest.php +++ b/pkg/null/Tests/Spec/NullMessageTest.php @@ -7,9 +7,6 @@ class NullMessageTest extends MessageSpec { - /** - * {@inheritdoc} - */ protected function createMessage() { return new NullMessage(); diff --git a/pkg/pheanstalk/PheanstalkMessage.php b/pkg/pheanstalk/PheanstalkMessage.php index cf4ea1905..5bff1a7a6 100644 --- a/pkg/pheanstalk/PheanstalkMessage.php +++ b/pkg/pheanstalk/PheanstalkMessage.php @@ -103,7 +103,7 @@ public function setRedelivered(bool $redelivered): void $this->redelivered = $redelivered; } - public function setCorrelationId(string $correlationId = null): void + public function setCorrelationId(?string $correlationId = null): void { $this->setHeader('correlation_id', (string) $correlationId); } @@ -113,7 +113,7 @@ public function getCorrelationId(): ?string return $this->getHeader('correlation_id'); } - public function setMessageId(string $messageId = null): void + public function setMessageId(?string $messageId = null): void { $this->setHeader('message_id', (string) $messageId); } @@ -130,12 +130,12 @@ public function getTimestamp(): ?int return null === $value ? null : (int) $value; } - public function setTimestamp(int $timestamp = null): void + public function setTimestamp(?int $timestamp = null): void { $this->setHeader('timestamp', $timestamp); } - public function setReplyTo(string $replyTo = null): void + public function setReplyTo(?string $replyTo = null): void { $this->setHeader('reply_to', $replyTo); } @@ -187,12 +187,8 @@ public function jsonSerialize(): array public static function jsonUnserialize(string $json): self { $data = json_decode($json, true); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return new self($data['body'], $data['properties'], $data['headers']); @@ -203,7 +199,7 @@ public function getJob(): ?Job return $this->job; } - public function setJob(Job $job = null): void + public function setJob(?Job $job = null): void { $this->job = $job; } diff --git a/pkg/pheanstalk/PheanstalkProducer.php b/pkg/pheanstalk/PheanstalkProducer.php index 030beedf8..0c8ffd8ff 100644 --- a/pkg/pheanstalk/PheanstalkProducer.php +++ b/pkg/pheanstalk/PheanstalkProducer.php @@ -48,7 +48,7 @@ public function send(Destination $destination, Message $message): void InvalidMessageException::assertMessageInstanceOf($message, PheanstalkMessage::class); $rawMessage = json_encode($message); - if (JSON_ERROR_NONE !== json_last_error()) { + if (\JSON_ERROR_NONE !== json_last_error()) { throw new \InvalidArgumentException(sprintf('Could not encode value into json. Error %s and message %s', json_last_error(), json_last_error_msg())); } @@ -73,7 +73,7 @@ public function send(Destination $destination, Message $message): void /** * @return PheanstalkProducer */ - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { $this->deliveryDelay = $deliveryDelay; @@ -88,7 +88,7 @@ public function getDeliveryDelay(): ?int /** * @return PheanstalkProducer */ - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { $this->priority = $priority; @@ -103,7 +103,7 @@ public function getPriority(): ?int /** * @return PheanstalkProducer */ - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { $this->timeToLive = $timeToLive; diff --git a/pkg/pheanstalk/Tests/PheanstalkConnectionFactoryConfigTest.php b/pkg/pheanstalk/Tests/PheanstalkConnectionFactoryConfigTest.php index ef0030d42..a7bc7fc34 100644 --- a/pkg/pheanstalk/Tests/PheanstalkConnectionFactoryConfigTest.php +++ b/pkg/pheanstalk/Tests/PheanstalkConnectionFactoryConfigTest.php @@ -41,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/pkg/pheanstalk/Tests/PheanstalkConsumerTest.php b/pkg/pheanstalk/Tests/PheanstalkConsumerTest.php index 944ac9b81..c79b20bbd 100644 --- a/pkg/pheanstalk/Tests/PheanstalkConsumerTest.php +++ b/pkg/pheanstalk/Tests/PheanstalkConsumerTest.php @@ -46,7 +46,7 @@ public function testShouldReceiveFromQueueAndReturnNullIfNoMessageInQueue() public function testShouldReceiveFromQueueAndReturnMessageIfMessageInQueue() { $destination = new PheanstalkDestination('theQueueName'); - $message = new PheanstalkMessage('theBody', ['foo' => 'fooVal'], ['bar' => 'barVal']); + $message = new PheanstalkMessage('theBody', ['foo' => 'fooVal'], ['bar' => 'barVal']); $job = new Job('theJobId', json_encode($message)); diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkConnectionFactoryTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkConnectionFactoryTest.php index e05152599..4d9148447 100644 --- a/pkg/pheanstalk/Tests/Spec/PheanstalkConnectionFactoryTest.php +++ b/pkg/pheanstalk/Tests/Spec/PheanstalkConnectionFactoryTest.php @@ -7,9 +7,6 @@ class PheanstalkConnectionFactoryTest extends ConnectionFactorySpec { - /** - * {@inheritdoc} - */ protected function createConnectionFactory() { return new PheanstalkConnectionFactory(); diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkContextTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkContextTest.php index d69a41ef6..d6ea514f4 100644 --- a/pkg/pheanstalk/Tests/Spec/PheanstalkContextTest.php +++ b/pkg/pheanstalk/Tests/Spec/PheanstalkContextTest.php @@ -8,9 +8,6 @@ class PheanstalkContextTest extends ContextSpec { - /** - * {@inheritdoc} - */ protected function createContext() { return new PheanstalkContext($this->createMock(Pheanstalk::class)); diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkMessageTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkMessageTest.php index 30fb1cf1b..692e0db54 100644 --- a/pkg/pheanstalk/Tests/Spec/PheanstalkMessageTest.php +++ b/pkg/pheanstalk/Tests/Spec/PheanstalkMessageTest.php @@ -7,9 +7,6 @@ class PheanstalkMessageTest extends MessageSpec { - /** - * {@inheritdoc} - */ protected function createMessage() { return new PheanstalkMessage(); diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkQueueTest.php index a71dc4687..0a770b2e2 100644 --- a/pkg/pheanstalk/Tests/Spec/PheanstalkQueueTest.php +++ b/pkg/pheanstalk/Tests/Spec/PheanstalkQueueTest.php @@ -7,9 +7,6 @@ class PheanstalkQueueTest extends QueueSpec { - /** - * {@inheritdoc} - */ protected function createQueue() { return new PheanstalkDestination(self::EXPECTED_QUEUE_NAME); diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveFromQueueTest.php index 45d0040b4..282ac364c 100644 --- a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveFromQueueTest.php +++ b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveFromQueueTest.php @@ -12,9 +12,6 @@ */ class PheanstalkSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new PheanstalkConnectionFactory(getenv('BEANSTALKD_DSN')); @@ -23,8 +20,7 @@ protected function createContext() } /** - * @param Context $context - * @param string $queueName + * @param string $queueName * * @return Queue */ diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveNoWaitFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveNoWaitFromQueueTest.php index 8226b512e..de464e5bf 100644 --- a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveNoWaitFromQueueTest.php +++ b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToAndReceiveNoWaitFromQueueTest.php @@ -11,9 +11,6 @@ */ class PheanstalkSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec { - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new PheanstalkConnectionFactory(getenv('BEANSTALKD_DSN')); @@ -21,9 +18,6 @@ protected function createContext() return $factory->createContext(); } - /** - * {@inheritdoc} - */ protected function createQueue(Context $context, $queueName) { return $context->createQueue($queueName.time()); diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php index a961cdf3f..4c30d7796 100644 --- a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php +++ b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php @@ -18,9 +18,6 @@ protected function setUp(): void $this->time = time(); } - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new PheanstalkConnectionFactory(getenv('BEANSTALKD_DSN')); @@ -28,17 +25,11 @@ protected function createContext() return $factory->createContext(); } - /** - * {@inheritdoc} - */ protected function createQueue(Context $context, $queueName) { return $context->createQueue($queueName.$this->time); } - /** - * {@inheritdoc} - */ protected function createTopic(Context $context, $topicName) { return $context->createTopic($topicName.$this->time); diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php index cedc0dd48..58e8b71f4 100644 --- a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php +++ b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php @@ -18,9 +18,6 @@ protected function setUp(): void $this->time = time(); } - /** - * {@inheritdoc} - */ protected function createContext() { $factory = new PheanstalkConnectionFactory(getenv('BEANSTALKD_DSN')); @@ -28,17 +25,11 @@ protected function createContext() return $factory->createContext(); } - /** - * {@inheritdoc} - */ protected function createQueue(Context $context, $queueName) { return $context->createQueue($queueName.$this->time); } - /** - * {@inheritdoc} - */ protected function createTopic(Context $context, $topicName) { return $context->createTopic($topicName.$this->time); diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkTopicTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkTopicTest.php index d15d51083..4b0028261 100644 --- a/pkg/pheanstalk/Tests/Spec/PheanstalkTopicTest.php +++ b/pkg/pheanstalk/Tests/Spec/PheanstalkTopicTest.php @@ -7,9 +7,6 @@ class PheanstalkTopicTest extends TopicSpec { - /** - * {@inheritdoc} - */ protected function createTopic() { return new PheanstalkDestination(self::EXPECTED_TOPIC_NAME); diff --git a/pkg/rdkafka/JsonSerializer.php b/pkg/rdkafka/JsonSerializer.php index ae161ca08..1d25ea55e 100644 --- a/pkg/rdkafka/JsonSerializer.php +++ b/pkg/rdkafka/JsonSerializer.php @@ -14,12 +14,8 @@ public function toString(RdKafkaMessage $message): string 'headers' => $message->getHeaders(), ]); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return $json; @@ -28,12 +24,8 @@ public function toString(RdKafkaMessage $message): string public function toMessage(string $string): RdKafkaMessage { $data = json_decode($string, true); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return new RdKafkaMessage($data['body'], $data['properties'], $data['headers']); diff --git a/pkg/rdkafka/RdKafkaConsumer.php b/pkg/rdkafka/RdKafkaConsumer.php index 7fbaef755..8b6cf12c6 100644 --- a/pkg/rdkafka/RdKafkaConsumer.php +++ b/pkg/rdkafka/RdKafkaConsumer.php @@ -71,7 +71,7 @@ public function getOffset(): ?int return $this->offset; } - public function setOffset(int $offset = null): void + public function setOffset(?int $offset = null): void { if ($this->subscribed) { throw new \LogicException('The consumer has already subscribed.'); @@ -167,11 +167,11 @@ private function doReceive(int $timeout): ?RdKafkaMessage } switch ($kafkaMessage->err) { - case RD_KAFKA_RESP_ERR__PARTITION_EOF: - case RD_KAFKA_RESP_ERR__TIMED_OUT: - case RD_KAFKA_RESP_ERR__TRANSPORT: + case \RD_KAFKA_RESP_ERR__PARTITION_EOF: + case \RD_KAFKA_RESP_ERR__TIMED_OUT: + case \RD_KAFKA_RESP_ERR__TRANSPORT: return null; - case RD_KAFKA_RESP_ERR_NO_ERROR: + case \RD_KAFKA_RESP_ERR_NO_ERROR: $message = $this->serializer->toMessage($kafkaMessage->payload); $message->setKey($kafkaMessage->key); $message->setPartition($kafkaMessage->partition); diff --git a/pkg/rdkafka/RdKafkaContext.php b/pkg/rdkafka/RdKafkaContext.php index 9930b56ee..a252fcfd5 100644 --- a/pkg/rdkafka/RdKafkaContext.php +++ b/pkg/rdkafka/RdKafkaContext.php @@ -173,9 +173,9 @@ public static function getLibrdKafkaVersion(): string if (!defined('RD_KAFKA_VERSION')) { throw new \RuntimeException('RD_KAFKA_VERSION constant is not defined. Phprdkafka is probably not installed'); } - $major = (RD_KAFKA_VERSION & 0xFF000000) >> 24; - $minor = (RD_KAFKA_VERSION & 0x00FF0000) >> 16; - $patch = (RD_KAFKA_VERSION & 0x0000FF00) >> 8; + $major = (\RD_KAFKA_VERSION & 0xFF000000) >> 24; + $minor = (\RD_KAFKA_VERSION & 0x00FF0000) >> 16; + $patch = (\RD_KAFKA_VERSION & 0x0000FF00) >> 8; return "$major.$minor.$patch"; } diff --git a/pkg/rdkafka/RdKafkaMessage.php b/pkg/rdkafka/RdKafkaMessage.php index 0785a5644..7c6d0d005 100644 --- a/pkg/rdkafka/RdKafkaMessage.php +++ b/pkg/rdkafka/RdKafkaMessage.php @@ -112,7 +112,7 @@ public function setRedelivered(bool $redelivered): void $this->redelivered = $redelivered; } - public function setCorrelationId(string $correlationId = null): void + public function setCorrelationId(?string $correlationId = null): void { $this->setHeader('correlation_id', (string) $correlationId); } @@ -122,7 +122,7 @@ public function getCorrelationId(): ?string return $this->getHeader('correlation_id'); } - public function setMessageId(string $messageId = null): void + public function setMessageId(?string $messageId = null): void { $this->setHeader('message_id', (string) $messageId); } @@ -139,12 +139,12 @@ public function getTimestamp(): ?int return null === $value ? null : (int) $value; } - public function setTimestamp(int $timestamp = null): void + public function setTimestamp(?int $timestamp = null): void { $this->setHeader('timestamp', $timestamp); } - public function setReplyTo(string $replyTo = null): void + public function setReplyTo(?string $replyTo = null): void { $this->setHeader('reply_to', $replyTo); } @@ -159,7 +159,7 @@ public function getPartition(): ?int return $this->partition; } - public function setPartition(int $partition = null): void + public function setPartition(?int $partition = null): void { $this->partition = $partition; } @@ -169,7 +169,7 @@ public function getKey(): ?string return $this->key; } - public function setKey(string $key = null): void + public function setKey(?string $key = null): void { $this->key = $key; } @@ -179,7 +179,7 @@ public function getKafkaMessage(): ?VendorMessage return $this->kafkaMessage; } - public function setKafkaMessage(VendorMessage $message = null): void + public function setKafkaMessage(?VendorMessage $message = null): void { $this->kafkaMessage = $message; } diff --git a/pkg/rdkafka/RdKafkaProducer.php b/pkg/rdkafka/RdKafkaProducer.php index 64b9ea3a7..c70f1fbe6 100644 --- a/pkg/rdkafka/RdKafkaProducer.php +++ b/pkg/rdkafka/RdKafkaProducer.php @@ -37,7 +37,7 @@ public function send(Destination $destination, Message $message): void InvalidDestinationException::assertDestinationInstanceOf($destination, RdKafkaTopic::class); InvalidMessageException::assertMessageInstanceOf($message, RdKafkaMessage::class); - $partition = $message->getPartition() ?? $destination->getPartition() ?? RD_KAFKA_PARTITION_UA; + $partition = $message->getPartition() ?? $destination->getPartition() ?? \RD_KAFKA_PARTITION_UA; $payload = $this->serializer->toString($message); $key = $message->getKey() ?? $destination->getKey() ?? null; @@ -70,7 +70,7 @@ public function send(Destination $destination, Message $message): void /** * @return RdKafkaProducer */ - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { if (null === $deliveryDelay) { return $this; @@ -87,7 +87,7 @@ public function getDeliveryDelay(): ?int /** * @return RdKafkaProducer */ - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { if (null === $priority) { return $this; @@ -101,7 +101,7 @@ public function getPriority(): ?int return null; } - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { if (null === $timeToLive) { return $this; diff --git a/pkg/rdkafka/RdKafkaTopic.php b/pkg/rdkafka/RdKafkaTopic.php index a7bde1021..572f4d024 100644 --- a/pkg/rdkafka/RdKafkaTopic.php +++ b/pkg/rdkafka/RdKafkaTopic.php @@ -50,7 +50,7 @@ public function getConf(): ?TopicConf return $this->conf; } - public function setConf(TopicConf $conf = null): void + public function setConf(?TopicConf $conf = null): void { $this->conf = $conf; } @@ -60,7 +60,7 @@ public function getPartition(): ?int return $this->partition; } - public function setPartition(int $partition = null): void + public function setPartition(?int $partition = null): void { $this->partition = $partition; } @@ -70,7 +70,7 @@ public function getKey(): ?string return $this->key; } - public function setKey(string $key = null): void + public function setKey(?string $key = null): void { $this->key = $key; } diff --git a/pkg/rdkafka/SerializerAwareTrait.php b/pkg/rdkafka/SerializerAwareTrait.php index d640f93cb..1cd1fac20 100644 --- a/pkg/rdkafka/SerializerAwareTrait.php +++ b/pkg/rdkafka/SerializerAwareTrait.php @@ -11,9 +11,6 @@ trait SerializerAwareTrait */ private $serializer; - /** - * @param Serializer $serializer - */ public function setSerializer(Serializer $serializer) { $this->serializer = $serializer; diff --git a/pkg/rdkafka/Tests/RdKafkaConnectionFactoryConfigTest.php b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryConfigTest.php index 0a50218bb..7ecb1bd7f 100644 --- a/pkg/rdkafka/Tests/RdKafkaConnectionFactoryConfigTest.php +++ b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryConfigTest.php @@ -33,9 +33,6 @@ public function testThrowIfSchemeIsNotSupported() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php index 62ccc7612..d7121da65 100644 --- a/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php +++ b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php @@ -70,9 +70,6 @@ public function testShouldBeExpectedDefaultDsnConfig() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/pkg/rdkafka/Tests/RdKafkaConsumerTest.php b/pkg/rdkafka/Tests/RdKafkaConsumerTest.php index 74e92954b..a0544da6c 100644 --- a/pkg/rdkafka/Tests/RdKafkaConsumerTest.php +++ b/pkg/rdkafka/Tests/RdKafkaConsumerTest.php @@ -32,7 +32,7 @@ public function testShouldReceiveFromQueueAndReturnNullIfNoMessageInQueue() $destination = new RdKafkaTopic('dest'); $kafkaMessage = new Message(); - $kafkaMessage->err = RD_KAFKA_RESP_ERR__TIMED_OUT; + $kafkaMessage->err = \RD_KAFKA_RESP_ERR__TIMED_OUT; $kafkaConsumer = $this->createKafkaConsumerMock(); $kafkaConsumer @@ -61,7 +61,7 @@ public function testShouldPassProperlyConfiguredTopicPartitionOnAssign() $destination = new RdKafkaTopic('dest'); $kafkaMessage = new Message(); - $kafkaMessage->err = RD_KAFKA_RESP_ERR__TIMED_OUT; + $kafkaMessage->err = \RD_KAFKA_RESP_ERR__TIMED_OUT; $kafkaConsumer = $this->createKafkaConsumerMock(); $kafkaConsumer @@ -91,7 +91,7 @@ public function testShouldSubscribeOnFirstReceiveOnly() $destination = new RdKafkaTopic('dest'); $kafkaMessage = new Message(); - $kafkaMessage->err = RD_KAFKA_RESP_ERR__TIMED_OUT; + $kafkaMessage->err = \RD_KAFKA_RESP_ERR__TIMED_OUT; $kafkaConsumer = $this->createKafkaConsumerMock(); $kafkaConsumer @@ -122,7 +122,7 @@ public function testShouldAssignWhenOffsetIsSet() $destination->setPartition(1); $kafkaMessage = new Message(); - $kafkaMessage->err = RD_KAFKA_RESP_ERR__TIMED_OUT; + $kafkaMessage->err = \RD_KAFKA_RESP_ERR__TIMED_OUT; $kafkaConsumer = $this->createKafkaConsumerMock(); $kafkaConsumer @@ -154,7 +154,7 @@ public function testThrowOnOffsetChangeAfterSubscribing() $destination = new RdKafkaTopic('dest'); $kafkaMessage = new Message(); - $kafkaMessage->err = RD_KAFKA_RESP_ERR__TIMED_OUT; + $kafkaMessage->err = \RD_KAFKA_RESP_ERR__TIMED_OUT; $kafkaConsumer = $this->createKafkaConsumerMock(); $kafkaConsumer @@ -188,7 +188,7 @@ public function testShouldReceiveFromQueueAndReturnMessageIfMessageInQueue() $expectedMessage = new RdKafkaMessage('theBody', ['foo' => 'fooVal'], ['bar' => 'barVal']); $kafkaMessage = new Message(); - $kafkaMessage->err = RD_KAFKA_RESP_ERR_NO_ERROR; + $kafkaMessage->err = \RD_KAFKA_RESP_ERR_NO_ERROR; $kafkaMessage->payload = 'theSerializedMessage'; $kafkaConsumer = $this->createKafkaConsumerMock(); diff --git a/pkg/rdkafka/Tests/RdKafkaProducerTest.php b/pkg/rdkafka/Tests/RdKafkaProducerTest.php index 6082968ad..6295fbc1b 100644 --- a/pkg/rdkafka/Tests/RdKafkaProducerTest.php +++ b/pkg/rdkafka/Tests/RdKafkaProducerTest.php @@ -46,7 +46,7 @@ public function testShouldUseSerializerToEncodeMessageAndPutToExpectedTube() ->expects($this->once()) ->method('producev') ->with( - RD_KAFKA_PARTITION_UA, + \RD_KAFKA_PARTITION_UA, 0, 'theSerializedMessage', 'key', @@ -183,7 +183,7 @@ public function testShouldAllowSerializersToSerializeKeys() ->expects($this->once()) ->method('producev') ->with( - RD_KAFKA_PARTITION_UA, + \RD_KAFKA_PARTITION_UA, 0, 'theSerializedMessage', 'theSerializedKey' @@ -324,7 +324,7 @@ public function testShouldAllowFalsyKeyFromMessage(): void ->expects($this->once()) ->method('producev') ->with( - RD_KAFKA_PARTITION_UA, + \RD_KAFKA_PARTITION_UA, 0, '', $key @@ -354,7 +354,7 @@ public function testShouldAllowFalsyKeyFromDestination(): void ->expects($this->once()) ->method('producev') ->with( - RD_KAFKA_PARTITION_UA, + \RD_KAFKA_PARTITION_UA, 0, '', $key diff --git a/pkg/rdkafka/Tests/Spec/RdKafkaMessageTest.php b/pkg/rdkafka/Tests/Spec/RdKafkaMessageTest.php index df54fa58b..9e230d1b6 100644 --- a/pkg/rdkafka/Tests/Spec/RdKafkaMessageTest.php +++ b/pkg/rdkafka/Tests/Spec/RdKafkaMessageTest.php @@ -7,9 +7,6 @@ class RdKafkaMessageTest extends MessageSpec { - /** - * {@inheritdoc} - */ protected function createMessage() { return new RdKafkaMessage(); diff --git a/pkg/rdkafka/Tests/Spec/RdKafkaTopicTest.php b/pkg/rdkafka/Tests/Spec/RdKafkaTopicTest.php index c5d43ee61..08d427883 100644 --- a/pkg/rdkafka/Tests/Spec/RdKafkaTopicTest.php +++ b/pkg/rdkafka/Tests/Spec/RdKafkaTopicTest.php @@ -7,9 +7,6 @@ class RdKafkaTopicTest extends TopicSpec { - /** - * {@inheritdoc} - */ protected function createTopic() { return new RdKafkaTopic(self::EXPECTED_TOPIC_NAME); diff --git a/pkg/rdkafka/Tests/bootstrap.php b/pkg/rdkafka/Tests/bootstrap.php index bf112623e..60f8101ef 100644 --- a/pkg/rdkafka/Tests/bootstrap.php +++ b/pkg/rdkafka/Tests/bootstrap.php @@ -8,7 +8,7 @@ if (false == file_exists($kafkaStubsDir)) { $kafkaStubsDir = __DIR__.'/../../../vendor/kwn/php-rdkafka-stubs'; if (false == file_exists($kafkaStubsDir)) { - throw new \LogicException('The kafka extension is not loaded and stubs could not be found as well'); + throw new LogicException('The kafka extension is not loaded and stubs could not be found as well'); } } diff --git a/pkg/redis/JsonSerializer.php b/pkg/redis/JsonSerializer.php index 7e064a221..ff67ed880 100644 --- a/pkg/redis/JsonSerializer.php +++ b/pkg/redis/JsonSerializer.php @@ -14,12 +14,8 @@ public function toString(RedisMessage $message): string 'headers' => $message->getHeaders(), ]); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return $json; @@ -28,12 +24,8 @@ public function toString(RedisMessage $message): string public function toMessage(string $string): RedisMessage { $data = json_decode($string, true); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return new RedisMessage($data['body'], $data['properties'], $data['headers']); diff --git a/pkg/redis/PhpRedis.php b/pkg/redis/PhpRedis.php index d6f5baffa..1a229e3c9 100644 --- a/pkg/redis/PhpRedis.php +++ b/pkg/redis/PhpRedis.php @@ -96,18 +96,14 @@ public function connect(): void $supportedSchemes = ['redis', 'rediss', 'tcp', 'unix']; if (false == in_array($this->config['scheme'], $supportedSchemes, true)) { - throw new \LogicException(sprintf( - 'The given scheme protocol "%s" is not supported by php extension. It must be one of "%s"', - $this->config['scheme'], - implode('", "', $supportedSchemes) - )); + throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported by php extension. It must be one of "%s"', $this->config['scheme'], implode('", "', $supportedSchemes))); } $this->redis = new \Redis(); $connectionMethod = $this->config['persistent'] ? 'pconnect' : 'connect'; - $host = $this->config['scheme'] === 'rediss' ? 'tls://' . $this->config['host'] : $this->config['host']; + $host = 'rediss' === $this->config['scheme'] ? 'tls://'.$this->config['host'] : $this->config['host']; $result = call_user_func( [$this->redis, $connectionMethod], diff --git a/pkg/redis/Redis.php b/pkg/redis/Redis.php index 362f5e8d0..04165af9d 100644 --- a/pkg/redis/Redis.php +++ b/pkg/redis/Redis.php @@ -7,41 +7,21 @@ interface Redis { /** - * @param string $script - * @param array $keys - * @param array $args - * * @throws ServerException - * - * @return mixed */ public function eval(string $script, array $keys = [], array $args = []); /** - * @param string $key - * @param string $value - * @param float $score - * * @throws ServerException - * - * @return int */ public function zadd(string $key, string $value, float $score): int; /** - * @param string $key - * @param string $value - * * @throws ServerException - * - * @return int */ public function zrem(string $key, string $value): int; /** - * @param string $key - * @param string $value - * * @throws ServerException * * @return int length of the list @@ -53,17 +33,11 @@ public function lpush(string $key, string $value): int; * @param int $timeout in seconds * * @throws ServerException - * - * @return RedisResult|null */ public function brpop(array $keys, int $timeout): ?RedisResult; /** - * @param string $key - * * @throws ServerException - * - * @return RedisResult|null */ public function rpop(string $key): ?RedisResult; @@ -75,8 +49,6 @@ public function connect(): void; public function disconnect(): void; /** - * @param string $key - * * @throws ServerException */ public function del(string $key): void; diff --git a/pkg/redis/RedisConsumer.php b/pkg/redis/RedisConsumer.php index 9c93b642a..ca3733d4b 100644 --- a/pkg/redis/RedisConsumer.php +++ b/pkg/redis/RedisConsumer.php @@ -34,9 +34,6 @@ public function __construct(RedisContext $context, RedisDestination $queue) $this->queue = $queue; } - /** - * @return int - */ public function getRedeliveryDelay(): ?int { return $this->redeliveryDelay; diff --git a/pkg/redis/RedisConsumerHelperTrait.php b/pkg/redis/RedisConsumerHelperTrait.php index 9939986ed..063ff1fbd 100644 --- a/pkg/redis/RedisConsumerHelperTrait.php +++ b/pkg/redis/RedisConsumerHelperTrait.php @@ -15,10 +15,6 @@ abstract protected function getContext(): RedisContext; /** * @param RedisDestination[] $queues - * @param int $timeout - * @param int $redeliveryDelay - * - * @return RedisMessage|null */ protected function receiveMessage(array $queues, int $timeout, int $redeliveryDelay): ?RedisMessage { diff --git a/pkg/redis/RedisContext.php b/pkg/redis/RedisContext.php index 344bb20c5..346375f8d 100644 --- a/pkg/redis/RedisContext.php +++ b/pkg/redis/RedisContext.php @@ -38,7 +38,6 @@ class RedisContext implements Context * Callable must return instance of Redis once called. * * @param Redis|callable $redis - * @param int $redeliveryDelay */ public function __construct($redis, int $redeliveryDelay) { @@ -47,11 +46,7 @@ public function __construct($redis, int $redeliveryDelay) } elseif (is_callable($redis)) { $this->redisFactory = $redis; } else { - throw new \InvalidArgumentException(sprintf( - 'The $redis argument must be either %s or callable that returns %s once called.', - Redis::class, - Redis::class - )); + throw new \InvalidArgumentException(sprintf('The $redis argument must be either %s or callable that returns %s once called.', Redis::class, Redis::class)); } $this->redeliveryDelay = $redeliveryDelay; @@ -159,11 +154,7 @@ public function getRedis(): Redis if (false == $this->redis) { $redis = call_user_func($this->redisFactory); if (false == $redis instanceof Redis) { - throw new \LogicException(sprintf( - 'The factory must return instance of %s. It returned %s', - Redis::class, - is_object($redis) ? get_class($redis) : gettype($redis) - )); + throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', Redis::class, is_object($redis) ? $redis::class : gettype($redis))); } $this->redis = $redis; diff --git a/pkg/redis/RedisMessage.php b/pkg/redis/RedisMessage.php index 74c65475a..708bdbc97 100644 --- a/pkg/redis/RedisMessage.php +++ b/pkg/redis/RedisMessage.php @@ -107,7 +107,7 @@ public function isRedelivered(): bool return $this->redelivered; } - public function setCorrelationId(string $correlationId = null): void + public function setCorrelationId(?string $correlationId = null): void { $this->setHeader('correlation_id', $correlationId); } @@ -117,7 +117,7 @@ public function getCorrelationId(): ?string return $this->getHeader('correlation_id'); } - public function setMessageId(string $messageId = null): void + public function setMessageId(?string $messageId = null): void { $this->setHeader('message_id', $messageId); } @@ -134,12 +134,12 @@ public function getTimestamp(): ?int return null === $value ? null : (int) $value; } - public function setTimestamp(int $timestamp = null): void + public function setTimestamp(?int $timestamp = null): void { $this->setHeader('timestamp', $timestamp); } - public function setReplyTo(string $replyTo = null): void + public function setReplyTo(?string $replyTo = null): void { $this->setHeader('reply_to', $replyTo); } @@ -149,17 +149,11 @@ public function getReplyTo(): ?string return $this->getHeader('reply_to'); } - /** - * @return int - */ public function getAttempts(): int { return (int) $this->getHeader('attempts', 0); } - /** - * @return int - */ public function getTimeToLive(): ?int { return $this->getHeader('time_to_live'); @@ -168,7 +162,7 @@ public function getTimeToLive(): ?int /** * Set time to live in milliseconds. */ - public function setTimeToLive(int $timeToLive = null): void + public function setTimeToLive(?int $timeToLive = null): void { $this->setHeader('time_to_live', $timeToLive); } @@ -181,38 +175,26 @@ public function getDeliveryDelay(): ?int /** * Set delay in milliseconds. */ - public function setDeliveryDelay(int $deliveryDelay = null): void + public function setDeliveryDelay(?int $deliveryDelay = null): void { $this->setHeader('delivery_delay', $deliveryDelay); } - /** - * @return string - */ public function getReservedKey(): ?string { return $this->reservedKey; } - /** - * @param string $reservedKey - */ public function setReservedKey(string $reservedKey) { $this->reservedKey = $reservedKey; } - /** - * @return string - */ public function getKey(): ?string { return $this->key; } - /** - * @param string $key - */ public function setKey(string $key): void { $this->key = $key; diff --git a/pkg/redis/RedisProducer.php b/pkg/redis/RedisProducer.php index cc7d63230..3ad3e5bb2 100644 --- a/pkg/redis/RedisProducer.php +++ b/pkg/redis/RedisProducer.php @@ -29,9 +29,6 @@ class RedisProducer implements Producer */ private $deliveryDelay; - /** - * @param RedisContext $context - */ public function __construct(RedisContext $context) { $this->context = $context; @@ -74,7 +71,7 @@ public function send(Destination $destination, Message $message): void /** * @return self */ - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { $this->deliveryDelay = $deliveryDelay; @@ -89,7 +86,7 @@ public function getDeliveryDelay(): ?int /** * @return RedisProducer */ - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { if (null === $priority) { return $this; @@ -106,7 +103,7 @@ public function getPriority(): ?int /** * @return self */ - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { $this->timeToLive = $timeToLive; diff --git a/pkg/redis/RedisSubscriptionConsumer.php b/pkg/redis/RedisSubscriptionConsumer.php index c59cab4da..d0b34634d 100644 --- a/pkg/redis/RedisSubscriptionConsumer.php +++ b/pkg/redis/RedisSubscriptionConsumer.php @@ -28,26 +28,17 @@ class RedisSubscriptionConsumer implements SubscriptionConsumer */ private $redeliveryDelay = 300; - /** - * @param RedisContext $context - */ public function __construct(RedisContext $context) { $this->context = $context; $this->subscribers = []; } - /** - * @return int - */ public function getRedeliveryDelay(): ?int { return $this->redeliveryDelay; } - /** - * @param int $delay - */ public function setRedeliveryDelay(int $delay): void { $this->redeliveryDelay = $delay; @@ -89,7 +80,7 @@ public function consume(int $timeout = 0): void public function subscribe(Consumer $consumer, callable $callback): void { if (false == $consumer instanceof RedisConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, $consumer::class)); } $queueName = $consumer->getQueue()->getQueueName(); @@ -111,7 +102,7 @@ public function subscribe(Consumer $consumer, callable $callback): void public function unsubscribe(Consumer $consumer): void { if (false == $consumer instanceof RedisConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, $consumer::class)); } $queueName = $consumer->getQueue()->getQueueName(); diff --git a/pkg/redis/SerializerAwareTrait.php b/pkg/redis/SerializerAwareTrait.php index 8d0fbe548..bcd94eed5 100644 --- a/pkg/redis/SerializerAwareTrait.php +++ b/pkg/redis/SerializerAwareTrait.php @@ -11,9 +11,6 @@ trait SerializerAwareTrait */ private $serializer; - /** - * @param Serializer $serializer - */ public function setSerializer(Serializer $serializer) { $this->serializer = $serializer; diff --git a/pkg/redis/Tests/Functional/CommonUseCasesTrait.php b/pkg/redis/Tests/Functional/CommonUseCasesTrait.php index b80ea9763..bdab87b31 100644 --- a/pkg/redis/Tests/Functional/CommonUseCasesTrait.php +++ b/pkg/redis/Tests/Functional/CommonUseCasesTrait.php @@ -91,7 +91,7 @@ public function testConsumerReceiveMessageWithZeroTimeout() $consumer = $this->getContext()->createConsumer($topic); - //guard + // guard $this->assertNull($consumer->receive(1000)); $message = $this->getContext()->createMessage(__METHOD__); diff --git a/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php b/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php index 87d97c289..9ac2a037b 100644 --- a/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php @@ -32,9 +32,6 @@ protected function tearDown(): void $this->context->close(); } - /** - * {@inheritdoc} - */ protected function getContext() { return $this->context; diff --git a/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php b/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php index f68cf6129..e61cd1f0f 100644 --- a/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php @@ -32,9 +32,6 @@ protected function tearDown(): void $this->context->close(); } - /** - * {@inheritdoc} - */ protected function getContext() { return $this->context; diff --git a/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php b/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php index af9140704..f36843ec9 100644 --- a/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php @@ -32,9 +32,6 @@ protected function tearDown(): void $this->context->close(); } - /** - * {@inheritdoc} - */ protected function getContext() { return $this->context; diff --git a/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php b/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php index cd5023178..073c1aff9 100644 --- a/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php @@ -32,9 +32,6 @@ protected function tearDown(): void $this->context->close(); } - /** - * {@inheritdoc} - */ protected function getContext() { return $this->context; diff --git a/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php b/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php index 88c8a94b9..37e831823 100644 --- a/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php +++ b/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php @@ -53,9 +53,6 @@ public function testCouldBeCreatedWithRedisInstance() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/pkg/redis/Tests/Spec/JsonSerializerTest.php b/pkg/redis/Tests/Spec/JsonSerializerTest.php index 78a0aed86..a15859d35 100644 --- a/pkg/redis/Tests/Spec/JsonSerializerTest.php +++ b/pkg/redis/Tests/Spec/JsonSerializerTest.php @@ -37,7 +37,7 @@ public function testThrowIfFailedToEncodeMessageToJson() $resource = fopen(__FILE__, 'r'); - //guard + // guard $this->assertIsResource($resource); $message = new RedisMessage('theBody', ['aProp' => $resource]); diff --git a/pkg/redis/Tests/Spec/RedisConnectionFactoryTest.php b/pkg/redis/Tests/Spec/RedisConnectionFactoryTest.php index e086bccab..f15282f11 100644 --- a/pkg/redis/Tests/Spec/RedisConnectionFactoryTest.php +++ b/pkg/redis/Tests/Spec/RedisConnectionFactoryTest.php @@ -10,9 +10,6 @@ */ class RedisConnectionFactoryTest extends ConnectionFactorySpec { - /** - * {@inheritdoc} - */ protected function createConnectionFactory() { return new RedisConnectionFactory(); diff --git a/pkg/redis/Tests/Spec/RedisContextTest.php b/pkg/redis/Tests/Spec/RedisContextTest.php index 3377fb89b..4f48e24ae 100644 --- a/pkg/redis/Tests/Spec/RedisContextTest.php +++ b/pkg/redis/Tests/Spec/RedisContextTest.php @@ -13,9 +13,6 @@ class RedisContextTest extends ContextSpec { use RedisExtension; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildPhpRedisContext(); diff --git a/pkg/redis/Tests/Spec/RedisMessageTest.php b/pkg/redis/Tests/Spec/RedisMessageTest.php index bb8af845d..b0cc828e9 100644 --- a/pkg/redis/Tests/Spec/RedisMessageTest.php +++ b/pkg/redis/Tests/Spec/RedisMessageTest.php @@ -10,9 +10,6 @@ */ class RedisMessageTest extends MessageSpec { - /** - * {@inheritdoc} - */ protected function createMessage() { return new RedisMessage(); diff --git a/pkg/redis/Tests/Spec/RedisProducerTest.php b/pkg/redis/Tests/Spec/RedisProducerTest.php index fa9fbfefb..3434820e9 100644 --- a/pkg/redis/Tests/Spec/RedisProducerTest.php +++ b/pkg/redis/Tests/Spec/RedisProducerTest.php @@ -13,9 +13,6 @@ class RedisProducerTest extends ProducerSpec { use RedisExtension; - /** - * {@inheritdoc} - */ protected function createProducer() { return $this->buildPhpRedisContext()->createProducer(); diff --git a/pkg/redis/Tests/Spec/RedisQueueTest.php b/pkg/redis/Tests/Spec/RedisQueueTest.php index ab7b9937b..a8cd3b442 100644 --- a/pkg/redis/Tests/Spec/RedisQueueTest.php +++ b/pkg/redis/Tests/Spec/RedisQueueTest.php @@ -10,9 +10,6 @@ */ class RedisQueueTest extends QueueSpec { - /** - * {@inheritdoc} - */ protected function createQueue() { return new RedisDestination(self::EXPECTED_QUEUE_NAME); diff --git a/pkg/redis/Tests/Spec/RedisRequeueMessageTest.php b/pkg/redis/Tests/Spec/RedisRequeueMessageTest.php index c84bc84b5..69bd2c6ef 100644 --- a/pkg/redis/Tests/Spec/RedisRequeueMessageTest.php +++ b/pkg/redis/Tests/Spec/RedisRequeueMessageTest.php @@ -13,9 +13,6 @@ class RedisRequeueMessageTest extends RequeueMessageSpec { use RedisExtension; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildPhpRedisContext(); diff --git a/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromQueueTest.php b/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromQueueTest.php index 5535d949a..7bb61ab5d 100644 --- a/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromQueueTest.php +++ b/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromQueueTest.php @@ -13,9 +13,6 @@ class RedisSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec { use RedisExtension; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildPhpRedisContext(); diff --git a/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromTopicTest.php b/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromTopicTest.php index 2967ba977..37545f032 100644 --- a/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromTopicTest.php +++ b/pkg/redis/Tests/Spec/RedisSendToAndReceiveFromTopicTest.php @@ -13,9 +13,6 @@ class RedisSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec { use RedisExtension; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildPhpRedisContext(); diff --git a/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromQueueTest.php b/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromQueueTest.php index e03139f7e..01aea7ff1 100644 --- a/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromQueueTest.php +++ b/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromQueueTest.php @@ -13,9 +13,6 @@ class RedisSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFro { use RedisExtension; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildPhpRedisContext(); diff --git a/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromTopicTest.php b/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromTopicTest.php index fe103234b..2c8fbac7a 100644 --- a/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromTopicTest.php +++ b/pkg/redis/Tests/Spec/RedisSendToAndReceiveNoWaitFromTopicTest.php @@ -13,9 +13,6 @@ class RedisSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFro { use RedisExtension; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildPhpRedisContext(); diff --git a/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php b/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php index 16dbd8f98..78d33045f 100644 --- a/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php +++ b/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php @@ -18,8 +18,6 @@ class RedisSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subscr /** * @return RedisContext - * - * {@inheritdoc} */ protected function createContext() { @@ -28,8 +26,6 @@ protected function createContext() /** * @param RedisContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeUntilUnsubscribedTest.php b/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeUntilUnsubscribedTest.php index b227e3405..84872093b 100644 --- a/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeUntilUnsubscribedTest.php +++ b/pkg/redis/Tests/Spec/RedisSubscriptionConsumerConsumeUntilUnsubscribedTest.php @@ -18,8 +18,6 @@ class RedisSubscriptionConsumerConsumeUntilUnsubscribedTest extends Subscription /** * @return RedisContext - * - * {@inheritdoc} */ protected function createContext() { @@ -28,8 +26,6 @@ protected function createContext() /** * @param RedisContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/redis/Tests/Spec/RedisSubscriptionConsumerStopOnFalseTest.php b/pkg/redis/Tests/Spec/RedisSubscriptionConsumerStopOnFalseTest.php index 5a033a872..490d58eab 100644 --- a/pkg/redis/Tests/Spec/RedisSubscriptionConsumerStopOnFalseTest.php +++ b/pkg/redis/Tests/Spec/RedisSubscriptionConsumerStopOnFalseTest.php @@ -18,8 +18,6 @@ class RedisSubscriptionConsumerStopOnFalseTest extends SubscriptionConsumerStopO /** * @return RedisContext - * - * {@inheritdoc} */ protected function createContext() { @@ -28,8 +26,6 @@ protected function createContext() /** * @param RedisContext $context - * - * {@inheritdoc} */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/redis/Tests/Spec/RedisTopicTest.php b/pkg/redis/Tests/Spec/RedisTopicTest.php index 52001aa66..da94ffa1b 100644 --- a/pkg/redis/Tests/Spec/RedisTopicTest.php +++ b/pkg/redis/Tests/Spec/RedisTopicTest.php @@ -10,9 +10,6 @@ */ class RedisTopicTest extends TopicSpec { - /** - * {@inheritdoc} - */ protected function createTopic() { return new RedisDestination(self::EXPECTED_TOPIC_NAME); diff --git a/pkg/simple-client/SimpleClient.php b/pkg/simple-client/SimpleClient.php index 9158364b9..bbfd8b91b 100644 --- a/pkg/simple-client/SimpleClient.php +++ b/pkg/simple-client/SimpleClient.php @@ -114,10 +114,9 @@ final class SimpleClient * ] * ] * - * * @param string|array $config */ - public function __construct($config, LoggerInterface $logger = null) + public function __construct($config, ?LoggerInterface $logger = null) { if (is_string($config)) { $config = [ @@ -134,7 +133,7 @@ public function __construct($config, LoggerInterface $logger = null) /** * @param callable|Processor $processor */ - public function bindTopic(string $topic, $processor, string $processorName = null): void + public function bindTopic(string $topic, $processor, ?string $processorName = null): void { if (is_callable($processor)) { $processor = new CallbackProcessor($processor); @@ -144,7 +143,7 @@ public function bindTopic(string $topic, $processor, string $processorName = nul throw new \LogicException('The processor must be either callable or instance of Processor'); } - $processorName = $processorName ?: uniqid(get_class($processor)); + $processorName = $processorName ?: uniqid($processor::class); $this->driver->getRouteCollection()->add(new Route($topic, Route::TOPIC, $processorName)); $this->processorRegistry->add($processorName, $processor); @@ -153,7 +152,7 @@ public function bindTopic(string $topic, $processor, string $processorName = nul /** * @param callable|Processor $processor */ - public function bindCommand(string $command, $processor, string $processorName = null): void + public function bindCommand(string $command, $processor, ?string $processorName = null): void { if (is_callable($processor)) { $processor = new CallbackProcessor($processor); @@ -163,7 +162,7 @@ public function bindCommand(string $command, $processor, string $processorName = throw new \LogicException('The processor must be either callable or instance of Processor'); } - $processorName = $processorName ?: uniqid(get_class($processor)); + $processorName = $processorName ?: uniqid($processor::class); $this->driver->getRouteCollection()->add(new Route($command, Route::COMMAND, $processorName)); $this->processorRegistry->add($processorName, $processor); @@ -185,7 +184,7 @@ public function sendEvent(string $topic, $message): void $this->producer->sendEvent($topic, $message); } - public function consume(ExtensionInterface $runtimeExtension = null): void + public function consume(?ExtensionInterface $runtimeExtension = null): void { $this->setupBroker(); diff --git a/pkg/simple-client/Tests/Functional/SimpleClientTest.php b/pkg/simple-client/Tests/Functional/SimpleClientTest.php index 13320fb67..ce75457af 100644 --- a/pkg/simple-client/Tests/Functional/SimpleClientTest.php +++ b/pkg/simple-client/Tests/Functional/SimpleClientTest.php @@ -85,8 +85,6 @@ public function testShouldWorkWithStringDsnConstructorArgument() /** * @dataProvider transportConfigDataProvider - * - * @param mixed $config */ public function testSendEventWithOneSubscriber($config, string $timeLimit) { @@ -125,8 +123,6 @@ public function testSendEventWithOneSubscriber($config, string $timeLimit) /** * @dataProvider transportConfigDataProvider - * - * @param mixed $config */ public function testSendEventWithTwoSubscriber($config, string $timeLimit) { @@ -168,8 +164,6 @@ public function testSendEventWithTwoSubscriber($config, string $timeLimit) /** * @dataProvider transportConfigDataProvider - * - * @param mixed $config */ public function testSendCommand($config, string $timeLimit) { diff --git a/pkg/simple-client/Tests/fix_composer_json.php b/pkg/simple-client/Tests/fix_composer_json.php index f025f6081..01f73c95e 100644 --- a/pkg/simple-client/Tests/fix_composer_json.php +++ b/pkg/simple-client/Tests/fix_composer_json.php @@ -6,4 +6,4 @@ $composerJson['config']['platform']['ext-amqp'] = '1.9.3'; -file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, JSON_PRETTY_PRINT)); +file_put_contents(__DIR__.'/../composer.json', json_encode($composerJson, \JSON_PRETTY_PRINT)); diff --git a/pkg/sns/SnsClient.php b/pkg/sns/SnsClient.php index 91bce56eb..7c4a81693 100644 --- a/pkg/sns/SnsClient.php +++ b/pkg/sns/SnsClient.php @@ -140,6 +140,6 @@ private function resolveClient(): void } } - throw new \LogicException(sprintf('The input client must be an instance of "%s" or "%s" or a callable that returns one of those. Got "%s"', AwsSnsClient::class, MultiRegionClient::class, is_object($client) ? get_class($client) : gettype($client))); + throw new \LogicException(sprintf('The input client must be an instance of "%s" or "%s" or a callable that returns one of those. Got "%s"', AwsSnsClient::class, MultiRegionClient::class, is_object($client) ? $client::class : gettype($client))); } } diff --git a/pkg/sns/SnsDestination.php b/pkg/sns/SnsDestination.php index 5823fd91e..adcb08f43 100644 --- a/pkg/sns/SnsDestination.php +++ b/pkg/sns/SnsDestination.php @@ -34,7 +34,7 @@ public function getTopicName(): string /** * The policy that defines who can access your topic. By default, only the topic owner can publish or subscribe to the topic. */ - public function setPolicy(string $policy = null): void + public function setPolicy(?string $policy = null): void { $this->setAttribute('Policy', $policy); } @@ -47,7 +47,7 @@ public function getPolicy(): ?string /** * The display name to use for a topic with SMS subscriptions. */ - public function setDisplayName(string $displayName = null): void + public function setDisplayName(?string $displayName = null): void { $this->setAttribute('DisplayName', $displayName); } @@ -60,7 +60,7 @@ public function getDisplayName(): ?string /** * The display name to use for a topic with SMS subscriptions. */ - public function setDeliveryPolicy(int $deliveryPolicy = null): void + public function setDeliveryPolicy(?int $deliveryPolicy = null): void { $this->setAttribute('DeliveryPolicy', $deliveryPolicy); } diff --git a/pkg/sns/SnsMessage.php b/pkg/sns/SnsMessage.php index 43c85e553..4122209e8 100644 --- a/pkg/sns/SnsMessage.php +++ b/pkg/sns/SnsMessage.php @@ -63,11 +63,11 @@ public function __construct( string $body = '', array $properties = [], array $headers = [], - array $messageAttributes = null, - string $messageStructure = null, - string $phoneNumber = null, - string $subject = null, - string $targetArn = null + ?array $messageAttributes = null, + ?string $messageStructure = null, + ?string $phoneNumber = null, + ?string $subject = null, + ?string $targetArn = null, ) { $this->body = $body; $this->properties = $properties; @@ -192,7 +192,7 @@ public function setTargetArn(?string $targetArn): void * of each user is processed in a FIFO fashion. * For more information, see: https://docs.aws.amazon.com/sns/latest/dg/fifo-message-grouping.html */ - public function setMessageGroupId(string $id = null): void + public function setMessageGroupId(?string $id = null): void { $this->messageGroupId = $id; } @@ -210,7 +210,7 @@ public function getMessageGroupId(): ?string * aren't delivered during the 5-minute deduplication interval. * For more information, see https://docs.aws.amazon.com/sns/latest/dg/fifo-message-dedup.html */ - public function setMessageDeduplicationId(string $id = null): void + public function setMessageDeduplicationId(?string $id = null): void { $this->messageDeduplicationId = $id; } diff --git a/pkg/sns/SnsProducer.php b/pkg/sns/SnsProducer.php index bbd46a96f..ac7e38b5b 100644 --- a/pkg/sns/SnsProducer.php +++ b/pkg/sns/SnsProducer.php @@ -99,7 +99,7 @@ public function send(Destination $destination, Message $message): void * * @return SnsProducer */ - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { if (null === $deliveryDelay) { return $this; @@ -118,7 +118,7 @@ public function getDeliveryDelay(): ?int * * @return SnsProducer */ - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { if (null === $priority) { return $this; @@ -137,7 +137,7 @@ public function getPriority(): ?int * * @return SnsProducer */ - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { if (null === $timeToLive) { return $this; diff --git a/pkg/sns/SnsSubscribe.php b/pkg/sns/SnsSubscribe.php index 70addb7e0..52991d81f 100644 --- a/pkg/sns/SnsSubscribe.php +++ b/pkg/sns/SnsSubscribe.php @@ -6,7 +6,7 @@ class SnsSubscribe { - const PROTOCOL_SQS = 'sqs'; + public const PROTOCOL_SQS = 'sqs'; /** * @var SnsDestination @@ -23,14 +23,8 @@ class SnsSubscribe */ private $protocol; - /** - * @var - */ private $returnSubscriptionArn; - /** - * @var - */ private $attributes; public function __construct( @@ -38,7 +32,7 @@ public function __construct( string $endpoint, string $protocol, bool $returnSubscriptionArn = false, - array $attributes = [] + array $attributes = [], ) { $this->topic = $topic; $this->endpoint = $endpoint; diff --git a/pkg/sns/SnsUnsubscribe.php b/pkg/sns/SnsUnsubscribe.php index cd5733651..ad6b93d45 100644 --- a/pkg/sns/SnsUnsubscribe.php +++ b/pkg/sns/SnsUnsubscribe.php @@ -24,7 +24,7 @@ class SnsUnsubscribe public function __construct( SnsDestination $topic, string $endpoint, - string $protocol + string $protocol, ) { $this->topic = $topic; $this->endpoint = $endpoint; diff --git a/pkg/sns/Tests/SnsConnectionFactoryConfigTest.php b/pkg/sns/Tests/SnsConnectionFactoryConfigTest.php index de32d4265..305a6518d 100644 --- a/pkg/sns/Tests/SnsConnectionFactoryConfigTest.php +++ b/pkg/sns/Tests/SnsConnectionFactoryConfigTest.php @@ -41,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/pkg/sns/examples/consume.php b/pkg/sns/examples/consume.php index 7976e7501..6698cd21e 100644 --- a/pkg/sns/examples/consume.php +++ b/pkg/sns/examples/consume.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\Sns\SnsConnectionFactory; @@ -26,7 +26,7 @@ while (true) { if ($m = $consumer->receive(20000)) { $consumer->acknowledge($m); - echo 'Received message: '.$m->getBody().PHP_EOL; + echo 'Received message: '.$m->getBody().\PHP_EOL; } } diff --git a/pkg/sns/examples/produce.php b/pkg/sns/examples/produce.php index d37fce79f..3e59c5232 100644 --- a/pkg/sns/examples/produce.php +++ b/pkg/sns/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\Sns\SnsConnectionFactory; diff --git a/pkg/snsqs/SnsQsConnectionFactory.php b/pkg/snsqs/SnsQsConnectionFactory.php index abb154a9b..65812beb3 100644 --- a/pkg/snsqs/SnsQsConnectionFactory.php +++ b/pkg/snsqs/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/pkg/snsqs/SnsQsConsumer.php b/pkg/snsqs/SnsQsConsumer.php index 17ec39ae0..45237d145 100644 --- a/pkg/snsqs/SnsQsConsumer.php +++ b/pkg/snsqs/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/pkg/snsqs/SnsQsContext.php b/pkg/snsqs/SnsQsContext.php index 4a7121681..d26a0fc6d 100644 --- a/pkg/snsqs/SnsQsContext.php +++ b/pkg/snsqs/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/pkg/snsqs/SnsQsMessage.php b/pkg/snsqs/SnsQsMessage.php index c804b1860..900ad9125 100644 --- a/pkg/snsqs/SnsQsMessage.php +++ b/pkg/snsqs/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/pkg/snsqs/SnsQsProducer.php b/pkg/snsqs/SnsQsProducer.php index 6bc66e8f8..a80e1eb2b 100644 --- a/pkg/snsqs/SnsQsProducer.php +++ b/pkg/snsqs/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/pkg/snsqs/Tests/Spec/SnsQsFactoryTrait.php b/pkg/snsqs/Tests/Spec/SnsQsFactoryTrait.php index efc4a7046..e314c2667 100644 --- a/pkg/snsqs/Tests/Spec/SnsQsFactoryTrait.php +++ b/pkg/snsqs/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/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveFromQueueTest.php b/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveFromQueueTest.php index ed199180d..707cab529 100644 --- a/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveFromQueueTest.php +++ b/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveFromQueueTest.php @@ -8,6 +8,7 @@ /** * @group functional + * * @retry 5 */ class SnsQsSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec diff --git a/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveNoWaitFromQueueTest.php b/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveNoWaitFromQueueTest.php index 53ae719b2..652766de4 100644 --- a/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveNoWaitFromQueueTest.php +++ b/pkg/snsqs/Tests/Spec/SnsQsSendToAndReceiveNoWaitFromQueueTest.php @@ -8,6 +8,7 @@ /** * @group functional + * * @retry 5 */ class SnsQsSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec diff --git a/pkg/snsqs/Tests/Spec/SnsQsSendToTopicAndReceiveFromQueueSpec.php b/pkg/snsqs/Tests/Spec/SnsQsSendToTopicAndReceiveFromQueueSpec.php index 24206c9d8..4a5869d63 100644 --- a/pkg/snsqs/Tests/Spec/SnsQsSendToTopicAndReceiveFromQueueSpec.php +++ b/pkg/snsqs/Tests/Spec/SnsQsSendToTopicAndReceiveFromQueueSpec.php @@ -8,6 +8,7 @@ /** * @group functional + * * @retry 5 */ class SnsQsSendToTopicAndReceiveFromQueueSpec extends SendToTopicAndReceiveFromQueueSpec diff --git a/pkg/snsqs/examples/consumer.php b/pkg/snsqs/examples/consumer.php index a5303b9ea..37f193925 100644 --- a/pkg/snsqs/examples/consumer.php +++ b/pkg/snsqs/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/pkg/snsqs/examples/produce.php b/pkg/snsqs/examples/produce.php index 0396d9cd0..53018d769 100644 --- a/pkg/snsqs/examples/produce.php +++ b/pkg/snsqs/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); } diff --git a/pkg/sqs/SqsClient.php b/pkg/sqs/SqsClient.php index 0d61584bf..bba2a5760 100644 --- a/pkg/sqs/SqsClient.php +++ b/pkg/sqs/SqsClient.php @@ -148,11 +148,6 @@ private function resolveClient(): void } } - throw new \LogicException(sprintf( - 'The input client must be an instance of "%s" or "%s" or a callable that returns one of those. Got "%s"', - AwsSqsClient::class, - MultiRegionClient::class, - is_object($client) ? get_class($client) : gettype($client) - )); + throw new \LogicException(sprintf('The input client must be an instance of "%s" or "%s" or a callable that returns one of those. Got "%s"', AwsSqsClient::class, MultiRegionClient::class, is_object($client) ? $client::class : gettype($client))); } } diff --git a/pkg/sqs/SqsConsumer.php b/pkg/sqs/SqsConsumer.php index 04d5bbd81..860bc648b 100644 --- a/pkg/sqs/SqsConsumer.php +++ b/pkg/sqs/SqsConsumer.php @@ -53,7 +53,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->visibilityTimeout = $visibilityTimeout; } diff --git a/pkg/sqs/SqsContext.php b/pkg/sqs/SqsContext.php index 60906f72f..65f12ae89 100644 --- a/pkg/sqs/SqsContext.php +++ b/pkg/sqs/SqsContext.php @@ -134,7 +134,7 @@ public function getSqsClient(): SqsClient */ public function getClient(): AwsSqsClient { - @trigger_error('The method is deprecated since 0.9.2. SqsContext::getAwsSqsClient() method should be used.', E_USER_DEPRECATED); + @trigger_error('The method is deprecated since 0.9.2. SqsContext::getAwsSqsClient() method should be used.', \E_USER_DEPRECATED); return $this->getAwsSqsClient(); } diff --git a/pkg/sqs/SqsDestination.php b/pkg/sqs/SqsDestination.php index 5649d30a3..d77966f15 100644 --- a/pkg/sqs/SqsDestination.php +++ b/pkg/sqs/SqsDestination.php @@ -62,7 +62,7 @@ public function getAttributes(): array * The number of seconds for which the delivery of all messages in the queue is delayed. * Valid values: An integer from 0 to 900 seconds (15 minutes). The default is 0 (zero). */ - public function setDelaySeconds(int $seconds = null): void + public function setDelaySeconds(?int $seconds = null): void { if (null == $seconds) { unset($this->attributes['DelaySeconds']); @@ -76,7 +76,7 @@ public function setDelaySeconds(int $seconds = null): void * Valid values: An integer from 1,024 bytes (1 KiB) to 262,144 bytes (256 KiB). * The default is 262,144 (256 KiB). */ - public function setMaximumMessageSize(int $bytes = null): void + public function setMaximumMessageSize(?int $bytes = null): void { if (null == $bytes) { unset($this->attributes['MaximumMessageSize']); @@ -90,7 +90,7 @@ public function setMaximumMessageSize(int $bytes = null): void * Valid values: An integer from 60 seconds (1 minute) to 1,209,600 seconds (14 days). * The default is 345,600 (4 days). */ - public function setMessageRetentionPeriod(int $seconds = null): void + public function setMessageRetentionPeriod(?int $seconds = null): void { if (null == $seconds) { unset($this->attributes['MessageRetentionPeriod']); @@ -103,7 +103,7 @@ public function setMessageRetentionPeriod(int $seconds = null): void * The queue's policy. A valid AWS policy. For more information about policy structure, * see http://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html. */ - public function setPolicy(string $policy = null): void + public function setPolicy(?string $policy = null): void { if (null == $policy) { unset($this->attributes['Policy']); @@ -116,7 +116,7 @@ public function setPolicy(string $policy = null): void * The number of seconds for which a ReceiveMessage action waits for a message to arrive. * Valid values: An integer from 0 to 20 (seconds). The default is 0 (zero). */ - public function setReceiveMessageWaitTimeSeconds(int $seconds = null): void + public function setReceiveMessageWaitTimeSeconds(?int $seconds = null): void { if (null == $seconds) { unset($this->attributes['ReceiveMessageWaitTimeSeconds']); @@ -145,7 +145,7 @@ public function setRedrivePolicy(int $maxReceiveCount, string $deadLetterTargetA * The default is 30. For more information about the visibility timeout, * see http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html. */ - public function setVisibilityTimeout(int $seconds = null): void + public function setVisibilityTimeout(?int $seconds = null): void { if (null == $seconds) { unset($this->attributes['VisibilityTimeout']); @@ -208,7 +208,7 @@ public function setQueueOwnerAWSAccountId(?string $queueOwnerAWSAccountId): void $this->queueOwnerAWSAccountId = $queueOwnerAWSAccountId; } - public function setRegion(string $region = null): void + public function setRegion(?string $region = null): void { $this->region = $region; } diff --git a/pkg/sqs/SqsMessage.php b/pkg/sqs/SqsMessage.php index cd2b1bdfe..772c3e217 100644 --- a/pkg/sqs/SqsMessage.php +++ b/pkg/sqs/SqsMessage.php @@ -144,7 +144,7 @@ public function setRedelivered(bool $redelivered): void $this->redelivered = $redelivered; } - public function setReplyTo(string $replyTo = null): void + public function setReplyTo(?string $replyTo = null): void { $this->setHeader('reply_to', $replyTo); } @@ -154,7 +154,7 @@ public function getReplyTo(): ?string return $this->getHeader('reply_to'); } - public function setCorrelationId(string $correlationId = null): void + public function setCorrelationId(?string $correlationId = null): void { $this->setHeader('correlation_id', $correlationId); } @@ -164,7 +164,7 @@ public function getCorrelationId(): ?string return $this->getHeader('correlation_id'); } - public function setMessageId(string $messageId = null): void + public function setMessageId(?string $messageId = null): void { $this->setHeader('message_id', $messageId); } @@ -181,7 +181,7 @@ public function getTimestamp(): ?int return null === $value ? null : (int) $value; } - public function setTimestamp(int $timestamp = null): void + public function setTimestamp(?int $timestamp = null): void { $this->setHeader('timestamp', $timestamp); } @@ -211,7 +211,7 @@ public function getDelaySeconds(): int * 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; } @@ -230,7 +230,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; } @@ -247,7 +247,7 @@ public function getMessageGroupId(): ?string * If you receive a message more than once, each time you receive it, you get a different receipt handle. * You must provide the most recently received receipt handle when you request to delete the message (otherwise, the message might not be deleted). */ - public function setReceiptHandle(string $receipt = null): void + public function setReceiptHandle(?string $receipt = null): void { $this->receiptHandle = $receipt; } diff --git a/pkg/sqs/SqsProducer.php b/pkg/sqs/SqsProducer.php index 98c133acc..2e43d8370 100644 --- a/pkg/sqs/SqsProducer.php +++ b/pkg/sqs/SqsProducer.php @@ -81,7 +81,7 @@ public function send(Destination $destination, Message $message): void /** * @return SqsProducer */ - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { $this->deliveryDelay = $deliveryDelay; @@ -96,7 +96,7 @@ public function getDeliveryDelay(): ?int /** * @return SqsProducer */ - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { if (null === $priority) { return $this; @@ -113,7 +113,7 @@ public function getPriority(): ?int /** * @return SqsProducer */ - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { if (null === $timeToLive) { return $this; diff --git a/pkg/sqs/Tests/Spec/CreateSqsQueueTrait.php b/pkg/sqs/Tests/Spec/CreateSqsQueueTrait.php index 79af8208e..3af2a5129 100644 --- a/pkg/sqs/Tests/Spec/CreateSqsQueueTrait.php +++ b/pkg/sqs/Tests/Spec/CreateSqsQueueTrait.php @@ -11,7 +11,7 @@ trait CreateSqsQueueTrait protected function createSqsQueue(SqsContext $context, string $queueName): SqsDestination { - $queueName = $queueName.time(); + $queueName .= time(); $this->queue = $context->createQueue($queueName); $context->declareQueue($this->queue); diff --git a/pkg/sqs/Tests/Spec/SqsMessageTest.php b/pkg/sqs/Tests/Spec/SqsMessageTest.php index 9007df099..994fe5be5 100644 --- a/pkg/sqs/Tests/Spec/SqsMessageTest.php +++ b/pkg/sqs/Tests/Spec/SqsMessageTest.php @@ -7,9 +7,6 @@ class SqsMessageTest extends MessageSpec { - /** - * {@inheritdoc} - */ protected function createMessage() { return new SqsMessage(); diff --git a/pkg/sqs/Tests/Spec/SqsProducerTest.php b/pkg/sqs/Tests/Spec/SqsProducerTest.php index c241a2165..f0e5c8b06 100644 --- a/pkg/sqs/Tests/Spec/SqsProducerTest.php +++ b/pkg/sqs/Tests/Spec/SqsProducerTest.php @@ -12,9 +12,6 @@ class SqsProducerTest extends ProducerSpec { use SqsExtension; - /** - * {@inheritdoc} - */ protected function createProducer() { return $this->buildSqsContext()->createProducer(); diff --git a/pkg/sqs/Tests/Spec/SqsSendAndReceiveDelayedMessageFromQueueTest.php b/pkg/sqs/Tests/Spec/SqsSendAndReceiveDelayedMessageFromQueueTest.php index 357ed93eb..40f20d68f 100644 --- a/pkg/sqs/Tests/Spec/SqsSendAndReceiveDelayedMessageFromQueueTest.php +++ b/pkg/sqs/Tests/Spec/SqsSendAndReceiveDelayedMessageFromQueueTest.php @@ -11,13 +11,14 @@ /** * @group functional + * * @retry 5 */ class SqsSendAndReceiveDelayedMessageFromQueueTest extends SendAndReceiveDelayedMessageFromQueueSpec { + use CreateSqsQueueTrait; use RetryTrait; use SqsExtension; - use CreateSqsQueueTrait; /** * @var SqsContext diff --git a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromQueueTest.php b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromQueueTest.php index 802d887ac..db698017d 100644 --- a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromQueueTest.php +++ b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromQueueTest.php @@ -11,13 +11,14 @@ /** * @group functional + * * @retry 5 */ class SqsSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec { + use CreateSqsQueueTrait; use RetryTrait; use SqsExtension; - use CreateSqsQueueTrait; /** * @var SqsContext diff --git a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php index ac57818aa..5cd14468a 100644 --- a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php +++ b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveFromTopicTest.php @@ -11,13 +11,14 @@ /** * @group functional + * * @retry 5 */ class SqsSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec { - use SqsExtension; - use RetryTrait; use CreateSqsQueueTrait; + use RetryTrait; + use SqsExtension; /** * @var SqsContext diff --git a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromQueueTest.php b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromQueueTest.php index 3f03006d9..7e31a25a4 100644 --- a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromQueueTest.php +++ b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromQueueTest.php @@ -11,13 +11,14 @@ /** * @group functional + * * @retry 5 */ class SqsSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitFromQueueSpec { + use CreateSqsQueueTrait; use RetryTrait; use SqsExtension; - use CreateSqsQueueTrait; /** * @var SqsContext diff --git a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromTopicTest.php b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromTopicTest.php index 12a3c0c6e..34f2e75dd 100644 --- a/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromTopicTest.php +++ b/pkg/sqs/Tests/Spec/SqsSendToAndReceiveNoWaitFromTopicTest.php @@ -11,13 +11,14 @@ /** * @group functional + * * @retry 5 */ class SqsSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitFromTopicSpec { + use CreateSqsQueueTrait; use RetryTrait; use SqsExtension; - use CreateSqsQueueTrait; /** * @var SqsContext diff --git a/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveFromQueueTest.php b/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveFromQueueTest.php index 519db1be5..b8e60aee9 100644 --- a/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveFromQueueTest.php +++ b/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveFromQueueTest.php @@ -11,13 +11,14 @@ /** * @group functional + * * @retry 5 */ class SqsSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceiveFromQueueSpec { + use CreateSqsQueueTrait; use RetryTrait; use SqsExtension; - use CreateSqsQueueTrait; /** * @var SqsContext diff --git a/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveNoWaitFromQueueTest.php index 317d7297c..e5520e01f 100644 --- a/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveNoWaitFromQueueTest.php +++ b/pkg/sqs/Tests/Spec/SqsSendToTopicAndReceiveNoWaitFromQueueTest.php @@ -11,13 +11,14 @@ /** * @group functional + * * @retry 5 */ class SqsSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndReceiveNoWaitFromQueueSpec { + use CreateSqsQueueTrait; use RetryTrait; use SqsExtension; - use CreateSqsQueueTrait; /** * @var SqsContext diff --git a/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php b/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php index 6fa9298be..c7a954b0f 100644 --- a/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php +++ b/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php @@ -41,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/pkg/sqs/examples/consume.php b/pkg/sqs/examples/consume.php index 9c5eaa12f..d82274d80 100644 --- a/pkg/sqs/examples/consume.php +++ b/pkg/sqs/examples/consume.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\Sqs\SqsConnectionFactory; @@ -26,7 +26,7 @@ while (true) { if ($m = $consumer->receive(20000)) { $consumer->acknowledge($m); - echo 'Received message: '.$m->getBody().PHP_EOL; + echo 'Received message: '.$m->getBody().\PHP_EOL; } } diff --git a/pkg/sqs/examples/produce.php b/pkg/sqs/examples/produce.php index ba35c84c1..a9ba3e3b7 100644 --- a/pkg/sqs/examples/produce.php +++ b/pkg/sqs/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\Sqs\SqsConnectionFactory; @@ -27,7 +27,7 @@ while (true) { $context->createProducer()->send($queue, $message); - echo 'Sent message: '.$message->getBody().PHP_EOL; + echo 'Sent message: '.$message->getBody().\PHP_EOL; sleep(1); } diff --git a/pkg/stomp/BufferedStompClient.php b/pkg/stomp/BufferedStompClient.php index 5feb88fae..e2c54d731 100644 --- a/pkg/stomp/BufferedStompClient.php +++ b/pkg/stomp/BufferedStompClient.php @@ -103,9 +103,6 @@ public function readMessageFrame(string $subscriptionId, int $timeout): ?Frame } } - /** - * {@inheritdoc} - */ public function disconnect($sync = false) { parent::disconnect($sync); diff --git a/pkg/stomp/ExtensionType.php b/pkg/stomp/ExtensionType.php index 37c248feb..c1c265f68 100644 --- a/pkg/stomp/ExtensionType.php +++ b/pkg/stomp/ExtensionType.php @@ -6,7 +6,7 @@ class ExtensionType { - const ACTIVEMQ = 'activemq'; - const RABBITMQ = 'rabbitmq'; - const ARTEMIS = 'artemis'; + public const ACTIVEMQ = 'activemq'; + public const RABBITMQ = 'rabbitmq'; + public const ARTEMIS = 'artemis'; } diff --git a/pkg/stomp/StompConnectionFactory.php b/pkg/stomp/StompConnectionFactory.php index 9110911bc..da9c6f9bd 100644 --- a/pkg/stomp/StompConnectionFactory.php +++ b/pkg/stomp/StompConnectionFactory.php @@ -13,7 +13,7 @@ class StompConnectionFactory implements ConnectionFactory { - const SUPPORTED_SCHEMES = [ + public const SUPPORTED_SCHEMES = [ ExtensionType::ACTIVEMQ, ExtensionType::RABBITMQ, ExtensionType::ARTEMIS, @@ -120,7 +120,7 @@ private function parseDsn(string $dsn): array $dsn = Dsn::parseFirst($dsn); if ('stomp' !== $dsn->getSchemeProtocol()) { - throw new \LogicException(sprintf('The given DSN is not supported. Must start with "stomp:".')); + throw new \LogicException('The given DSN is not supported. Must start with "stomp:".'); } $schemeExtension = current($dsn->getSchemeExtensions()); diff --git a/pkg/stomp/StompConsumer.php b/pkg/stomp/StompConsumer.php index e1fe80f7d..5a80be890 100644 --- a/pkg/stomp/StompConsumer.php +++ b/pkg/stomp/StompConsumer.php @@ -15,9 +15,9 @@ class StompConsumer implements Consumer { - const ACK_AUTO = 'auto'; - const ACK_CLIENT = 'client'; - const ACK_CLIENT_INDIVIDUAL = 'client-individual'; + public const ACK_AUTO = 'auto'; + public const ACK_CLIENT = 'client'; + public const ACK_CLIENT_INDIVIDUAL = 'client-individual'; /** * @var StompDestination diff --git a/pkg/stomp/StompContext.php b/pkg/stomp/StompContext.php index c71277e65..1e77f88ee 100644 --- a/pkg/stomp/StompContext.php +++ b/pkg/stomp/StompContext.php @@ -74,7 +74,7 @@ public function createMessage(string $body = '', array $properties = [], array $ */ public function createQueue(string $name): Queue { - if (0 !== strpos($name, '/')) { + if (!str_starts_with($name, '/')) { $destination = new StompDestination($this->extensionType); $destination->setType(StompDestination::TYPE_QUEUE); $destination->setStompName($name); @@ -101,7 +101,7 @@ public function createTemporaryQueue(): Queue */ public function createTopic(string $name): Topic { - if (0 !== strpos($name, '/')) { + if (!str_starts_with($name, '/')) { $destination = new StompDestination($this->extensionType); $destination->setType($this->useExchangePrefix ? StompDestination::TYPE_EXCHANGE : StompDestination::TYPE_TOPIC); $destination->setStompName($name); @@ -130,7 +130,7 @@ public function createDestination(string $destination): StompDestination foreach ($types as $_type) { $typePrefix = '/'.$_type.'/'; - if (0 === strpos($dest, $typePrefix)) { + if (str_starts_with($dest, $typePrefix)) { $type = $_type; $dest = substr($dest, strlen($typePrefix)); @@ -225,7 +225,7 @@ private function createStomp(): BufferedStompClient $stomp = call_user_func($this->stompFactory); if (false == $stomp instanceof BufferedStompClient) { - throw new \LogicException(sprintf('The factory must return instance of BufferedStompClient. It returns %s', is_object($stomp) ? get_class($stomp) : gettype($stomp))); + throw new \LogicException(sprintf('The factory must return instance of BufferedStompClient. It returns %s', is_object($stomp) ? $stomp::class : gettype($stomp))); } return $stomp; diff --git a/pkg/stomp/StompDestination.php b/pkg/stomp/StompDestination.php index 30e858e1d..3364968c4 100644 --- a/pkg/stomp/StompDestination.php +++ b/pkg/stomp/StompDestination.php @@ -9,16 +9,16 @@ class StompDestination implements Topic, Queue { - const TYPE_TOPIC = 'topic'; - const TYPE_EXCHANGE = 'exchange'; - const TYPE_QUEUE = 'queue'; - const TYPE_AMQ_QUEUE = 'amq/queue'; - const TYPE_TEMP_QUEUE = 'temp-queue'; - const TYPE_REPLY_QUEUE = 'reply-queue'; + public const TYPE_TOPIC = 'topic'; + public const TYPE_EXCHANGE = 'exchange'; + public const TYPE_QUEUE = 'queue'; + public const TYPE_AMQ_QUEUE = 'amq/queue'; + public const TYPE_TEMP_QUEUE = 'temp-queue'; + public const TYPE_REPLY_QUEUE = 'reply-queue'; - const HEADER_DURABLE = 'durable'; - const HEADER_AUTO_DELETE = 'auto-delete'; - const HEADER_EXCLUSIVE = 'exclusive'; + public const HEADER_DURABLE = 'durable'; + public const HEADER_AUTO_DELETE = 'auto-delete'; + public const HEADER_EXCLUSIVE = 'exclusive'; /** * @var string @@ -122,7 +122,7 @@ public function getRoutingKey(): ?string return $this->routingKey; } - public function setRoutingKey(string $routingKey = null): void + public function setRoutingKey(?string $routingKey = null): void { $this->routingKey = $routingKey; } diff --git a/pkg/stomp/StompHeadersEncoder.php b/pkg/stomp/StompHeadersEncoder.php index 27e637cc3..e3484abf6 100644 --- a/pkg/stomp/StompHeadersEncoder.php +++ b/pkg/stomp/StompHeadersEncoder.php @@ -6,13 +6,13 @@ class StompHeadersEncoder { - const PROPERTY_PREFIX = '_property_'; - const TYPE_PREFIX = '_type_'; - const TYPE_STRING = 's'; - const TYPE_INT = 'i'; - const TYPE_FLOAT = 'f'; - const TYPE_BOOL = 'b'; - const TYPE_NULL = 'n'; + public const PROPERTY_PREFIX = '_property_'; + public const TYPE_PREFIX = '_type_'; + public const TYPE_STRING = 's'; + public const TYPE_INT = 'i'; + public const TYPE_FLOAT = 'f'; + public const TYPE_BOOL = 'b'; + public const TYPE_NULL = 'n'; public static function encode(array $headers = [], array $properties = []): array { @@ -36,7 +36,7 @@ public static function decode(array $headers = []): array // separate headers/properties foreach ($headers as $key => $value) { - if (0 === strpos($key, self::PROPERTY_PREFIX)) { + if (str_starts_with($key, self::PROPERTY_PREFIX)) { $encodedProperties[substr($key, $prefixLength)] = $value; } else { $encodedHeaders[$key] = $value; @@ -94,7 +94,7 @@ private static function doDecode(array $headers = []): array foreach ($headers as $key => $value) { // skip type header - if (0 === strpos($key, self::TYPE_PREFIX)) { + if (str_starts_with($key, self::TYPE_PREFIX)) { continue; } diff --git a/pkg/stomp/StompMessage.php b/pkg/stomp/StompMessage.php index bb563c8cd..7098679b7 100644 --- a/pkg/stomp/StompMessage.php +++ b/pkg/stomp/StompMessage.php @@ -120,7 +120,7 @@ public function setRedelivered(bool $redelivered): void $this->redelivered = $redelivered; } - public function setCorrelationId(string $correlationId = null): void + public function setCorrelationId(?string $correlationId = null): void { $this->setHeader('correlation_id', (string) $correlationId); } @@ -130,7 +130,7 @@ public function getCorrelationId(): ?string return $this->getHeader('correlation_id'); } - public function setMessageId(string $messageId = null): void + public function setMessageId(?string $messageId = null): void { $this->setHeader('message_id', (string) $messageId); } @@ -147,7 +147,7 @@ public function getTimestamp(): ?int return null === $value ? null : (int) $value; } - public function setTimestamp(int $timestamp = null): void + public function setTimestamp(?int $timestamp = null): void { $this->setHeader('timestamp', $timestamp); } @@ -157,12 +157,12 @@ public function getFrame(): ?Frame return $this->frame; } - public function setFrame(Frame $frame = null): void + public function setFrame(?Frame $frame = null): void { $this->frame = $frame; } - public function setReplyTo(string $replyTo = null): void + public function setReplyTo(?string $replyTo = null): void { $this->setHeader('reply-to', $replyTo); } diff --git a/pkg/stomp/StompProducer.php b/pkg/stomp/StompProducer.php index 8c1933ee4..909720973 100644 --- a/pkg/stomp/StompProducer.php +++ b/pkg/stomp/StompProducer.php @@ -45,7 +45,7 @@ public function send(Destination $destination, Message $message): void /** * @return $this|Producer */ - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { if (empty($deliveryDelay)) { return $this; @@ -64,7 +64,7 @@ public function getDeliveryDelay(): ?int * * @return $this|Producer */ - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { if (empty($priority)) { return $this; @@ -81,7 +81,7 @@ public function getPriority(): ?int /** * @return $this|Producer */ - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { if (empty($timeToLive)) { return $this; diff --git a/pkg/stomp/Tests/Spec/StompMessageTest.php b/pkg/stomp/Tests/Spec/StompMessageTest.php index dd9e733ea..8f6748b63 100644 --- a/pkg/stomp/Tests/Spec/StompMessageTest.php +++ b/pkg/stomp/Tests/Spec/StompMessageTest.php @@ -7,9 +7,6 @@ class StompMessageTest extends MessageSpec { - /** - * {@inheritdoc} - */ protected function createMessage() { return new StompMessage(); diff --git a/pkg/stomp/Tests/StompConnectionFactoryConfigTest.php b/pkg/stomp/Tests/StompConnectionFactoryConfigTest.php index 3899f3c76..d784d4104 100644 --- a/pkg/stomp/Tests/StompConnectionFactoryConfigTest.php +++ b/pkg/stomp/Tests/StompConnectionFactoryConfigTest.php @@ -41,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/pkg/stomp/Tests/StompHeadersEncoderTest.php b/pkg/stomp/Tests/StompHeadersEncoderTest.php index 7997e05a4..cd3d112dd 100644 --- a/pkg/stomp/Tests/StompHeadersEncoderTest.php +++ b/pkg/stomp/Tests/StompHeadersEncoderTest.php @@ -32,9 +32,6 @@ public function propertyValuesDataProvider() /** * @dataProvider headerValuesDataProvider - * - * @param mixed $originalValue - * @param mixed $encodedValue */ public function testShouldEncodeHeaders($originalValue, $encodedValue) { @@ -43,9 +40,6 @@ public function testShouldEncodeHeaders($originalValue, $encodedValue) /** * @dataProvider propertyValuesDataProvider - * - * @param mixed $originalValue - * @param mixed $encodedValue */ public function testShouldEncodeProperties($originalValue, $encodedValue) { @@ -54,9 +48,6 @@ public function testShouldEncodeProperties($originalValue, $encodedValue) /** * @dataProvider headerValuesDataProvider - * - * @param mixed $originalValue - * @param mixed $encodedValue */ public function testShouldDecodeHeaders($originalValue, $encodedValue) { @@ -65,9 +56,6 @@ public function testShouldDecodeHeaders($originalValue, $encodedValue) /** * @dataProvider propertyValuesDataProvider - * - * @param mixed $originalValue - * @param mixed $encodedValue */ public function testShouldDecodeProperties($originalValue, $encodedValue) { diff --git a/pkg/stomp/Tests/StompMessageTest.php b/pkg/stomp/Tests/StompMessageTest.php index 736df79a2..49be1a8c5 100644 --- a/pkg/stomp/Tests/StompMessageTest.php +++ b/pkg/stomp/Tests/StompMessageTest.php @@ -93,7 +93,7 @@ public function testShouldUnsetHeaderIfNullPassed() $message->setHeader('aHeader', 'aVal'); - //guard + // guard $this->assertSame('aVal', $message->getHeader('aHeader')); $message->setHeader('aHeader', null); @@ -108,7 +108,7 @@ public function testShouldUnsetPropertyIfNullPassed() $message->setProperty('aProperty', 'aVal'); - //guard + // guard $this->assertSame('aVal', $message->getProperty('aProperty')); $message->setProperty('aProperty', null); diff --git a/pkg/test/RabbitManagementExtensionTrait.php b/pkg/test/RabbitManagementExtensionTrait.php index 82bdd072c..184b1758e 100644 --- a/pkg/test/RabbitManagementExtensionTrait.php +++ b/pkg/test/RabbitManagementExtensionTrait.php @@ -21,17 +21,17 @@ private function removeQueue($queueName) ); $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - curl_setopt($ch, CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword()); - curl_setopt($ch, CURLOPT_HTTPHEADER, [ + curl_setopt($ch, \CURLOPT_URL, $url); + curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE'); + curl_setopt($ch, \CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, \CURLOPT_HTTPAUTH, \CURLAUTH_BASIC); + curl_setopt($ch, \CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword()); + curl_setopt($ch, \CURLOPT_HTTPHEADER, [ 'Content-Type' => 'application/json', ]); curl_exec($ch); - $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $httpCode = curl_getinfo($ch, \CURLINFO_HTTP_CODE); curl_close($ch); @@ -55,17 +55,17 @@ private function removeExchange($exchangeName) ); $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - curl_setopt($ch, CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword()); - curl_setopt($ch, CURLOPT_HTTPHEADER, [ + curl_setopt($ch, \CURLOPT_URL, $url); + curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE'); + curl_setopt($ch, \CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, \CURLOPT_HTTPAUTH, \CURLAUTH_BASIC); + curl_setopt($ch, \CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword()); + curl_setopt($ch, \CURLOPT_HTTPHEADER, [ 'Content-Type' => 'application/json', ]); curl_exec($ch); - $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $httpCode = curl_getinfo($ch, \CURLINFO_HTTP_CODE); curl_close($ch); diff --git a/pkg/test/ReadAttributeTrait.php b/pkg/test/ReadAttributeTrait.php index 6938f257c..5b9758a64 100644 --- a/pkg/test/ReadAttributeTrait.php +++ b/pkg/test/ReadAttributeTrait.php @@ -2,8 +2,6 @@ namespace Enqueue\Test; -use ReflectionProperty; - trait ReadAttributeTrait { public function readAttribute(object $object, string $attribute) @@ -19,14 +17,14 @@ public function readAttribute(object $object, string $attribute) private function getClassAttribute( object $object, string $attribute, - ?string $class = null - ): ReflectionProperty { + ?string $class = null, + ): \ReflectionProperty { if (null === $class) { - $class = get_class($object); + $class = $object::class; } try { - return new ReflectionProperty($class, $attribute); + return new \ReflectionProperty($class, $attribute); } catch (\ReflectionException $exception) { $parentClass = get_parent_class($object); if (false === $parentClass) { diff --git a/pkg/test/RedisExtension.php b/pkg/test/RedisExtension.php index 86586d16b..3227785c2 100644 --- a/pkg/test/RedisExtension.php +++ b/pkg/test/RedisExtension.php @@ -20,7 +20,7 @@ private function buildPhpRedisContext(): RedisContext $context = (new RedisConnectionFactory($config))->createContext(); - //guard + // guard $this->assertInstanceOf(PhpRedis::class, $context->getRedis()); return $context; @@ -36,7 +36,7 @@ private function buildPRedisContext(): RedisContext $context = (new RedisConnectionFactory($config))->createContext(); - //guard + // guard $this->assertInstanceOf(PRedis::class, $context->getRedis()); return $context; diff --git a/pkg/test/TestLogger.php b/pkg/test/TestLogger.php index d61c67932..9db2c2a5e 100644 --- a/pkg/test/TestLogger.php +++ b/pkg/test/TestLogger.php @@ -111,7 +111,7 @@ public function hasRecord($record, $level) public function hasRecordThatContains($message, $level) { return $this->hasRecordThatPasses(function ($rec) use ($message) { - return false !== strpos($rec['message'], $message); + return str_contains($rec['message'], $message); }, $level); } diff --git a/pkg/test/WriteAttributeTrait.php b/pkg/test/WriteAttributeTrait.php index e2e84bd2a..6f8c1aab5 100644 --- a/pkg/test/WriteAttributeTrait.php +++ b/pkg/test/WriteAttributeTrait.php @@ -7,11 +7,10 @@ trait WriteAttributeTrait /** * @param object $object * @param string $attribute - * @param mixed $value */ public function writeAttribute($object, $attribute, $value) { - $refProperty = new \ReflectionProperty(get_class($object), $attribute); + $refProperty = new \ReflectionProperty($object::class, $attribute); $refProperty->setAccessible(true); $refProperty->setValue($object, $value); $refProperty->setAccessible(false); diff --git a/pkg/wamp/JsonSerializer.php b/pkg/wamp/JsonSerializer.php index b6027ba81..9a224fbb8 100644 --- a/pkg/wamp/JsonSerializer.php +++ b/pkg/wamp/JsonSerializer.php @@ -14,12 +14,8 @@ public function toString(WampMessage $message): string 'headers' => $message->getHeaders(), ]); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return $json; @@ -28,12 +24,8 @@ public function toString(WampMessage $message): string public function toMessage(string $string): WampMessage { $data = json_decode($string, true); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return new WampMessage($data['body'], $data['properties'], $data['headers']); diff --git a/pkg/wamp/SerializerAwareTrait.php b/pkg/wamp/SerializerAwareTrait.php index c2ce9b603..adfe66e7e 100644 --- a/pkg/wamp/SerializerAwareTrait.php +++ b/pkg/wamp/SerializerAwareTrait.php @@ -11,9 +11,6 @@ trait SerializerAwareTrait */ private $serializer; - /** - * @param Serializer $serializer - */ public function setSerializer(Serializer $serializer) { $this->serializer = $serializer; diff --git a/pkg/wamp/Tests/Functional/WampConsumerTest.php b/pkg/wamp/Tests/Functional/WampConsumerTest.php index 2494721d1..bb2dd89a4 100644 --- a/pkg/wamp/Tests/Functional/WampConsumerTest.php +++ b/pkg/wamp/Tests/Functional/WampConsumerTest.php @@ -12,6 +12,7 @@ /** * @group functional * @group Wamp + * * @retry 5 */ class WampConsumerTest extends TestCase diff --git a/pkg/wamp/Tests/Spec/JsonSerializerTest.php b/pkg/wamp/Tests/Spec/JsonSerializerTest.php index f1c3e24d3..f062a7058 100644 --- a/pkg/wamp/Tests/Spec/JsonSerializerTest.php +++ b/pkg/wamp/Tests/Spec/JsonSerializerTest.php @@ -37,7 +37,7 @@ public function testThrowIfFailedToEncodeMessageToJson() $resource = fopen(__FILE__, 'r'); - //guard + // guard $this->assertIsResource($resource); $message = new WampMessage('theBody', ['aProp' => $resource]); diff --git a/pkg/wamp/Tests/Spec/WampConnectionFactoryTest.php b/pkg/wamp/Tests/Spec/WampConnectionFactoryTest.php index 3c3ccf841..5b6e418c9 100644 --- a/pkg/wamp/Tests/Spec/WampConnectionFactoryTest.php +++ b/pkg/wamp/Tests/Spec/WampConnectionFactoryTest.php @@ -10,9 +10,6 @@ */ class WampConnectionFactoryTest extends ConnectionFactorySpec { - /** - * {@inheritdoc} - */ protected function createConnectionFactory() { return new WampConnectionFactory(); diff --git a/pkg/wamp/Tests/Spec/WampContextTest.php b/pkg/wamp/Tests/Spec/WampContextTest.php index 0bd70c772..4b2fb6c59 100644 --- a/pkg/wamp/Tests/Spec/WampContextTest.php +++ b/pkg/wamp/Tests/Spec/WampContextTest.php @@ -13,9 +13,6 @@ class WampContextTest extends ContextSpec { use WampExtension; - /** - * {@inheritdoc} - */ protected function createContext() { return $this->buildWampContext(); diff --git a/pkg/wamp/Tests/Spec/WampMessageTest.php b/pkg/wamp/Tests/Spec/WampMessageTest.php index 5482fadde..3e030d8c1 100644 --- a/pkg/wamp/Tests/Spec/WampMessageTest.php +++ b/pkg/wamp/Tests/Spec/WampMessageTest.php @@ -10,9 +10,6 @@ */ class WampMessageTest extends MessageSpec { - /** - * {@inheritdoc} - */ protected function createMessage() { return new WampMessage(); diff --git a/pkg/wamp/Tests/Spec/WampProducerTest.php b/pkg/wamp/Tests/Spec/WampProducerTest.php index d28194688..55aa68403 100644 --- a/pkg/wamp/Tests/Spec/WampProducerTest.php +++ b/pkg/wamp/Tests/Spec/WampProducerTest.php @@ -13,9 +13,6 @@ class WampProducerTest extends ProducerSpec { use WampExtension; - /** - * {@inheritdoc} - */ protected function createProducer() { return $this->buildWampContext()->createProducer(); diff --git a/pkg/wamp/Tests/Spec/WampQueueTest.php b/pkg/wamp/Tests/Spec/WampQueueTest.php index e8cb87267..015536fd1 100644 --- a/pkg/wamp/Tests/Spec/WampQueueTest.php +++ b/pkg/wamp/Tests/Spec/WampQueueTest.php @@ -10,9 +10,6 @@ */ class WampQueueTest extends QueueSpec { - /** - * {@inheritdoc} - */ protected function createQueue() { return new WampDestination(self::EXPECTED_QUEUE_NAME); diff --git a/pkg/wamp/Tests/Spec/WampTopicTest.php b/pkg/wamp/Tests/Spec/WampTopicTest.php index 4c48e7911..854da2c87 100644 --- a/pkg/wamp/Tests/Spec/WampTopicTest.php +++ b/pkg/wamp/Tests/Spec/WampTopicTest.php @@ -10,9 +10,6 @@ */ class WampTopicTest extends TopicSpec { - /** - * {@inheritdoc} - */ protected function createTopic() { return new WampDestination(self::EXPECTED_TOPIC_NAME); diff --git a/pkg/wamp/WampConnectionFactory.php b/pkg/wamp/WampConnectionFactory.php index 3ba29f60a..d4ea9d73b 100644 --- a/pkg/wamp/WampConnectionFactory.php +++ b/pkg/wamp/WampConnectionFactory.php @@ -88,10 +88,7 @@ private function parseDsn(string $dsn): array $dsn = Dsn::parseFirst($dsn); if (false === in_array($dsn->getSchemeProtocol(), ['wamp', 'ws'], true)) { - throw new \LogicException(sprintf( - 'The given scheme protocol "%s" is not supported. It must be "wamp"', - $dsn->getSchemeProtocol() - )); + throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "wamp"', $dsn->getSchemeProtocol())); } return array_filter(array_replace($dsn->getQuery(), [ diff --git a/pkg/wamp/WampConsumer.php b/pkg/wamp/WampConsumer.php index 8dc859739..8a6733e36 100644 --- a/pkg/wamp/WampConsumer.php +++ b/pkg/wamp/WampConsumer.php @@ -84,7 +84,7 @@ public function receive(int $timeout = 0): ?Message } if ($timeout > 0) { - $timeout = $timeout / 1000; + $timeout /= 1000; $timeout = $timeout >= 0.1 ? $timeout : 0.1; $this->timer = $this->client->getLoop()->addTimer($timeout, function () { @@ -112,8 +112,6 @@ public function receiveNoWait(): ?Message } /** - * {@inheritdoc} - * * @param WampMessage $message */ public function acknowledge(Message $message): void @@ -122,8 +120,6 @@ public function acknowledge(Message $message): void } /** - * {@inheritdoc} - * * @param WampMessage $message */ public function reject(Message $message, bool $requeue = false): void diff --git a/pkg/wamp/WampContext.php b/pkg/wamp/WampContext.php index 9bbed5087..623aa33f9 100644 --- a/pkg/wamp/WampContext.php +++ b/pkg/wamp/WampContext.php @@ -97,11 +97,7 @@ public function getNewClient(): Client $client = call_user_func($this->clientFactory); if (false == $client instanceof Client) { - throw new \LogicException(sprintf( - 'The factory must return instance of "%s". But it returns %s', - Client::class, - is_object($client) ? get_class($client) : gettype($client) - )); + throw new \LogicException(sprintf('The factory must return instance of "%s". But it returns %s', Client::class, is_object($client) ? $client::class : gettype($client))); } $this->clients[] = $client; diff --git a/pkg/wamp/WampProducer.php b/pkg/wamp/WampProducer.php index 3bffe21f0..71ea625ae 100644 --- a/pkg/wamp/WampProducer.php +++ b/pkg/wamp/WampProducer.php @@ -48,8 +48,6 @@ public function __construct(WampContext $context) } /** - * {@inheritdoc} - * * @param WampDestination $destination * @param WampMessage $message */ @@ -113,11 +111,9 @@ public function send(Destination $destination, Message $message): void } /** - * {@inheritdoc} - * * @return WampProducer */ - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { if (null === $deliveryDelay) { return $this; @@ -132,11 +128,9 @@ public function getDeliveryDelay(): ?int } /** - * {@inheritdoc} - * * @return WampProducer */ - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { if (null === $priority) { return $this; @@ -151,11 +145,9 @@ public function getPriority(): ?int } /** - * {@inheritdoc} - * * @return WampProducer */ - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { if (null === $timeToLive) { return $this; diff --git a/pkg/wamp/WampSubscriptionConsumer.php b/pkg/wamp/WampSubscriptionConsumer.php index 6b96926e1..2d25a673b 100644 --- a/pkg/wamp/WampSubscriptionConsumer.php +++ b/pkg/wamp/WampSubscriptionConsumer.php @@ -84,7 +84,7 @@ public function consume(int $timeout = 0): void } if ($timeout > 0) { - $timeout = $timeout / 1000; + $timeout /= 1000; $timeout = $timeout >= 0.1 ? $timeout : 0.1; $this->timer = $this->client->getLoop()->addTimer($timeout, function () { @@ -100,14 +100,12 @@ public function consume(int $timeout = 0): void } /** - * {@inheritdoc} - * * @param WampConsumer $consumer */ public function subscribe(Consumer $consumer, callable $callback): void { if (false == $consumer instanceof WampConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', WampConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', WampConsumer::class, $consumer::class)); } if ($this->client) { @@ -127,14 +125,12 @@ public function subscribe(Consumer $consumer, callable $callback): void } /** - * {@inheritdoc} - * * @param WampConsumer $consumer */ public function unsubscribe(Consumer $consumer): void { if (false == $consumer instanceof WampConsumer) { - throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', WampConsumer::class, get_class($consumer))); + throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', WampConsumer::class, $consumer::class)); } if ($this->client) {