Skip to content

Commit 5642cdb

Browse files
committed
[amqp-lib] Do not use deprecated classes.
1 parent 63cda2d commit 5642cdb

23 files changed

+94
-94
lines changed

AmqpConnectionFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Enqueue\AmqpTools\DelayStrategyAwareTrait;
1010
use Enqueue\AmqpTools\RabbitMqDlxDelayStrategy;
1111
use Interop\Amqp\AmqpConnectionFactory as InteropAmqpConnectionFactory;
12-
use Interop\Queue\PsrContext;
12+
use Interop\Queue\Context;
1313
use PhpAmqpLib\Connection\AbstractConnection;
1414
use PhpAmqpLib\Connection\AMQPLazyConnection;
1515
use PhpAmqpLib\Connection\AMQPLazySocketConnection;
@@ -58,7 +58,7 @@ public function __construct($config = 'amqp:')
5858
/**
5959
* @return AmqpContext
6060
*/
61-
public function createContext(): PsrContext
61+
public function createContext(): Context
6262
{
6363
$context = new AmqpContext($this->establishConnection(), $this->config->getConfig());
6464
$context->setDelayStrategy($this->delayStrategy);

AmqpConsumer.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use Interop\Amqp\AmqpConsumer as InteropAmqpConsumer;
88
use Interop\Amqp\AmqpMessage as InteropAmqpMessage;
99
use Interop\Amqp\AmqpQueue as InteropAmqpQueue;
10-
use Interop\Queue\InvalidMessageException;
11-
use Interop\Queue\PsrMessage;
12-
use Interop\Queue\PsrQueue;
10+
use Interop\Queue\Exception\InvalidMessageException;
11+
use Interop\Queue\Message;
12+
use Interop\Queue\Queue;
1313
use PhpAmqpLib\Channel\AMQPChannel;
1414

1515
class AmqpConsumer implements InteropAmqpConsumer
@@ -80,15 +80,15 @@ public function setFlags(int $flags): void
8080
/**
8181
* @return InteropAmqpQueue
8282
*/
83-
public function getQueue(): PsrQueue
83+
public function getQueue(): Queue
8484
{
8585
return $this->queue;
8686
}
8787

8888
/**
8989
* @return InteropAmqpMessage
9090
*/
91-
public function receive(int $timeout = 0): ?PsrMessage
91+
public function receive(int $timeout = 0): ?Message
9292
{
9393
$end = microtime(true) + ($timeout / 1000);
9494

@@ -106,7 +106,7 @@ public function receive(int $timeout = 0): ?PsrMessage
106106
/**
107107
* @return InteropAmqpMessage
108108
*/
109-
public function receiveNoWait(): ?PsrMessage
109+
public function receiveNoWait(): ?Message
110110
{
111111
if ($message = $this->channel->basic_get($this->queue->getQueueName(), (bool) ($this->getFlags() & InteropAmqpConsumer::FLAG_NOACK))) {
112112
return $this->context->convertMessage($message);
@@ -118,7 +118,7 @@ public function receiveNoWait(): ?PsrMessage
118118
/**
119119
* @param InteropAmqpMessage $message
120120
*/
121-
public function acknowledge(PsrMessage $message): void
121+
public function acknowledge(Message $message): void
122122
{
123123
InvalidMessageException::assertMessageInstanceOf($message, InteropAmqpMessage::class);
124124

@@ -129,7 +129,7 @@ public function acknowledge(PsrMessage $message): void
129129
* @param InteropAmqpMessage $message
130130
* @param bool $requeue
131131
*/
132-
public function reject(PsrMessage $message, bool $requeue = false): void
132+
public function reject(Message $message, bool $requeue = false): void
133133
{
134134
InvalidMessageException::assertMessageInstanceOf($message, InteropAmqpMessage::class);
135135

AmqpContext.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
use Interop\Amqp\Impl\AmqpMessage;
1616
use Interop\Amqp\Impl\AmqpQueue;
1717
use Interop\Amqp\Impl\AmqpTopic;
18-
use Interop\Queue\Exception;
19-
use Interop\Queue\InvalidDestinationException;
20-
use Interop\Queue\PsrConsumer;
21-
use Interop\Queue\PsrDestination;
22-
use Interop\Queue\PsrMessage;
23-
use Interop\Queue\PsrProducer;
24-
use Interop\Queue\PsrQueue;
25-
use Interop\Queue\PsrSubscriptionConsumer;
26-
use Interop\Queue\PsrTopic;
18+
use Interop\Queue\Consumer;
19+
use Interop\Queue\Destination;
20+
use Interop\Queue\Exception\Exception;
21+
use Interop\Queue\Exception\InvalidDestinationException;
22+
use Interop\Queue\Message;
23+
use Interop\Queue\Producer;
24+
use Interop\Queue\Queue;
25+
use Interop\Queue\SubscriptionConsumer;
26+
use Interop\Queue\Topic;
2727
use PhpAmqpLib\Channel\AMQPChannel;
2828
use PhpAmqpLib\Connection\AbstractConnection;
2929
use PhpAmqpLib\Message\AMQPMessage as LibAMQPMessage;
@@ -62,23 +62,23 @@ public function __construct(AbstractConnection $connection, array $config)
6262
/**
6363
* @return InteropAmqpMessage
6464
*/
65-
public function createMessage(string $body = '', array $properties = [], array $headers = []): PsrMessage
65+
public function createMessage(string $body = '', array $properties = [], array $headers = []): Message
6666
{
6767
return new AmqpMessage($body, $properties, $headers);
6868
}
6969

7070
/**
7171
* @return InteropAmqpQueue
7272
*/
73-
public function createQueue(string $name): PsrQueue
73+
public function createQueue(string $name): Queue
7474
{
7575
return new AmqpQueue($name);
7676
}
7777

7878
/**
7979
* @return InteropAmqpTopic
8080
*/
81-
public function createTopic(string $name): PsrTopic
81+
public function createTopic(string $name): Topic
8282
{
8383
return new AmqpTopic($name);
8484
}
@@ -88,9 +88,9 @@ public function createTopic(string $name): PsrTopic
8888
*
8989
* @return AmqpConsumer
9090
*/
91-
public function createConsumer(PsrDestination $destination): PsrConsumer
91+
public function createConsumer(Destination $destination): Consumer
9292
{
93-
$destination instanceof PsrTopic
93+
$destination instanceof Topic
9494
? InvalidDestinationException::assertDestinationInstanceOf($destination, InteropAmqpTopic::class)
9595
: InvalidDestinationException::assertDestinationInstanceOf($destination, InteropAmqpQueue::class)
9696
;
@@ -108,15 +108,15 @@ public function createConsumer(PsrDestination $destination): PsrConsumer
108108
/**
109109
* @return AmqpSubscriptionConsumer
110110
*/
111-
public function createSubscriptionConsumer(): PsrSubscriptionConsumer
111+
public function createSubscriptionConsumer(): SubscriptionConsumer
112112
{
113113
return new AmqpSubscriptionConsumer($this);
114114
}
115115

116116
/**
117117
* @return AmqpProducer
118118
*/
119-
public function createProducer(): PsrProducer
119+
public function createProducer(): Producer
120120
{
121121
$producer = new AmqpProducer($this->getLibChannel(), $this);
122122
$producer->setDelayStrategy($this->delayStrategy);
@@ -127,7 +127,7 @@ public function createProducer(): PsrProducer
127127
/**
128128
* @return InteropAmqpQueue
129129
*/
130-
public function createTemporaryQueue(): PsrQueue
130+
public function createTemporaryQueue(): Queue
131131
{
132132
list($name) = $this->getLibChannel()->queue_declare('', false, false, true, false);
133133

@@ -188,7 +188,7 @@ public function deleteQueue(InteropAmqpQueue $queue): void
188188
/**
189189
* @param AmqpQueue $queue
190190
*/
191-
public function purgeQueue(PsrQueue $queue): void
191+
public function purgeQueue(Queue $queue): void
192192
{
193193
InvalidDestinationException::assertDestinationInstanceOf($queue, InteropAmqpQueue::class);
194194

AmqpProducer.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
use Interop\Amqp\AmqpProducer as InteropAmqpProducer;
1212
use Interop\Amqp\AmqpQueue as InteropAmqpQueue;
1313
use Interop\Amqp\AmqpTopic as InteropAmqpTopic;
14-
use Interop\Queue\DeliveryDelayNotSupportedException;
15-
use Interop\Queue\Exception;
16-
use Interop\Queue\InvalidDestinationException;
17-
use Interop\Queue\InvalidMessageException;
18-
use Interop\Queue\PsrDestination;
19-
use Interop\Queue\PsrMessage;
20-
use Interop\Queue\PsrProducer;
21-
use Interop\Queue\PsrTopic;
14+
use Interop\Queue\Destination;
15+
use Interop\Queue\Exception\DeliveryDelayNotSupportedException;
16+
use Interop\Queue\Exception\Exception;
17+
use Interop\Queue\Exception\InvalidDestinationException;
18+
use Interop\Queue\Exception\InvalidMessageException;
19+
use Interop\Queue\Message;
20+
use Interop\Queue\Producer;
21+
use Interop\Queue\Topic;
2222
use PhpAmqpLib\Channel\AMQPChannel;
2323
use PhpAmqpLib\Message\AMQPMessage as LibAMQPMessage;
2424
use PhpAmqpLib\Wire\AMQPTable;
@@ -62,9 +62,9 @@ public function __construct(AMQPChannel $channel, AmqpContext $context)
6262
* @param InteropAmqpTopic|InteropAmqpQueue $destination
6363
* @param InteropAmqpMessage $message
6464
*/
65-
public function send(PsrDestination $destination, PsrMessage $message): void
65+
public function send(Destination $destination, Message $message): void
6666
{
67-
$destination instanceof PsrTopic
67+
$destination instanceof Topic
6868
? InvalidDestinationException::assertDestinationInstanceOf($destination, InteropAmqpTopic::class)
6969
: InvalidDestinationException::assertDestinationInstanceOf($destination, InteropAmqpQueue::class)
7070
;
@@ -81,7 +81,7 @@ public function send(PsrDestination $destination, PsrMessage $message): void
8181
/**
8282
* @return self
8383
*/
84-
public function setDeliveryDelay(int $deliveryDelay = null): PsrProducer
84+
public function setDeliveryDelay(int $deliveryDelay = null): Producer
8585
{
8686
if (null === $this->delayStrategy) {
8787
throw DeliveryDelayNotSupportedException::providerDoestNotSupportIt();
@@ -100,7 +100,7 @@ public function getDeliveryDelay(): ?int
100100
/**
101101
* @return self
102102
*/
103-
public function setPriority(int $priority = null): PsrProducer
103+
public function setPriority(int $priority = null): Producer
104104
{
105105
$this->priority = $priority;
106106

@@ -115,7 +115,7 @@ public function getPriority(): ?int
115115
/**
116116
* @return self
117117
*/
118-
public function setTimeToLive(int $timeToLive = null): PsrProducer
118+
public function setTimeToLive(int $timeToLive = null): Producer
119119
{
120120
$this->timeToLive = $timeToLive;
121121

AmqpSubscriptionConsumer.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use Enqueue\AmqpTools\SignalSocketHelper;
88
use Interop\Amqp\AmqpConsumer as InteropAmqpConsumer;
99
use Interop\Amqp\AmqpSubscriptionConsumer as InteropAmqpSubscriptionConsumer;
10-
use Interop\Queue\Exception;
11-
use Interop\Queue\PsrConsumer;
10+
use Interop\Queue\Consumer;
11+
use Interop\Queue\Exception\Exception;
1212
use PhpAmqpLib\Exception\AMQPIOWaitException;
1313
use PhpAmqpLib\Exception\AMQPTimeoutException;
1414
use PhpAmqpLib\Message\AMQPMessage as LibAMQPMessage;
@@ -75,7 +75,7 @@ public function consume(int $timeout = 0): void
7575
/**
7676
* @param AmqpConsumer $consumer
7777
*/
78-
public function subscribe(PsrConsumer $consumer, callable $callback): void
78+
public function subscribe(Consumer $consumer, callable $callback): void
7979
{
8080
if (false == $consumer instanceof AmqpConsumer) {
8181
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer)));
@@ -122,7 +122,7 @@ public function subscribe(PsrConsumer $consumer, callable $callback): void
122122
/**
123123
* @param AmqpConsumer $consumer
124124
*/
125-
public function unsubscribe(PsrConsumer $consumer): void
125+
public function unsubscribe(Consumer $consumer): void
126126
{
127127
if (false == $consumer instanceof AmqpConsumer) {
128128
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', AmqpConsumer::class, get_class($consumer)));

Tests/AmqpConnectionFactoryTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Enqueue\AmqpLib\AmqpConnectionFactory;
66
use Enqueue\AmqpTools\RabbitMqDlxDelayStrategy;
77
use Enqueue\Test\ClassExtensionTrait;
8-
use Interop\Queue\PsrConnectionFactory;
8+
use Interop\Queue\ConnectionFactory;
99
use PHPUnit\Framework\TestCase;
1010

1111
class AmqpConnectionFactoryTest extends TestCase
@@ -14,7 +14,7 @@ class AmqpConnectionFactoryTest extends TestCase
1414

1515
public function testShouldImplementConnectionFactoryInterface()
1616
{
17-
$this->assertClassImplements(PsrConnectionFactory::class, AmqpConnectionFactory::class);
17+
$this->assertClassImplements(ConnectionFactory::class, AmqpConnectionFactory::class);
1818
}
1919

2020
public function testShouldSetRabbitMqDlxDelayStrategyIfRabbitMqSchemeExtensionPresent()

Tests/AmqpConsumerTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use Enqueue\Test\WriteAttributeTrait;
1010
use Interop\Amqp\Impl\AmqpMessage;
1111
use Interop\Amqp\Impl\AmqpQueue;
12-
use Interop\Queue\InvalidMessageException;
13-
use Interop\Queue\PsrConsumer;
12+
use Interop\Queue\Consumer;
13+
use Interop\Queue\Exception\InvalidMessageException;
1414
use PhpAmqpLib\Channel\AMQPChannel;
1515
use PHPUnit\Framework\TestCase;
1616

@@ -21,7 +21,7 @@ class AmqpConsumerTest extends TestCase
2121

2222
public function testShouldImplementConsumerInterface()
2323
{
24-
$this->assertClassImplements(PsrConsumer::class, AmqpConsumer::class);
24+
$this->assertClassImplements(Consumer::class, AmqpConsumer::class);
2525
}
2626

2727
public function testCouldBeConstructedWithContextAndQueueAsArguments()

Tests/AmqpProducerTest.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
use Interop\Amqp\Impl\AmqpMessage;
99
use Interop\Amqp\Impl\AmqpQueue;
1010
use Interop\Amqp\Impl\AmqpTopic;
11-
use Interop\Queue\InvalidDestinationException;
12-
use Interop\Queue\InvalidMessageException;
13-
use Interop\Queue\PsrDestination;
14-
use Interop\Queue\PsrMessage;
15-
use Interop\Queue\PsrProducer;
11+
use Interop\Queue\Destination;
12+
use Interop\Queue\Exception\InvalidDestinationException;
13+
use Interop\Queue\Exception\InvalidMessageException;
14+
use Interop\Queue\Message;
15+
use Interop\Queue\Producer;
1616
use PhpAmqpLib\Channel\AMQPChannel;
1717
use PhpAmqpLib\Message\AMQPMessage as LibAMQPMessage;
1818
use PhpAmqpLib\Wire\AMQPTable;
@@ -27,9 +27,9 @@ public function testCouldBeConstructedWithRequiredArguments()
2727
new AmqpProducer($this->createAmqpChannelMock(), $this->createContextMock());
2828
}
2929

30-
public function testShouldImplementPsrProducerInterface()
30+
public function testShouldImplementProducerInterface()
3131
{
32-
$this->assertClassImplements(PsrProducer::class, AmqpProducer::class);
32+
$this->assertClassImplements(Producer::class, AmqpProducer::class);
3333
}
3434

3535
public function testShouldThrowExceptionWhenDestinationTypeIsInvalid()
@@ -142,19 +142,19 @@ public function testShouldSetMessageProperties()
142142
}
143143

144144
/**
145-
* @return \PHPUnit_Framework_MockObject_MockObject|PsrMessage
145+
* @return \PHPUnit_Framework_MockObject_MockObject|Message
146146
*/
147147
private function createMessageMock()
148148
{
149-
return $this->createMock(PsrMessage::class);
149+
return $this->createMock(Message::class);
150150
}
151151

152152
/**
153-
* @return \PHPUnit_Framework_MockObject_MockObject|PsrDestination
153+
* @return \PHPUnit_Framework_MockObject_MockObject|Destination
154154
*/
155155
private function createDestinationMock()
156156
{
157-
return $this->createMock(PsrDestination::class);
157+
return $this->createMock(Destination::class);
158158
}
159159

160160
/**

Tests/AmqpSubscriptionConsumerTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
use Enqueue\AmqpLib\AmqpContext;
66
use Enqueue\AmqpLib\AmqpSubscriptionConsumer;
7-
use Interop\Queue\PsrSubscriptionConsumer;
7+
use Interop\Queue\SubscriptionConsumer;
88
use PHPUnit\Framework\TestCase;
99

1010
class AmqpSubscriptionConsumerTest extends TestCase
1111
{
12-
public function testShouldImplementPsrSubscriptionConsumerInterface()
12+
public function testShouldImplementSubscriptionConsumerInterface()
1313
{
1414
$rc = new \ReflectionClass(AmqpSubscriptionConsumer::class);
1515

16-
$this->assertTrue($rc->implementsInterface(PsrSubscriptionConsumer::class));
16+
$this->assertTrue($rc->implementsInterface(SubscriptionConsumer::class));
1717
}
1818

1919
public function testCouldBeConstructedWithAmqpContextAsFirstArgument()

Tests/Spec/AmqpSendAndReceiveDelayedMessageWithDelayPluginStrategyTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Enqueue\AmqpLib\AmqpConnectionFactory;
66
use Enqueue\AmqpLib\AmqpContext;
77
use Enqueue\AmqpTools\RabbitMqDelayPluginDelayStrategy;
8-
use Interop\Queue\PsrContext;
8+
use Interop\Queue\Context;
99
use Interop\Queue\Spec\SendAndReceiveDelayedMessageFromQueueSpec;
1010

1111
/**
@@ -29,7 +29,7 @@ protected function createContext()
2929
*
3030
* {@inheritdoc}
3131
*/
32-
protected function createQueue(PsrContext $context, $queueName)
32+
protected function createQueue(Context $context, $queueName)
3333
{
3434
$queue = parent::createQueue($context, $queueName);
3535

0 commit comments

Comments
 (0)