From 14fa9a667ff6bf16714f30bc1b159d3c9fb73bb7 Mon Sep 17 00:00:00 2001 From: James Read Date: Wed, 15 Jan 2025 22:51:32 +0000 Subject: [PATCH] Running php-cs-fixer Running php-cs-fixer to fix CS drift --- ConnectionConfig.php | 32 +++++++------------ DelayStrategyAware.php | 2 +- DelayStrategyAwareTrait.php | 2 +- RabbitMqDelayPluginDelayStrategy.php | 5 +-- RabbitMqDlxDelayStrategy.php | 8 +---- SignalSocketHelper.php | 9 ++---- Tests/ConnectionConfigTest.php | 3 -- .../RabbitMqDelayPluginDelayStrategyTest.php | 6 ++-- 8 files changed, 21 insertions(+), 46 deletions(-) diff --git a/ConnectionConfig.php b/ConnectionConfig.php index 224d54b..e1356c7 100644 --- a/ConnectionConfig.php +++ b/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/DelayStrategyAware.php b/DelayStrategyAware.php index f41a856..af488ce 100644 --- a/DelayStrategyAware.php +++ b/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/DelayStrategyAwareTrait.php b/DelayStrategyAwareTrait.php index 785f128..b29f057 100644 --- a/DelayStrategyAwareTrait.php +++ b/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/RabbitMqDelayPluginDelayStrategy.php b/RabbitMqDelayPluginDelayStrategy.php index 1921359..180d43b 100644 --- a/RabbitMqDelayPluginDelayStrategy.php +++ b/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/RabbitMqDlxDelayStrategy.php b/RabbitMqDlxDelayStrategy.php index f0fdd89..35d9b59 100644 --- a/RabbitMqDlxDelayStrategy.php +++ b/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/SignalSocketHelper.php b/SignalSocketHelper.php index 0bee8f2..623a5e3 100644 --- a/SignalSocketHelper.php +++ b/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/Tests/ConnectionConfigTest.php b/Tests/ConnectionConfigTest.php index 67a3f62..1a1dc47 100644 --- a/Tests/ConnectionConfigTest.php +++ b/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/Tests/RabbitMqDelayPluginDelayStrategyTest.php b/Tests/RabbitMqDelayPluginDelayStrategyTest.php index de2b77e..d205069 100644 --- a/Tests/RabbitMqDelayPluginDelayStrategyTest.php +++ b/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'); }