Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c07db8c

Browse files
committed
Merge remote-tracking branch 'origin/master' into merge08
2 parents 3d0e5f3 + 52c95dd commit c07db8c

21 files changed

+190
-316
lines changed

‎.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ git:
66
language: php
77

88
php:
9-
- '5.6'
10-
- '7.0'
9+
- '7.1'
10+
- '7.2'
1111

1212
cache:
1313
directories:

‎PheanstalkConnectionFactory.php

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Enqueue\Pheanstalk;
46

5-
use Interop\Queue\PsrConnectionFactory;
7+
use Interop\Queue\ConnectionFactory;
8+
use Interop\Queue\Context;
69
use Pheanstalk\Pheanstalk;
710

8-
class PheanstalkConnectionFactory implements PsrConnectionFactory
11+
class PheanstalkConnectionFactory implements ConnectionFactory
912
{
1013
/**
1114
* @var array
@@ -49,19 +52,14 @@ public function __construct($config = 'beanstalk:')
4952
}
5053

5154
/**
52-
* {@inheritdoc}
53-
*
5455
* @return PheanstalkContext
5556
*/
56-
public function createContext()
57+
public function createContext(): Context
5758
{
5859
return new PheanstalkContext($this->establishConnection());
5960
}
6061

61-
/**
62-
* @return Pheanstalk
63-
*/
64-
private function establishConnection()
62+
private function establishConnection(): Pheanstalk
6563
{
6664
if (false == $this->connection) {
6765
$this->connection = new Pheanstalk(
@@ -75,12 +73,7 @@ private function establishConnection()
7573
return $this->connection;
7674
}
7775

78-
/**
79-
* @param string $dsn
80-
*
81-
* @return array
82-
*/
83-
private function parseDsn($dsn)
76+
private function parseDsn(string $dsn): array
8477
{
8578
$dsnConfig = parse_url($dsn);
8679
if (false === $dsnConfig) {
@@ -112,10 +105,7 @@ private function parseDsn($dsn)
112105
]);
113106
}
114107

115-
/**
116-
* @return array
117-
*/
118-
private function defaultConfig()
108+
private function defaultConfig(): array
119109
{
120110
return [
121111
'host' => 'localhost',

‎PheanstalkConsumer.php

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Enqueue\Pheanstalk;
46

5-
use Interop\Queue\InvalidMessageException;
6-
use Interop\Queue\PsrConsumer;
7-
use Interop\Queue\PsrMessage;
7+
use Interop\Queue\Consumer;
8+
use Interop\Queue\Exception\InvalidMessageException;
9+
use Interop\Queue\Message;
10+
use Interop\Queue\Queue;
811
use Pheanstalk\Job;
912
use Pheanstalk\Pheanstalk;
1013

11-
class PheanstalkConsumer implements PsrConsumer
14+
class PheanstalkConsumer implements Consumer
1215
{
1316
/**
1417
* @var PheanstalkDestination
@@ -20,32 +23,24 @@ class PheanstalkConsumer implements PsrConsumer
2023
*/
2124
private $pheanstalk;
2225

23-
/**
24-
* @param PheanstalkDestination $destination
25-
* @param Pheanstalk $pheanstalk
26-
*/
2726
public function __construct(PheanstalkDestination $destination, Pheanstalk $pheanstalk)
2827
{
2928
$this->destination = $destination;
3029
$this->pheanstalk = $pheanstalk;
3130
}
3231

3332
/**
34-
* {@inheritdoc}
35-
*
3633
* @return PheanstalkDestination
3734
*/
38-
public function getQueue()
35+
public function getQueue(): Queue
3936
{
4037
return $this->destination;
4138
}
4239

4340
/**
44-
* {@inheritdoc}
45-
*
46-
* @return PheanstalkMessage|null
41+
* @return PheanstalkMessage
4742
*/
48-
public function receive($timeout = 0)
43+
public function receive(int$timeout = 0): ?Message
4944
{
5045
if (0 === $timeout) {
5146
while (true) {
@@ -58,26 +53,26 @@ public function receive($timeout = 0)
5853
return $this->convertJobToMessage($job);
5954
}
6055
}
56+
57+
return null;
6158
}
6259

6360
/**
64-
* {@inheritdoc}
65-
*
66-
* @return PheanstalkMessage|null
61+
* @return PheanstalkMessage
6762
*/
68-
public function receiveNoWait()
63+
public function receiveNoWait(): ?Message
6964
{
7065
if ($job = $this->pheanstalk->reserveFromTube($this->destination->getName(), 0)) {
7166
return $this->convertJobToMessage($job);
7267
}
68+
69+
return null;
7370
}
7471

7572
/**
76-
* {@inheritdoc}
77-
*
7873
* @param PheanstalkMessage $message
7974
*/
80-
public function acknowledge(PsrMessage $message)
75+
public function acknowledge(Message $message): void
8176
{
8277
InvalidMessageException::assertMessageInstanceOf($message, PheanstalkMessage::class);
8378

@@ -89,11 +84,9 @@ public function acknowledge(PsrMessage $message)
8984
}
9085

9186
/**
92-
* {@inheritdoc}
93-
*
9487
* @param PheanstalkMessage $message
9588
*/
96-
public function reject(PsrMessage $message, $requeue = false)
89+
public function reject(Message $message, bool$requeue = false): void
9790
{
9891
$this->acknowledge($message);
9992

@@ -102,12 +95,7 @@ public function reject(PsrMessage $message, $requeue = false)
10295
}
10396
}
10497

105-
/**
106-
* @param Job $job
107-
*
108-
* @return PheanstalkMessage
109-
*/
110-
private function convertJobToMessage(Job $job)
98+
private function convertJobToMessage(Job $job): PheanstalkMessage
11199
{
112100
$stats = $this->pheanstalk->statsJob($job);
113101

‎PheanstalkContext.php

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,100 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Enqueue\Pheanstalk;
46

5-
use Interop\Queue\InvalidDestinationException;
6-
use Interop\Queue\PsrContext;
7-
use Interop\Queue\PsrDestination;
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;
819
use Pheanstalk\Pheanstalk;
920

10-
class PheanstalkContext implements PsrContext
21+
class PheanstalkContext implements Context
1122
{
1223
/**
1324
* @var Pheanstalk
1425
*/
1526
private $pheanstalk;
1627

17-
/**
18-
* @param Pheanstalk $pheanstalk
19-
*/
2028
public function __construct(Pheanstalk $pheanstalk)
2129
{
2230
$this->pheanstalk = $pheanstalk;
2331
}
2432

2533
/**
26-
* {@inheritdoc}
34+
* @return PheanstalkMessage
2735
*/
28-
public function createMessage($body = '', array $properties = [], array $headers = [])
36+
public function createMessage(string$body = '', array $properties = [], array $headers = []): Message
2937
{
3038
return new PheanstalkMessage($body, $properties, $headers);
3139
}
3240

3341
/**
34-
* {@inheritdoc}
42+
* @return PheanstalkDestination
3543
*/
36-
public function createTopic($topicName)
44+
public function createTopic(string$topicName): Topic
3745
{
3846
return new PheanstalkDestination($topicName);
3947
}
4048

4149
/**
42-
* {@inheritdoc}
50+
* @return PheanstalkDestination
4351
*/
44-
public function createQueue($queueName)
52+
public function createQueue(string$queueName): Queue
4553
{
4654
return new PheanstalkDestination($queueName);
4755
}
4856

49-
/**
50-
* {@inheritdoc}
51-
*/
52-
public function createTemporaryQueue()
57+
public function createTemporaryQueue(): Queue
5358
{
54-
throw new \LogicException('Not implemented');
59+
throw TemporaryQueueNotSupportedException::providerDoestNotSupportIt();
5560
}
5661

5762
/**
58-
* {@inheritdoc}
59-
*
6063
* @return PheanstalkProducer
6164
*/
62-
public function createProducer()
65+
public function createProducer(): Producer
6366
{
6467
return new PheanstalkProducer($this->pheanstalk);
6568
}
6669

6770
/**
68-
* {@inheritdoc}
69-
*
7071
* @param PheanstalkDestination $destination
7172
*
7273
* @return PheanstalkConsumer
7374
*/
74-
public function createConsumer(PsrDestination $destination)
75+
public function createConsumer(Destination $destination): Consumer
7576
{
7677
InvalidDestinationException::assertDestinationInstanceOf($destination, PheanstalkDestination::class);
7778

7879
return new PheanstalkConsumer($destination, $this->pheanstalk);
7980
}
8081

81-
public function close()
82+
public function close(): void
8283
{
8384
$this->pheanstalk->getConnection()->disconnect();
8485
}
8586

86-
/**
87-
* @return Pheanstalk
88-
*/
89-
public function getPheanstalk()
87+
public function createSubscriptionConsumer(): SubscriptionConsumer
88+
{
89+
throw SubscriptionConsumerNotSupportedException::providerDoestNotSupportIt();
90+
}
91+
92+
public function purgeQueue(Queue $queue): void
93+
{
94+
throw PurgeQueueNotSupportedException::providerDoestNotSupportIt();
95+
}
96+
97+
public function getPheanstalk(): Pheanstalk
9098
{
9199
return $this->pheanstalk;
92100
}

‎PheanstalkDestination.php

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,36 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Enqueue\Pheanstalk;
46

5-
use Interop\Queue\PsrQueue;
6-
use Interop\Queue\PsrTopic;
7+
use Interop\Queue\Queue;
8+
use Interop\Queue\Topic;
79

8-
class PheanstalkDestination implements PsrQueue, PsrTopic
10+
class PheanstalkDestination implements Queue, Topic
911
{
1012
/**
1113
* @var string
1214
*/
1315
private $destinationName;
1416

15-
/**
16-
* @param string $destinationName
17-
*/
18-
public function __construct($destinationName)
17+
public function __construct(string $destinationName)
1918
{
2019
$this->destinationName = $destinationName;
2120
}
2221

23-
/**
24-
* @return string
25-
*/
26-
public function getName()
22+
public function getName(): string
2723
{
2824
return $this->destinationName;
2925
}
3026

31-
/**
32-
* {@inheritdoc}
33-
*/
34-
public function getQueueName()
27+
public function getQueueName(): string
3528
{
36-
return $this->getName();
29+
return $this->destinationName;
3730
}
3831

39-
/**
40-
* {@inheritdoc}
41-
*/
42-
public function getTopicName()
32+
public function getTopicName(): string
4333
{
44-
return $this->getName();
34+
return $this->destinationName;
4535
}
4636
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /