Skip to content

Commit

Permalink
Running php-cs-fixer
Browse files Browse the repository at this point in the history
Running php-cs-fixer to fix CS drift
  • Loading branch information
JimTools committed Jan 17, 2025
1 parent 866d454 commit 14fa9a6
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 46 deletions.
32 changes: 11 additions & 21 deletions ConnectionConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ public function __construct($config = null)
$this->addSupportedScheme('amqps');
}

/**
* @param string[] $extensions
*/
public function addSupportedScheme(string $schema): self
{
$this->supportedSchemes[] = $schema;
Expand All @@ -117,7 +114,6 @@ public function addSupportedScheme(string $schema): self

/**
* @param string $name
* @param mixed $value
*
* @return self
*/
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion DelayStrategyAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

interface DelayStrategyAware
{
public function setDelayStrategy(DelayStrategy $delayStrategy = null): self;
public function setDelayStrategy(?DelayStrategy $delayStrategy = null): self;
}
2 changes: 1 addition & 1 deletion DelayStrategyAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 1 addition & 4 deletions RabbitMqDelayPluginDelayStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 1 addition & 7 deletions RabbitMqDlxDelayStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@

class RabbitMqDlxDelayStrategy implements DelayStrategy
{
/**
* {@inheritdoc}
*/
public function delayMessage(AmqpContext $context, AmqpDestination $dest, AmqpMessage $message, int $delay): void
{
$properties = $message->getProperties();
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 3 additions & 6 deletions SignalSocketHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down Expand Up @@ -60,22 +60,19 @@ 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);
}

$this->handlers = [];
}

/**
* @return bool
*/
public function wasThereSignal(): bool
{
return (bool) $this->wasThereSignal;
Expand Down
3 changes: 0 additions & 3 deletions Tests/ConnectionConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ public function testShouldGetSchemeExtensions()

/**
* @dataProvider provideConfigs
*
* @param mixed $config
* @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
Expand Down
6 changes: 3 additions & 3 deletions Tests/RabbitMqDelayPluginDelayStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -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');
}
Expand All @@ -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');
}
Expand Down

0 comments on commit 14fa9a6

Please sign in to comment.