From 41d9dadbfd9edd0906c9a8d6b614f2fab274408f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 23 Jan 2024 14:51:25 +0100 Subject: [PATCH] Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value --- Tests/Transport/AmqpTransportTest.php | 2 +- Transport/AmqpReceiver.php | 2 +- Transport/AmqpSender.php | 2 +- Transport/AmqpStamp.php | 6 +++--- Transport/AmqpTransport.php | 2 +- Transport/Connection.php | 10 +++++----- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Tests/Transport/AmqpTransportTest.php b/Tests/Transport/AmqpTransportTest.php index 0223a03..743bd51 100644 --- a/Tests/Transport/AmqpTransportTest.php +++ b/Tests/Transport/AmqpTransportTest.php @@ -52,7 +52,7 @@ public function testReceivesMessages() $this->assertSame($decodedMessage, $envelopes[0]->getMessage()); } - private function getTransport(SerializerInterface $serializer = null, Connection $connection = null): AmqpTransport + private function getTransport(?SerializerInterface $serializer = null, ?Connection $connection = null): AmqpTransport { $serializer = $serializer ?? $this->createMock(SerializerInterface::class); $connection = $connection ?? $this->createMock(Connection::class); diff --git a/Transport/AmqpReceiver.php b/Transport/AmqpReceiver.php index 141ab8c..3cadcc1 100644 --- a/Transport/AmqpReceiver.php +++ b/Transport/AmqpReceiver.php @@ -30,7 +30,7 @@ class AmqpReceiver implements QueueReceiverInterface, MessageCountAwareInterface private $serializer; private $connection; - public function __construct(Connection $connection, SerializerInterface $serializer = null) + public function __construct(Connection $connection, ?SerializerInterface $serializer = null) { $this->connection = $connection; $this->serializer = $serializer ?? new PhpSerializer(); diff --git a/Transport/AmqpSender.php b/Transport/AmqpSender.php index 5fdfdff..c0c3e9b 100644 --- a/Transport/AmqpSender.php +++ b/Transport/AmqpSender.php @@ -29,7 +29,7 @@ class AmqpSender implements SenderInterface private $serializer; private $connection; - public function __construct(Connection $connection, SerializerInterface $serializer = null) + public function __construct(Connection $connection, ?SerializerInterface $serializer = null) { $this->connection = $connection; $this->serializer = $serializer ?? new PhpSerializer(); diff --git a/Transport/AmqpStamp.php b/Transport/AmqpStamp.php index 5835bdc..ba09690 100644 --- a/Transport/AmqpStamp.php +++ b/Transport/AmqpStamp.php @@ -24,7 +24,7 @@ final class AmqpStamp implements NonSendableStampInterface private $attributes; private $isRetryAttempt = false; - public function __construct(string $routingKey = null, int $flags = \AMQP_NOPARAM, array $attributes = []) + public function __construct(?string $routingKey = null, int $flags = \AMQP_NOPARAM, array $attributes = []) { $this->routingKey = $routingKey; $this->flags = $flags; @@ -46,7 +46,7 @@ public function getAttributes(): array return $this->attributes; } - public static function createFromAmqpEnvelope(\AMQPEnvelope $amqpEnvelope, self $previousStamp = null, string $retryRoutingKey = null): self + public static function createFromAmqpEnvelope(\AMQPEnvelope $amqpEnvelope, ?self $previousStamp = null, ?string $retryRoutingKey = null): self { $attr = $previousStamp->attributes ?? []; @@ -79,7 +79,7 @@ public function isRetryAttempt(): bool return $this->isRetryAttempt; } - public static function createWithAttributes(array $attributes, self $previousStamp = null): self + public static function createWithAttributes(array $attributes, ?self $previousStamp = null): self { return new self( $previousStamp->routingKey ?? null, diff --git a/Transport/AmqpTransport.php b/Transport/AmqpTransport.php index 9ffda47..52b5299 100644 --- a/Transport/AmqpTransport.php +++ b/Transport/AmqpTransport.php @@ -29,7 +29,7 @@ class AmqpTransport implements QueueReceiverInterface, TransportInterface, Setup private $receiver; private $sender; - public function __construct(Connection $connection, SerializerInterface $serializer = null) + public function __construct(Connection $connection, ?SerializerInterface $serializer = null) { $this->connection = $connection; $this->serializer = $serializer ?? new PhpSerializer(); diff --git a/Transport/Connection.php b/Transport/Connection.php index 1cdbe04..b0c9fe4 100644 --- a/Transport/Connection.php +++ b/Transport/Connection.php @@ -112,7 +112,7 @@ class Connection */ private $lastActivityTime = 0; - public function __construct(array $connectionOptions, array $exchangeOptions, array $queuesOptions, AmqpFactory $amqpFactory = null) + public function __construct(array $connectionOptions, array $exchangeOptions, array $queuesOptions, ?AmqpFactory $amqpFactory = null) { if (!\extension_loaded('amqp')) { throw new LogicException(sprintf('You cannot use the "%s" as the "amqp" extension is not installed.', __CLASS__)); @@ -176,7 +176,7 @@ public function __construct(array $connectionOptions, array $exchangeOptions, ar * * verify: Enable or disable peer verification. If peer verification is enabled then the common name in the * server certificate must match the server name. Peer verification is enabled by default. */ - public static function fromDsn(string $dsn, array $options = [], AmqpFactory $amqpFactory = null): self + public static function fromDsn(string $dsn, array $options = [], ?AmqpFactory $amqpFactory = null): self { if (false === $params = parse_url($dsn)) { // this is a valid URI that parse_url cannot handle when you want to pass all parameters as options @@ -298,7 +298,7 @@ private static function hasCaCertConfigured(array $amqpOptions): bool /** * @throws \AMQPException */ - public function publish(string $body, array $headers = [], int $delayInMs = 0, AmqpStamp $amqpStamp = null): void + public function publish(string $body, array $headers = [], int $delayInMs = 0, ?AmqpStamp $amqpStamp = null): void { $this->clearWhenDisconnected(); @@ -334,7 +334,7 @@ public function countMessagesInQueues(): int /** * @throws \AMQPException */ - private function publishWithDelay(string $body, array $headers, int $delay, AmqpStamp $amqpStamp = null) + private function publishWithDelay(string $body, array $headers, int $delay, ?AmqpStamp $amqpStamp = null) { $routingKey = $this->getRoutingKeyForMessage($amqpStamp); $isRetryAttempt = $amqpStamp ? $amqpStamp->isRetryAttempt() : false; @@ -350,7 +350,7 @@ private function publishWithDelay(string $body, array $headers, int $delay, Amqp ); } - private function publishOnExchange(\AMQPExchange $exchange, string $body, string $routingKey = null, array $headers = [], AmqpStamp $amqpStamp = null) + private function publishOnExchange(\AMQPExchange $exchange, string $body, ?string $routingKey = null, array $headers = [], ?AmqpStamp $amqpStamp = null) { $attributes = $amqpStamp ? $amqpStamp->getAttributes() : []; $attributes['headers'] = array_merge($attributes['headers'] ?? [], $headers);