Skip to content

Commit 23b610d

Browse files
Add more nullsafe operators
1 parent 2062be4 commit 23b610d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Tests/Transport/AmqpTransportTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public function testReceivesMessages()
5454

5555
private function getTransport(SerializerInterface $serializer = null, Connection $connection = null): AmqpTransport
5656
{
57-
$serializer = $serializer ?? $this->createMock(SerializerInterface::class);
58-
$connection = $connection ?? $this->createMock(Connection::class);
57+
$serializer ??= $this->createMock(SerializerInterface::class);
58+
$connection ??= $this->createMock(Connection::class);
5959

6060
return new AmqpTransport($connection, $serializer);
6161
}

Transport/AmqpTransport.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,39 @@ public function __construct(Connection $connection, SerializerInterface $seriali
4040
*/
4141
public function get(): iterable
4242
{
43-
return ($this->receiver ?? $this->getReceiver())->get();
43+
return $this->getReceiver()->get();
4444
}
4545

4646
/**
4747
* {@inheritdoc}
4848
*/
4949
public function getFromQueues(array $queueNames): iterable
5050
{
51-
return ($this->receiver ?? $this->getReceiver())->getFromQueues($queueNames);
51+
return $this->getReceiver()->getFromQueues($queueNames);
5252
}
5353

5454
/**
5555
* {@inheritdoc}
5656
*/
5757
public function ack(Envelope $envelope): void
5858
{
59-
($this->receiver ?? $this->getReceiver())->ack($envelope);
59+
$this->getReceiver()->ack($envelope);
6060
}
6161

6262
/**
6363
* {@inheritdoc}
6464
*/
6565
public function reject(Envelope $envelope): void
6666
{
67-
($this->receiver ?? $this->getReceiver())->reject($envelope);
67+
$this->getReceiver()->reject($envelope);
6868
}
6969

7070
/**
7171
* {@inheritdoc}
7272
*/
7373
public function send(Envelope $envelope): Envelope
7474
{
75-
return ($this->sender ?? $this->getSender())->send($envelope);
75+
return $this->getSender()->send($envelope);
7676
}
7777

7878
/**
@@ -88,17 +88,17 @@ public function setup(): void
8888
*/
8989
public function getMessageCount(): int
9090
{
91-
return ($this->receiver ?? $this->getReceiver())->getMessageCount();
91+
return $this->getReceiver()->getMessageCount();
9292
}
9393

9494
private function getReceiver(): AmqpReceiver
9595
{
96-
return $this->receiver = new AmqpReceiver($this->connection, $this->serializer);
96+
return $this->receiver ??= new AmqpReceiver($this->connection, $this->serializer);
9797
}
9898

9999
private function getSender(): AmqpSender
100100
{
101-
return $this->sender = new AmqpSender($this->connection, $this->serializer);
101+
return $this->sender ??= new AmqpSender($this->connection, $this->serializer);
102102
}
103103
}
104104

0 commit comments

Comments
 (0)