Skip to content

Commit 1fbbce3

Browse files
committed
[gearman] Do not use deprecated classes
1 parent f19f85d commit 1fbbce3

13 files changed

+77
-77
lines changed

GearmanConnectionFactory.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace Enqueue\Gearman;
66

7-
use Interop\Queue\PsrConnectionFactory;
8-
use Interop\Queue\PsrContext;
7+
use Interop\Queue\ConnectionFactory;
8+
use Interop\Queue\Context;
99

10-
class GearmanConnectionFactory implements PsrConnectionFactory
10+
class GearmanConnectionFactory implements ConnectionFactory
1111
{
1212
/**
1313
* @var array
@@ -45,7 +45,7 @@ public function __construct($config = 'gearman:')
4545
/**
4646
* @return GearmanContext
4747
*/
48-
public function createContext(): PsrContext
48+
public function createContext(): Context
4949
{
5050
return new GearmanContext($this->config);
5151
}

GearmanConsumer.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
namespace Enqueue\Gearman;
66

7-
use Interop\Queue\PsrConsumer;
8-
use Interop\Queue\PsrMessage;
9-
use Interop\Queue\PsrQueue;
7+
use Interop\Queue\Consumer;
8+
use Interop\Queue\Message;
9+
use Interop\Queue\Queue;
1010

11-
class GearmanConsumer implements PsrConsumer
11+
class GearmanConsumer implements Consumer
1212
{
1313
/**
1414
* @var \GearmanWorker
@@ -36,15 +36,15 @@ public function __construct(GearmanContext $context, GearmanDestination $destina
3636
/**
3737
* @return GearmanDestination
3838
*/
39-
public function getQueue(): PsrQueue
39+
public function getQueue(): Queue
4040
{
4141
return $this->destination;
4242
}
4343

4444
/**
4545
* @return GearmanMessage
4646
*/
47-
public function receive(int $timeout = 0): ?PsrMessage
47+
public function receive(int $timeout = 0): ?Message
4848
{
4949
set_error_handler(function ($severity, $message, $file, $line) {
5050
throw new \ErrorException($message, 0, $severity, $file, $line);
@@ -70,22 +70,22 @@ public function receive(int $timeout = 0): ?PsrMessage
7070
/**
7171
* @return GearmanMessage
7272
*/
73-
public function receiveNoWait(): ?PsrMessage
73+
public function receiveNoWait(): ?Message
7474
{
7575
return $this->receive(100);
7676
}
7777

7878
/**
7979
* @param GearmanMessage $message
8080
*/
81-
public function acknowledge(PsrMessage $message): void
81+
public function acknowledge(Message $message): void
8282
{
8383
}
8484

8585
/**
8686
* @param GearmanMessage $message
8787
*/
88-
public function reject(PsrMessage $message, bool $requeue = false): void
88+
public function reject(Message $message, bool $requeue = false): void
8989
{
9090
if ($requeue) {
9191
$this->context->createProducer()->send($this->destination, $message);

GearmanContext.php

+22-22
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44

55
namespace Enqueue\Gearman;
66

7-
use Interop\Queue\InvalidDestinationException;
8-
use Interop\Queue\PsrConsumer;
9-
use Interop\Queue\PsrContext;
10-
use Interop\Queue\PsrDestination;
11-
use Interop\Queue\PsrMessage;
12-
use Interop\Queue\PsrProducer;
13-
use Interop\Queue\PsrQueue;
14-
use Interop\Queue\PsrSubscriptionConsumer;
15-
use Interop\Queue\PsrTopic;
16-
use Interop\Queue\PurgeQueueNotSupportedException;
17-
use Interop\Queue\SubscriptionConsumerNotSupportedException;
18-
use Interop\Queue\TemporaryQueueNotSupportedException;
19-
20-
class GearmanContext implements PsrContext
7+
use Interop\Queue\Consumer;
8+
use Interop\Queue\Context;
9+
use Interop\Queue\Destination;
10+
use Interop\Queue\Exception\InvalidDestinationException;
11+
use Interop\Queue\Exception\PurgeQueueNotSupportedException;
12+
use Interop\Queue\Exception\SubscriptionConsumerNotSupportedException;
13+
use Interop\Queue\Exception\TemporaryQueueNotSupportedException;
14+
use Interop\Queue\Message;
15+
use Interop\Queue\Producer;
16+
use Interop\Queue\Queue;
17+
use Interop\Queue\SubscriptionConsumer;
18+
use Interop\Queue\Topic;
19+
20+
class GearmanContext implements Context
2121
{
2222
/**
2323
* @var \GearmanClient
@@ -42,36 +42,36 @@ public function __construct(array $config)
4242
/**
4343
* @return GearmanMessage
4444
*/
45-
public function createMessage(string $body = '', array $properties = [], array $headers = []): PsrMessage
45+
public function createMessage(string $body = '', array $properties = [], array $headers = []): Message
4646
{
4747
return new GearmanMessage($body, $properties, $headers);
4848
}
4949

5050
/**
5151
* @return GearmanDestination
5252
*/
53-
public function createTopic(string $topicName): PsrTopic
53+
public function createTopic(string $topicName): Topic
5454
{
5555
return new GearmanDestination($topicName);
5656
}
5757

5858
/**
5959
* @return GearmanDestination
6060
*/
61-
public function createQueue(string $queueName): PsrQueue
61+
public function createQueue(string $queueName): Queue
6262
{
6363
return new GearmanDestination($queueName);
6464
}
6565

66-
public function createTemporaryQueue(): PsrQueue
66+
public function createTemporaryQueue(): Queue
6767
{
6868
throw TemporaryQueueNotSupportedException::providerDoestNotSupportIt();
6969
}
7070

7171
/**
7272
* @return GearmanProducer
7373
*/
74-
public function createProducer(): PsrProducer
74+
public function createProducer(): Producer
7575
{
7676
return new GearmanProducer($this->getClient());
7777
}
@@ -81,7 +81,7 @@ public function createProducer(): PsrProducer
8181
*
8282
* @return GearmanConsumer
8383
*/
84-
public function createConsumer(PsrDestination $destination): PsrConsumer
84+
public function createConsumer(Destination $destination): Consumer
8585
{
8686
InvalidDestinationException::assertDestinationInstanceOf($destination, GearmanDestination::class);
8787

@@ -99,12 +99,12 @@ public function close(): void
9999
}
100100
}
101101

102-
public function createSubscriptionConsumer(): PsrSubscriptionConsumer
102+
public function createSubscriptionConsumer(): SubscriptionConsumer
103103
{
104104
throw SubscriptionConsumerNotSupportedException::providerDoestNotSupportIt();
105105
}
106106

107-
public function purgeQueue(PsrQueue $queue): void
107+
public function purgeQueue(Queue $queue): void
108108
{
109109
throw PurgeQueueNotSupportedException::providerDoestNotSupportIt();
110110
}

GearmanDestination.php

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

55
namespace Enqueue\Gearman;
66

7-
use Interop\Queue\PsrQueue;
8-
use Interop\Queue\PsrTopic;
7+
use Interop\Queue\Queue;
8+
use Interop\Queue\Topic;
99

10-
class GearmanDestination implements PsrQueue, PsrTopic
10+
class GearmanDestination implements Queue, Topic
1111
{
1212
/**
1313
* @var string

GearmanMessage.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace Enqueue\Gearman;
66

7-
use Interop\Queue\PsrMessage;
7+
use Interop\Queue\Message;
88

9-
class GearmanMessage implements PsrMessage, \JsonSerializable
9+
class GearmanMessage implements Message, \JsonSerializable
1010
{
1111
/**
1212
* @var string

GearmanProducer.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
namespace Enqueue\Gearman;
66

7-
use Interop\Queue\InvalidDestinationException;
8-
use Interop\Queue\InvalidMessageException;
9-
use Interop\Queue\PsrDestination;
10-
use Interop\Queue\PsrMessage;
11-
use Interop\Queue\PsrProducer;
7+
use Interop\Queue\Destination;
8+
use Interop\Queue\Exception\InvalidDestinationException;
9+
use Interop\Queue\Exception\InvalidMessageException;
10+
use Interop\Queue\Message;
11+
use Interop\Queue\Producer;
1212

13-
class GearmanProducer implements PsrProducer
13+
class GearmanProducer implements Producer
1414
{
1515
/**
1616
* @var \GearmanClient
@@ -26,7 +26,7 @@ public function __construct(\GearmanClient $client)
2626
* @param GearmanDestination $destination
2727
* @param GearmanMessage $message
2828
*/
29-
public function send(PsrDestination $destination, PsrMessage $message): void
29+
public function send(Destination $destination, Message $message): void
3030
{
3131
InvalidDestinationException::assertDestinationInstanceOf($destination, GearmanDestination::class);
3232
InvalidMessageException::assertMessageInstanceOf($message, GearmanMessage::class);
@@ -39,7 +39,7 @@ public function send(PsrDestination $destination, PsrMessage $message): void
3939
}
4040
}
4141

42-
public function setDeliveryDelay(int $deliveryDelay = null): PsrProducer
42+
public function setDeliveryDelay(int $deliveryDelay = null): Producer
4343
{
4444
if (null === $deliveryDelay) {
4545
return $this;
@@ -53,7 +53,7 @@ public function getDeliveryDelay(): ?int
5353
return null;
5454
}
5555

56-
public function setPriority(int $priority = null): PsrProducer
56+
public function setPriority(int $priority = null): Producer
5757
{
5858
if (null === $priority) {
5959
return $this;
@@ -67,7 +67,7 @@ public function getPriority(): ?int
6767
return null;
6868
}
6969

70-
public function setTimeToLive(int $timeToLive = null): PsrProducer
70+
public function setTimeToLive(int $timeToLive = null): Producer
7171
{
7272
if (null === $timeToLive) {
7373
return $this;

Tests/GearmanContextTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
use Enqueue\Gearman\GearmanContext;
66
use Enqueue\Null\NullQueue;
77
use Enqueue\Test\ClassExtensionTrait;
8-
use Interop\Queue\InvalidDestinationException;
9-
use Interop\Queue\PsrContext;
10-
use Interop\Queue\TemporaryQueueNotSupportedException;
8+
use Interop\Queue\Context;
9+
use Interop\Queue\Exception\InvalidDestinationException;
10+
use Interop\Queue\Exception\TemporaryQueueNotSupportedException;
1111
use PHPUnit\Framework\TestCase;
1212

1313
/**
@@ -18,9 +18,9 @@ class GearmanContextTest extends TestCase
1818
use ClassExtensionTrait;
1919
use SkipIfGearmanExtensionIsNotInstalledTrait;
2020

21-
public function testShouldImplementPsrContextInterface()
21+
public function testShouldImplementContextInterface()
2222
{
23-
$this->assertClassImplements(PsrContext::class, GearmanContext::class);
23+
$this->assertClassImplements(Context::class, GearmanContext::class);
2424
}
2525

2626
public function testCouldBeConstructedWithConnectionConfigAsFirstArgument()

Tests/GearmanDestinationTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44

55
use Enqueue\Gearman\GearmanDestination;
66
use Enqueue\Test\ClassExtensionTrait;
7-
use Interop\Queue\PsrQueue;
8-
use Interop\Queue\PsrTopic;
7+
use Interop\Queue\Queue;
8+
use Interop\Queue\Topic;
99
use PHPUnit\Framework\TestCase;
1010

1111
class GearmanDestinationTest extends TestCase
1212
{
1313
use ClassExtensionTrait;
1414
use SkipIfGearmanExtensionIsNotInstalledTrait;
1515

16-
public function testShouldImplementPsrQueueInterface()
16+
public function testShouldImplementQueueInterface()
1717
{
18-
$this->assertClassImplements(PsrQueue::class, GearmanDestination::class);
18+
$this->assertClassImplements(Queue::class, GearmanDestination::class);
1919
}
2020

21-
public function testShouldImplementPsrTopicInterface()
21+
public function testShouldImplementTopicInterface()
2222
{
23-
$this->assertClassImplements(PsrTopic::class, GearmanDestination::class);
23+
$this->assertClassImplements(Topic::class, GearmanDestination::class);
2424
}
2525

2626
public function testShouldAllowGetNameSetInConstructor()

Tests/GearmanProducerTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
use Enqueue\Null\NullMessage;
99
use Enqueue\Null\NullQueue;
1010
use Enqueue\Test\ClassExtensionTrait;
11-
use Interop\Queue\InvalidDestinationException;
12-
use Interop\Queue\InvalidMessageException;
11+
use Interop\Queue\Exception\InvalidDestinationException;
12+
use Interop\Queue\Exception\InvalidMessageException;
1313
use PHPUnit\Framework\TestCase;
1414

1515
class GearmanProducerTest extends TestCase

Tests/Spec/GearmanSendToAndReceiveFromQueueTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Enqueue\Gearman\Tests\Spec;
44

55
use Enqueue\Gearman\GearmanConnectionFactory;
6-
use Interop\Queue\PsrContext;
7-
use Interop\Queue\PsrQueue;
6+
use Interop\Queue\Context;
7+
use Interop\Queue\Queue;
88
use Interop\Queue\Spec\SendToAndReceiveFromQueueSpec;
99

1010
/**
@@ -23,12 +23,12 @@ protected function createContext()
2323
}
2424

2525
/**
26-
* @param PsrContext $context
27-
* @param string $queueName
26+
* @param Context $context
27+
* @param string $queueName
2828
*
29-
* @return PsrQueue
29+
* @return Queue
3030
*/
31-
protected function createQueue(PsrContext $context, $queueName)
31+
protected function createQueue(Context $context, $queueName)
3232
{
3333
return $context->createQueue($queueName.time());
3434
}

Tests/Spec/GearmanSendToAndReceiveNoWaitFromQueueTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Enqueue\Gearman\Tests\Spec;
44

55
use Enqueue\Gearman\GearmanConnectionFactory;
6-
use Interop\Queue\PsrContext;
6+
use Interop\Queue\Context;
77
use Interop\Queue\Spec\SendToAndReceiveNoWaitFromQueueSpec;
88

99
/**
@@ -24,7 +24,7 @@ protected function createContext()
2424
/**
2525
* {@inheritdoc}
2626
*/
27-
protected function createQueue(PsrContext $context, $queueName)
27+
protected function createQueue(Context $context, $queueName)
2828
{
2929
return $context->createQueue($queueName.time());
3030
}

0 commit comments

Comments
 (0)