Skip to content

Commit e0848d4

Browse files
committed
[Messenger] Add types to private properties
Signed-off-by: Alexander M. Turek <[email protected]>
1 parent 050f171 commit e0848d4

File tree

6 files changed

+29
-42
lines changed

6 files changed

+29
-42
lines changed

Transport/AmqpReceivedStamp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919
class AmqpReceivedStamp implements NonSendableStampInterface
2020
{
21-
private $amqpEnvelope;
22-
private $queueName;
21+
private \AMQPEnvelope $amqpEnvelope;
22+
private string $queueName;
2323

2424
public function __construct(\AMQPEnvelope $amqpEnvelope, string $queueName)
2525
{

Transport/AmqpReceiver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
*/
2828
class AmqpReceiver implements QueueReceiverInterface, MessageCountAwareInterface
2929
{
30-
private $serializer;
31-
private $connection;
30+
private SerializerInterface $serializer;
31+
private Connection $connection;
3232

3333
public function __construct(Connection $connection, SerializerInterface $serializer = null)
3434
{

Transport/AmqpSender.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
*/
2727
class AmqpSender implements SenderInterface
2828
{
29-
private $serializer;
30-
private $connection;
29+
private SerializerInterface $serializer;
30+
private Connection $connection;
3131

3232
public function __construct(Connection $connection, SerializerInterface $serializer = null)
3333
{

Transport/AmqpStamp.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
*/
2020
final class AmqpStamp implements NonSendableStampInterface
2121
{
22-
private $routingKey;
23-
private $flags;
24-
private $attributes;
25-
private $isRetryAttempt = false;
22+
private ?string $routingKey;
23+
private int $flags;
24+
private array $attributes;
25+
private bool $isRetryAttempt = false;
2626

2727
public function __construct(string $routingKey = null, int $flags = \AMQP_NOPARAM, array $attributes = [])
2828
{

Transport/AmqpTransport.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
*/
2525
class AmqpTransport implements QueueReceiverInterface, TransportInterface, SetupableTransportInterface, MessageCountAwareInterface
2626
{
27-
private $serializer;
28-
private $connection;
29-
private $receiver;
30-
private $sender;
27+
private SerializerInterface $serializer;
28+
private Connection $connection;
29+
private AmqpReceiver $receiver;
30+
private AmqpSender $sender;
3131

3232
public function __construct(Connection $connection, SerializerInterface $serializer = null)
3333
{

Transport/Connection.php

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -74,32 +74,21 @@ class Connection
7474
'arguments',
7575
];
7676

77-
private $connectionOptions;
78-
private $exchangeOptions;
79-
private $queuesOptions;
80-
private $amqpFactory;
81-
private $autoSetupExchange;
82-
private $autoSetupDelayExchange;
77+
private array $connectionOptions;
78+
private array $exchangeOptions;
79+
private array $queuesOptions;
80+
private AmqpFactory $amqpFactory;
81+
private mixed $autoSetupExchange;
82+
private mixed $autoSetupDelayExchange;
83+
private \AMQPChannel $amqpChannel;
84+
private \AMQPExchange $amqpExchange;
8385

8486
/**
85-
* @var \AMQPChannel|null
87+
* @var \AMQPQueue[]
8688
*/
87-
private $amqpChannel;
89+
private array $amqpQueues = [];
8890

89-
/**
90-
* @var \AMQPExchange|null
91-
*/
92-
private $amqpExchange;
93-
94-
/**
95-
* @var \AMQPQueue[]|null
96-
*/
97-
private $amqpQueues = [];
98-
99-
/**
100-
* @var \AMQPExchange|null
101-
*/
102-
private $amqpDelayExchange;
91+
private \AMQPExchange $amqpDelayExchange;
10392

10493
public function __construct(array $connectionOptions, array $exchangeOptions, array $queuesOptions, AmqpFactory $amqpFactory = null)
10594
{
@@ -367,7 +356,7 @@ private function setupDelay(int $delay, ?string $routingKey, bool $isRetryAttemp
367356

368357
private function getDelayExchange(): \AMQPExchange
369358
{
370-
if (null === $this->amqpDelayExchange) {
359+
if (!isset($this->amqpDelayExchange)) {
371360
$this->amqpDelayExchange = $this->amqpFactory->createExchange($this->channel());
372361
$this->amqpDelayExchange->setName($this->connectionOptions['delay']['exchange_name']);
373362
$this->amqpDelayExchange->setType(\AMQP_EX_TYPE_DIRECT);
@@ -483,7 +472,7 @@ public function getQueueNames(): array
483472

484473
public function channel(): \AMQPChannel
485474
{
486-
if (null === $this->amqpChannel) {
475+
if (!isset($this->amqpChannel)) {
487476
$connection = $this->amqpFactory->createConnection($this->connectionOptions);
488477
$connectMethod = 'true' === ($this->connectionOptions['persistent'] ?? 'false') ? 'pconnect' : 'connect';
489478

@@ -531,7 +520,7 @@ public function queue(string $queueName): \AMQPQueue
531520

532521
public function exchange(): \AMQPExchange
533522
{
534-
if (null === $this->amqpExchange) {
523+
if (!isset($this->amqpExchange)) {
535524
$this->amqpExchange = $this->amqpFactory->createExchange($this->channel());
536525
$this->amqpExchange->setName($this->exchangeOptions['name']);
537526
$this->amqpExchange->setType($this->exchangeOptions['type'] ?? \AMQP_EX_TYPE_FANOUT);
@@ -548,10 +537,8 @@ public function exchange(): \AMQPExchange
548537
private function clearWhenDisconnected(): void
549538
{
550539
if (!$this->channel()->isConnected()) {
551-
$this->amqpChannel = null;
540+
unset($this->amqpChannel, $this->amqpExchange, $this->amqpDelayExchange);
552541
$this->amqpQueues = [];
553-
$this->amqpExchange = null;
554-
$this->amqpDelayExchange = null;
555542
}
556543
}
557544

0 commit comments

Comments
 (0)