Skip to content

Commit cb64634

Browse files
author
Jonathan Bergler
committed
Fix compatibility with Laravel 12.34
-> vyuldashev#638
1 parent d06427b commit cb64634

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

src/Queue/RabbitMQQueue.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ class RabbitMQQueue extends Queue implements QueueContract, RabbitMQQueueContrac
6262
/**
6363
* Holds the Configuration
6464
*/
65-
protected QueueConfig $config;
65+
protected QueueConfig $rabbitMQConfig;
6666

6767
/**
6868
* RabbitMQQueue constructor.
6969
*/
7070
public function __construct(QueueConfig $config)
7171
{
72-
$this->config = $config;
72+
$this->rabbitMQConfig = $config;
7373
$this->dispatchAfterCommit = $config->isDispatchAfterCommit();
7474
}
7575

@@ -293,7 +293,7 @@ public function setConnection(AbstractConnection $connection): RabbitMQQueue
293293
*/
294294
public function getJobClass(): string
295295
{
296-
$job = $this->getConfig()->getAbstractJob();
296+
$job = $this->getRabbitMQConfig()->getAbstractJob();
297297

298298
throw_if(
299299
! is_a($job, RabbitMQJob::class, true),
@@ -309,7 +309,7 @@ public function getJobClass(): string
309309
*/
310310
public function getQueue($queue = null): string
311311
{
312-
return $queue ?: $this->getConfig()->getQueue();
312+
return $queue ?: $this->getRabbitMQConfig()->getQueue();
313313
}
314314

315315
/**
@@ -523,7 +523,7 @@ protected function createMessage($payload, int $attempts = 0): array
523523
$properties['correlation_id'] = $correlationId;
524524
}
525525

526-
if ($this->getConfig()->isPrioritizeDelayed()) {
526+
if ($this->getRabbitMQConfig()->isPrioritizeDelayed()) {
527527
$properties['priority'] = $attempts;
528528
}
529529

@@ -605,16 +605,16 @@ protected function getQueueArguments(string $destination): array
605605
// Messages with a priority which is higher than the queue's maximum, are treated as if they were
606606
// published with the maximum priority.
607607
// Quorum queues does not support priority.
608-
if ($this->getConfig()->isPrioritizeDelayed() && ! $this->getConfig()->isQuorum()) {
609-
$arguments['x-max-priority'] = $this->getConfig()->getQueueMaxPriority();
608+
if ($this->getRabbitMQConfig()->isPrioritizeDelayed() && ! $this->getRabbitMQConfig()->isQuorum()) {
609+
$arguments['x-max-priority'] = $this->getRabbitMQConfig()->getQueueMaxPriority();
610610
}
611611

612-
if ($this->getConfig()->isRerouteFailed()) {
612+
if ($this->getRabbitMQConfig()->isRerouteFailed()) {
613613
$arguments['x-dead-letter-exchange'] = $this->getFailedExchange();
614614
$arguments['x-dead-letter-routing-key'] = $this->getFailedRoutingKey($destination);
615615
}
616616

617-
if ($this->getConfig()->isQuorum()) {
617+
if ($this->getRabbitMQConfig()->isQuorum()) {
618618
$arguments['x-queue-type'] = 'quorum';
619619
}
620620

@@ -639,7 +639,7 @@ protected function getDelayQueueArguments(string $destination, int $ttl): array
639639
*/
640640
protected function getExchange(?string $exchange = null): string
641641
{
642-
return $exchange ?? $this->getConfig()->getExchange();
642+
return $exchange ?? $this->getRabbitMQConfig()->getExchange();
643643
}
644644

645645
/**
@@ -648,15 +648,15 @@ protected function getExchange(?string $exchange = null): string
648648
*/
649649
protected function getRoutingKey(string $destination): string
650650
{
651-
return ltrim(sprintf($this->getConfig()->getExchangeRoutingKey(), $destination), '.');
651+
return ltrim(sprintf($this->getRabbitMQConfig()->getExchangeRoutingKey(), $destination), '.');
652652
}
653653

654654
/**
655655
* Get the exchangeType, or AMQPExchangeType::DIRECT as default.
656656
*/
657657
protected function getExchangeType(?string $type = null): string
658658
{
659-
$constant = AMQPExchangeType::class.'::'.Str::upper($type ?: $this->getConfig()->getExchangeType());
659+
$constant = AMQPExchangeType::class.'::'.Str::upper($type ?: $this->getRabbitMQConfig()->getExchangeType());
660660

661661
return defined($constant) ? constant($constant) : AMQPExchangeType::DIRECT;
662662
}
@@ -666,7 +666,7 @@ protected function getExchangeType(?string $type = null): string
666666
*/
667667
protected function getFailedExchange(?string $exchange = null): string
668668
{
669-
return $exchange ?? $this->getConfig()->getFailedExchange();
669+
return $exchange ?? $this->getRabbitMQConfig()->getFailedExchange();
670670
}
671671

672672
/**
@@ -675,7 +675,7 @@ protected function getFailedExchange(?string $exchange = null): string
675675
*/
676676
protected function getFailedRoutingKey(string $destination): string
677677
{
678-
return ltrim(sprintf($this->getConfig()->getFailedRoutingKey(), $destination), '.');
678+
return ltrim(sprintf($this->getRabbitMQConfig()->getFailedRoutingKey(), $destination), '.');
679679
}
680680

681681
/**
@@ -735,9 +735,9 @@ protected function publishProperties($queue, array $options = []): array
735735
return [$destination, $exchange, $exchangeType, $attempts];
736736
}
737737

738-
protected function getConfig(): QueueConfig
738+
protected function getRabbitMQConfig(): QueueConfig
739739
{
740-
return $this->config;
740+
return $this->rabbitMQConfig;
741741
}
742742

743743
/**

tests/Functional/RabbitMQQueueTest.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,50 +24,50 @@ public function test_connection(): void
2424
public function test_config_reroute_failed(): void
2525
{
2626
$queue = $this->connection();
27-
$this->assertFalse($this->callProperty($queue, 'config')->isRerouteFailed());
27+
$this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isRerouteFailed());
2828

2929
$queue = $this->connection('rabbitmq-with-options');
30-
$this->assertTrue($this->callProperty($queue, 'config')->isRerouteFailed());
30+
$this->assertTrue($this->callProperty($queue, 'rabbitMQConfig')->isRerouteFailed());
3131

3232
$queue = $this->connection('rabbitmq-with-options-empty');
33-
$this->assertFalse($this->callProperty($queue, 'config')->isRerouteFailed());
33+
$this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isRerouteFailed());
3434

3535
$queue = $this->connection('rabbitmq-with-options-null');
36-
$this->assertFalse($this->callProperty($queue, 'config')->isRerouteFailed());
36+
$this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isRerouteFailed());
3737
}
3838

3939
public function test_config_prioritize_delayed(): void
4040
{
4141
$queue = $this->connection();
42-
$this->assertFalse($this->callProperty($queue, 'config')->isPrioritizeDelayed());
42+
$this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isPrioritizeDelayed());
4343

4444
$queue = $this->connection('rabbitmq-with-options');
45-
$this->assertTrue($this->callProperty($queue, 'config')->isPrioritizeDelayed());
45+
$this->assertTrue($this->callProperty($queue, 'rabbitMQConfig')->isPrioritizeDelayed());
4646

4747
$queue = $this->connection('rabbitmq-with-options-empty');
48-
$this->assertFalse($this->callProperty($queue, 'config')->isPrioritizeDelayed());
48+
$this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isPrioritizeDelayed());
4949

5050
$queue = $this->connection('rabbitmq-with-options-null');
51-
$this->assertFalse($this->callProperty($queue, 'config')->isPrioritizeDelayed());
51+
$this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isPrioritizeDelayed());
5252
}
5353

5454
public function test_queue_max_priority(): void
5555
{
5656
$queue = $this->connection();
57-
$this->assertIsInt($this->callProperty($queue, 'config')->getQueueMaxPriority());
58-
$this->assertSame(2, $this->callProperty($queue, 'config')->getQueueMaxPriority());
57+
$this->assertIsInt($this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority());
58+
$this->assertSame(2, $this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority());
5959

6060
$queue = $this->connection('rabbitmq-with-options');
61-
$this->assertIsInt($this->callProperty($queue, 'config')->getQueueMaxPriority());
62-
$this->assertSame(20, $this->callProperty($queue, 'config')->getQueueMaxPriority());
61+
$this->assertIsInt($this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority());
62+
$this->assertSame(20, $this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority());
6363

6464
$queue = $this->connection('rabbitmq-with-options-empty');
65-
$this->assertIsInt($this->callProperty($queue, 'config')->getQueueMaxPriority());
66-
$this->assertSame(2, $this->callProperty($queue, 'config')->getQueueMaxPriority());
65+
$this->assertIsInt($this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority());
66+
$this->assertSame(2, $this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority());
6767

6868
$queue = $this->connection('rabbitmq-with-options-null');
69-
$this->assertIsInt($this->callProperty($queue, 'config')->getQueueMaxPriority());
70-
$this->assertSame(2, $this->callProperty($queue, 'config')->getQueueMaxPriority());
69+
$this->assertIsInt($this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority());
70+
$this->assertSame(2, $this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority());
7171
}
7272

7373
public function test_config_exchange_type(): void
@@ -88,7 +88,7 @@ public function test_config_exchange_type(): void
8888
$this->assertSame(AMQPExchangeType::DIRECT, $this->callMethod($queue, 'getExchangeType'));
8989

9090
// testing an unkown type with a default
91-
$this->callProperty($queue, 'config')->setExchangeType('unknown');
91+
$this->callProperty($queue, 'rabbitMQConfig')->setExchangeType('unknown');
9292
$this->assertSame(AMQPExchangeType::DIRECT, $this->callMethod($queue, 'getExchangeType'));
9393
}
9494

@@ -161,7 +161,7 @@ public function test_routing_key(): void
161161

162162
$queue = $this->connection('rabbitmq-with-options-null');
163163
$this->assertSame('test', $this->callMethod($queue, 'getRoutingKey', ['test']));
164-
$this->callProperty($queue, 'config')->setExchangeRoutingKey('.an.alternate.routing-key');
164+
$this->callProperty($queue, 'rabbitMQConfig')->setExchangeRoutingKey('.an.alternate.routing-key');
165165
$this->assertSame('an.alternate.routing-key', $this->callMethod($queue, 'getRoutingKey', ['test']));
166166
}
167167

@@ -180,26 +180,26 @@ public function test_failed_routing_key(): void
180180

181181
$queue = $this->connection('rabbitmq-with-options-null');
182182
$this->assertSame('test.failed', $this->callMethod($queue, 'getFailedRoutingKey', ['test']));
183-
$this->callProperty($queue, 'config')->setFailedRoutingKey('.an.alternate.routing-key');
183+
$this->callProperty($queue, 'rabbitMQConfig')->setFailedRoutingKey('.an.alternate.routing-key');
184184
$this->assertSame('an.alternate.routing-key', $this->callMethod($queue, 'getFailedRoutingKey', ['test']));
185185
}
186186

187187
public function test_config_quorum(): void
188188
{
189189
$queue = $this->connection();
190-
$this->assertFalse($this->callProperty($queue, 'config')->isQuorum());
190+
$this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isQuorum());
191191

192192
$queue = $this->connection('rabbitmq-with-options');
193-
$this->assertFalse($this->callProperty($queue, 'config')->isQuorum());
193+
$this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isQuorum());
194194

195195
$queue = $this->connection('rabbitmq-with-options-empty');
196-
$this->assertFalse($this->callProperty($queue, 'config')->isQuorum());
196+
$this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isQuorum());
197197

198198
$queue = $this->connection('rabbitmq-with-options-null');
199-
$this->assertFalse($this->callProperty($queue, 'config')->isQuorum());
199+
$this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isQuorum());
200200

201201
$queue = $this->connection('rabbitmq-with-quorum-options');
202-
$this->assertTrue($this->callProperty($queue, 'config')->isQuorum());
202+
$this->assertTrue($this->callProperty($queue, 'rabbitMQConfig')->isQuorum());
203203
}
204204

205205
public function test_declare_delete_exchange(): void

0 commit comments

Comments
 (0)