Skip to content

Commit 7a629c5

Browse files
committed
Migrate null transport.
1 parent 42e384d commit 7a629c5

11 files changed

+99
-161
lines changed

pkg/dbal/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"license": "MIT",
88
"require": {
99
"php": "^7.1.3",
10-
"queue-interop/queue-interop": "^0.6.2",
10+
"queue-interop/queue-interop": "0.7.x-dev",
1111
"doctrine/dbal": "~2.5",
1212
"ramsey/uuid": "^3"
1313
},

pkg/null/NullConnectionFactory.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
namespace Enqueue\Null;
44

55
use Interop\Queue\PsrConnectionFactory;
6+
use Interop\Queue\PsrContext;
67

78
class NullConnectionFactory implements PsrConnectionFactory
89
{
910
/**
10-
* {@inheritdoc}
11+
* @return NullContext
1112
*/
12-
public function createContext()
13+
public function createContext(): PsrContext
1314
{
1415
return new NullContext();
1516
}

pkg/null/NullConsumer.php

+8-19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Interop\Queue\PsrConsumer;
66
use Interop\Queue\PsrDestination;
77
use Interop\Queue\PsrMessage;
8+
use Interop\Queue\PsrQueue;
89

910
class NullConsumer implements PsrConsumer
1011
{
@@ -13,49 +14,37 @@ class NullConsumer implements PsrConsumer
1314
*/
1415
private $queue;
1516

16-
/**
17-
* @param PsrDestination $queue
18-
*/
1917
public function __construct(PsrDestination $queue)
2018
{
2119
$this->queue = $queue;
2220
}
2321

24-
/**
25-
* {@inheritdoc}
26-
*/
27-
public function getQueue()
22+
public function getQueue(): PsrQueue
2823
{
2924
return $this->queue;
3025
}
3126

3227
/**
33-
* {@inheritdoc}
28+
* @return NullMessage
3429
*/
35-
public function receive($timeout = 0)
30+
public function receive(int $timeout = 0): ?PsrMessage
3631
{
3732
return null;
3833
}
3934

4035
/**
41-
* {@inheritdoc}
36+
* @return NullMessage
4237
*/
43-
public function receiveNoWait()
38+
public function receiveNoWait(): ?PsrMessage
4439
{
4540
return null;
4641
}
4742

48-
/**
49-
* {@inheritdoc}
50-
*/
51-
public function acknowledge(PsrMessage $message)
43+
public function acknowledge(PsrMessage $message): void
5244
{
5345
}
5446

55-
/**
56-
* {@inheritdoc}
57-
*/
58-
public function reject(PsrMessage $message, $requeue = false)
47+
public function reject(PsrMessage $message, bool $requeue = false): void
5948
{
6049
}
6150
}

pkg/null/NullContext.php

+25-18
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@
22

33
namespace Enqueue\Null;
44

5+
use Interop\Queue\PsrConsumer;
56
use Interop\Queue\PsrContext;
67
use Interop\Queue\PsrDestination;
8+
use Interop\Queue\PsrMessage;
9+
use Interop\Queue\PsrProducer;
10+
use Interop\Queue\PsrQueue;
11+
use Interop\Queue\PsrSubscriptionConsumer;
12+
use Interop\Queue\PsrTopic;
713

814
class NullContext implements PsrContext
915
{
1016
/**
11-
* {@inheritdoc}
12-
*
1317
* @return NullMessage
1418
*/
15-
public function createMessage($body = null, array $properties = [], array $headers = [])
19+
public function createMessage(string $body = '', array $properties = [], array $headers = []): PsrMessage
1620
{
1721
$message = new NullMessage();
1822
$message->setBody($body);
@@ -23,55 +27,58 @@ public function createMessage($body = null, array $properties = [], array $heade
2327
}
2428

2529
/**
26-
* {@inheritdoc}
27-
*
2830
* @return NullQueue
2931
*/
30-
public function createQueue($name)
32+
public function createQueue(string $name): PsrQueue
3133
{
3234
return new NullQueue($name);
3335
}
3436

3537
/**
36-
* {@inheritdoc}
38+
* @return NullQueue
3739
*/
38-
public function createTemporaryQueue()
40+
public function createTemporaryQueue(): PsrQueue
3941
{
4042
return $this->createQueue(uniqid('', true));
4143
}
4244

4345
/**
44-
* {@inheritdoc}
45-
*
4646
* @return NullTopic
4747
*/
48-
public function createTopic($name)
48+
public function createTopic(string $name): PsrTopic
4949
{
5050
return new NullTopic($name);
5151
}
5252

5353
/**
54-
* {@inheritdoc}
55-
*
5654
* @return NullConsumer
5755
*/
58-
public function createConsumer(PsrDestination $destination)
56+
public function createConsumer(PsrDestination $destination): PsrConsumer
5957
{
6058
return new NullConsumer($destination);
6159
}
6260

6361
/**
64-
* {@inheritdoc}
62+
* @return NullProducer
6563
*/
66-
public function createProducer()
64+
public function createProducer(): PsrProducer
6765
{
6866
return new NullProducer();
6967
}
7068

7169
/**
72-
* {@inheritdoc}
70+
* @return NullSubscriptionConsumer
7371
*/
74-
public function close()
72+
public function createSubscriptionConsumer(): PsrSubscriptionConsumer
73+
{
74+
return new NullSubscriptionConsumer();
75+
}
76+
77+
public function purgeQueue(PsrQueue $queue): void
78+
{
79+
}
80+
81+
public function close(): void
7582
{
7683
}
7784
}

pkg/null/NullMessage.php

+21-81
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class NullMessage implements PsrMessage
2626
*/
2727
private $redelivered;
2828

29-
public function __construct($body = '', array $properties = [], array $headers = [])
29+
public function __construct(string $body = '', array $properties = [], array $headers = [])
3030
{
3131
$this->body = $body;
3232
$this->properties = $properties;
@@ -35,173 +35,113 @@ public function __construct($body = '', array $properties = [], array $headers =
3535
$this->redelivered = false;
3636
}
3737

38-
/**
39-
* {@inheritdoc}
40-
*/
41-
public function setBody($body)
38+
public function setBody(string $body): void
4239
{
4340
$this->body = $body;
4441
}
4542

46-
/**
47-
* {@inheritdoc}
48-
*/
49-
public function getBody()
43+
public function getBody(): string
5044
{
5145
return $this->body;
5246
}
5347

54-
/**
55-
* {@inheritdoc}
56-
*/
57-
public function setProperties(array $properties)
48+
public function setProperties(array $properties): void
5849
{
5950
$this->properties = $properties;
6051
}
6152

62-
/**
63-
* {@inheritdoc}
64-
*/
65-
public function getProperties()
53+
public function getProperties(): array
6654
{
6755
return $this->properties;
6856
}
6957

70-
/**
71-
* {@inheritdoc}
72-
*/
73-
public function setProperty($name, $value)
58+
public function setProperty(string $name, $value): void
7459
{
7560
$this->properties[$name] = $value;
7661
}
7762

78-
/**
79-
* {@inheritdoc}
80-
*/
81-
public function getProperty($name, $default = null)
63+
public function getProperty(string $name, $default = null)
8264
{
8365
return array_key_exists($name, $this->properties) ? $this->properties[$name] : $default;
8466
}
8567

86-
/**
87-
* {@inheritdoc}
88-
*/
89-
public function setHeaders(array $headers)
68+
public function setHeaders(array $headers): void
9069
{
9170
$this->headers = $headers;
9271
}
9372

94-
/**
95-
* {@inheritdoc}
96-
*/
97-
public function getHeaders()
73+
public function getHeaders(): array
9874
{
9975
return $this->headers;
10076
}
10177

102-
/**
103-
* {@inheritdoc}
104-
*/
105-
public function setHeader($name, $value)
78+
public function setHeader(string $name, $value): void
10679
{
10780
$this->headers[$name] = $value;
10881
}
10982

110-
/**
111-
* {@inheritdoc}
112-
*/
113-
public function getHeader($name, $default = null)
83+
public function getHeader(string $name, $default = null)
11484
{
11585
return array_key_exists($name, $this->headers) ? $this->headers[$name] : $default;
11686
}
11787

118-
/**
119-
* {@inheritdoc}
120-
*/
121-
public function isRedelivered()
88+
public function isRedelivered(): bool
12289
{
12390
return $this->redelivered;
12491
}
12592

126-
/**
127-
* {@inheritdoc}
128-
*/
129-
public function setRedelivered($redelivered)
93+
public function setRedelivered(bool $redelivered): void
13094
{
13195
$this->redelivered = $redelivered;
13296
}
13397

134-
/**
135-
* {@inheritdoc}
136-
*/
137-
public function setCorrelationId($correlationId)
98+
public function setCorrelationId(string $correlationId = null): void
13899
{
139100
$headers = $this->getHeaders();
140101
$headers['correlation_id'] = (string) $correlationId;
141102

142103
$this->setHeaders($headers);
143104
}
144105

145-
/**
146-
* {@inheritdoc}
147-
*/
148-
public function getCorrelationId()
106+
public function getCorrelationId(): ?string
149107
{
150108
return $this->getHeader('correlation_id');
151109
}
152110

153-
/**
154-
* {@inheritdoc}
155-
*/
156-
public function setMessageId($messageId)
111+
public function setMessageId(string $messageId = null): void
157112
{
158113
$headers = $this->getHeaders();
159114
$headers['message_id'] = (string) $messageId;
160115

161116
$this->setHeaders($headers);
162117
}
163118

164-
/**
165-
* {@inheritdoc}
166-
*/
167-
public function getMessageId()
119+
public function getMessageId(): ?string
168120
{
169121
return $this->getHeader('message_id');
170122
}
171123

172-
/**
173-
* {@inheritdoc}
174-
*/
175-
public function getTimestamp()
124+
public function getTimestamp(): ?int
176125
{
177126
$value = $this->getHeader('timestamp');
178127

179128
return null === $value ? null : (int) $value;
180129
}
181130

182-
/**
183-
* {@inheritdoc}
184-
*/
185-
public function setTimestamp($timestamp)
131+
public function setTimestamp(int $timestamp = null): void
186132
{
187133
$headers = $this->getHeaders();
188134
$headers['timestamp'] = (int) $timestamp;
189135

190136
$this->setHeaders($headers);
191137
}
192138

193-
/**
194-
* @param string|null $replyTo
195-
*/
196-
public function setReplyTo($replyTo)
139+
public function setReplyTo(string $replyTo = null): void
197140
{
198141
$this->setHeader('reply_to', $replyTo);
199142
}
200143

201-
/**
202-
* @return string|null
203-
*/
204-
public function getReplyTo()
144+
public function getReplyTo(): ?string
205145
{
206146
return $this->getHeader('reply_to');
207147
}

0 commit comments

Comments
 (0)