Skip to content

Commit

Permalink
Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_…
Browse files Browse the repository at this point in the history
…null_value
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
1 parent f5ffb4c commit 41d9dad
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Tests/Transport/AmqpTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Transport/AmqpReceiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Transport/AmqpSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions Transport/AmqpStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 ?? [];

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Transport/AmqpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions Transport/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__));
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 41d9dad

Please sign in to comment.