diff --git a/Tests/Transport/AmqpTransportTest.php b/Tests/Transport/AmqpTransportTest.php index 433aeeb..21857d4 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 ??= $this->createMock(SerializerInterface::class); $connection ??= $this->createMock(Connection::class); diff --git a/Transport/AmqpReceiver.php b/Transport/AmqpReceiver.php index fecf39b..631f79d 100644 --- a/Transport/AmqpReceiver.php +++ b/Transport/AmqpReceiver.php @@ -30,7 +30,7 @@ class AmqpReceiver implements QueueReceiverInterface, MessageCountAwareInterface private SerializerInterface $serializer; private Connection $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 cbcecff..4f7caaa 100644 --- a/Transport/AmqpSender.php +++ b/Transport/AmqpSender.php @@ -29,7 +29,7 @@ class AmqpSender implements SenderInterface private SerializerInterface $serializer; private Connection $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 127593d..a91467f 100644 --- a/Transport/AmqpStamp.php +++ b/Transport/AmqpStamp.php @@ -24,7 +24,7 @@ final class AmqpStamp implements NonSendableStampInterface private array $attributes; private bool $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 2276536..edb0961 100644 --- a/Transport/AmqpTransport.php +++ b/Transport/AmqpTransport.php @@ -29,7 +29,7 @@ class AmqpTransport implements QueueReceiverInterface, TransportInterface, Setup private AmqpReceiver $receiver; private AmqpSender $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 260e226..fc5e5d0 100644 --- a/Transport/Connection.php +++ b/Transport/Connection.php @@ -97,7 +97,7 @@ class Connection private \AMQPExchange $amqpDelayExchange; private int $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__)); @@ -161,7 +161,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(#[\SensitiveParameter] string $dsn, array $options = [], AmqpFactory $amqpFactory = null): self + public static function fromDsn(#[\SensitiveParameter] 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 @@ -279,7 +279,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(); @@ -313,7 +313,7 @@ public function countMessagesInQueues(): int /** * @throws \AMQPException */ - private function publishWithDelay(string $body, array $headers, int $delay, AmqpStamp $amqpStamp = null): void + private function publishWithDelay(string $body, array $headers, int $delay, ?AmqpStamp $amqpStamp = null): void { $routingKey = $this->getRoutingKeyForMessage($amqpStamp); $isRetryAttempt = $amqpStamp ? $amqpStamp->isRetryAttempt() : false; @@ -329,7 +329,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): void + private function publishOnExchange(\AMQPExchange $exchange, string $body, ?string $routingKey = null, array $headers = [], ?AmqpStamp $amqpStamp = null): void { $attributes = $amqpStamp ? $amqpStamp->getAttributes() : []; $attributes['headers'] = array_merge($attributes['headers'] ?? [], $headers);