Skip to content

Commit a57bd9b

Browse files
committed
Running php-cs-fixer
Running php-cs-fixer to fix CS drift
1 parent dc8d691 commit a57bd9b

23 files changed

+29
-98
lines changed

JSON.php

+7-20
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ class JSON
1414
public static function decode($string)
1515
{
1616
if (!is_string($string)) {
17-
throw new \InvalidArgumentException(sprintf(
18-
'Accept only string argument but got: "%s"',
19-
is_object($string) ? get_class($string) : gettype($string)
20-
));
17+
throw new \InvalidArgumentException(sprintf('Accept only string argument but got: "%s"', is_object($string) ? $string::class : gettype($string)));
2118
}
2219

2320
// PHP7 fix - empty string and null cause syntax error
@@ -26,32 +23,22 @@ public static function decode($string)
2623
}
2724

2825
$decoded = json_decode($string, true);
29-
if (JSON_ERROR_NONE !== json_last_error()) {
30-
throw new \InvalidArgumentException(sprintf(
31-
'The malformed json given. Error %s and message %s',
32-
json_last_error(),
33-
json_last_error_msg()
34-
));
26+
if (\JSON_ERROR_NONE !== json_last_error()) {
27+
throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
3528
}
3629

3730
return $decoded;
3831
}
3932

4033
/**
41-
* @param mixed $value
42-
*
4334
* @return string
4435
*/
4536
public static function encode($value)
4637
{
47-
$encoded = json_encode($value, JSON_UNESCAPED_UNICODE);
48-
49-
if (JSON_ERROR_NONE !== json_last_error()) {
50-
throw new \InvalidArgumentException(sprintf(
51-
'Could not encode value into json. Error %s and message %s',
52-
json_last_error(),
53-
json_last_error_msg()
54-
));
38+
$encoded = json_encode($value, \JSON_UNESCAPED_UNICODE);
39+
40+
if (\JSON_ERROR_NONE !== json_last_error()) {
41+
throw new \InvalidArgumentException(sprintf('Could not encode value into json. Error %s and message %s', json_last_error(), json_last_error_msg()));
5542
}
5643

5744
return $encoded;

MongodbConnectionFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ public static function parseDsn(string $dsn): array
8989
// see: https://github.com/php-enqueue/enqueue-dev/issues/1027
9090
if (isset($parsedUrl['path']) && '/' !== $parsedUrl['path']) {
9191
$pathParts = explode('/', $parsedUrl['path']);
92-
//DB name
92+
// DB name
9393
if ($pathParts[1]) {
9494
$config['dbname'] = $pathParts[1];
9595
}
9696
}
9797
if (isset($parsedUrl['query'])) {
9898
$queryParts = null;
9999
parse_str($parsedUrl['query'], $queryParts);
100-
//get enqueue attributes values
100+
// get enqueue attributes values
101101
if (!empty($queryParts['polling_interval'])) {
102102
$config['polling_interval'] = (int) $queryParts['polling_interval'];
103103
}

MongodbMessage.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function __construct(string $body = '', array $properties = [], array $he
6565
$this->redelivered = false;
6666
}
6767

68-
public function setId(string $id = null): void
68+
public function setId(?string $id = null): void
6969
{
7070
$this->id = $id;
7171
}
@@ -135,7 +135,7 @@ public function setRedelivered(bool $redelivered): void
135135
$this->redelivered = $redelivered;
136136
}
137137

138-
public function setReplyTo(string $replyTo = null): void
138+
public function setReplyTo(?string $replyTo = null): void
139139
{
140140
$this->setHeader('reply_to', $replyTo);
141141
}
@@ -150,7 +150,7 @@ public function getPriority(): ?int
150150
return $this->priority;
151151
}
152152

153-
public function setPriority(int $priority = null): void
153+
public function setPriority(?int $priority = null): void
154154
{
155155
$this->priority = $priority;
156156
}
@@ -163,7 +163,7 @@ public function getDeliveryDelay(): ?int
163163
/**
164164
* In milliseconds.
165165
*/
166-
public function setDeliveryDelay(int $deliveryDelay = null): void
166+
public function setDeliveryDelay(?int $deliveryDelay = null): void
167167
{
168168
$this->deliveryDelay = $deliveryDelay;
169169
}
@@ -176,12 +176,12 @@ public function getTimeToLive(): ?int
176176
/**
177177
* In milliseconds.
178178
*/
179-
public function setTimeToLive(int $timeToLive = null): void
179+
public function setTimeToLive(?int $timeToLive = null): void
180180
{
181181
$this->timeToLive = $timeToLive;
182182
}
183183

184-
public function setCorrelationId(string $correlationId = null): void
184+
public function setCorrelationId(?string $correlationId = null): void
185185
{
186186
$this->setHeader('correlation_id', $correlationId);
187187
}
@@ -191,7 +191,7 @@ public function getCorrelationId(): ?string
191191
return $this->getHeader('correlation_id', null);
192192
}
193193

194-
public function setMessageId(string $messageId = null): void
194+
public function setMessageId(?string $messageId = null): void
195195
{
196196
$this->setHeader('message_id', $messageId);
197197
}
@@ -208,7 +208,7 @@ public function getTimestamp(): ?int
208208
return null === $value ? null : (int) $value;
209209
}
210210

211-
public function setTimestamp(int $timestamp = null): void
211+
public function setTimestamp(?int $timestamp = null): void
212212
{
213213
$this->setHeader('timestamp', $timestamp);
214214
}
@@ -221,7 +221,7 @@ public function getPublishedAt(): ?int
221221
/**
222222
* In milliseconds.
223223
*/
224-
public function setPublishedAt(int $publishedAt = null): void
224+
public function setPublishedAt(?int $publishedAt = null): void
225225
{
226226
$this->publishedAt = $publishedAt;
227227
}

MongodbProducer.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function send(Destination $destination, Message $message): void
7777
$delay = $message->getDeliveryDelay();
7878
if ($delay) {
7979
if (!is_int($delay)) {
80-
throw new \LogicException(sprintf('Delay must be integer but got: "%s"', is_object($delay) ? get_class($delay) : gettype($delay)));
80+
throw new \LogicException(sprintf('Delay must be integer but got: "%s"', is_object($delay) ? $delay::class : gettype($delay)));
8181
}
8282

8383
if ($delay <= 0) {
@@ -90,7 +90,7 @@ public function send(Destination $destination, Message $message): void
9090
$timeToLive = $message->getTimeToLive();
9191
if ($timeToLive) {
9292
if (!is_int($timeToLive)) {
93-
throw new \LogicException(sprintf('TimeToLive must be integer but got: "%s"', is_object($timeToLive) ? get_class($timeToLive) : gettype($timeToLive)));
93+
throw new \LogicException(sprintf('TimeToLive must be integer but got: "%s"', is_object($timeToLive) ? $timeToLive::class : gettype($timeToLive)));
9494
}
9595

9696
if ($timeToLive <= 0) {
@@ -111,7 +111,7 @@ public function send(Destination $destination, Message $message): void
111111
/**
112112
* @return self
113113
*/
114-
public function setDeliveryDelay(int $deliveryDelay = null): Producer
114+
public function setDeliveryDelay(?int $deliveryDelay = null): Producer
115115
{
116116
$this->deliveryDelay = $deliveryDelay;
117117

@@ -126,7 +126,7 @@ public function getDeliveryDelay(): ?int
126126
/**
127127
* @return self
128128
*/
129-
public function setPriority(int $priority = null): Producer
129+
public function setPriority(?int $priority = null): Producer
130130
{
131131
$this->priority = $priority;
132132

@@ -141,7 +141,7 @@ public function getPriority(): ?int
141141
/**
142142
* @return self
143143
*/
144-
public function setTimeToLive(int $timeToLive = null): Producer
144+
public function setTimeToLive(?int $timeToLive = null): Producer
145145
{
146146
$this->timeToLive = $timeToLive;
147147

MongodbSubscriptionConsumer.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ class MongodbSubscriptionConsumer implements SubscriptionConsumer
2121
*/
2222
private $subscribers;
2323

24-
/**
25-
* @param MongodbContext $context
26-
*/
2724
public function __construct(MongodbContext $context)
2825
{
2926
$this->context = $context;
@@ -92,7 +89,7 @@ public function consume(int $timeout = 0): void
9289
public function subscribe(Consumer $consumer, callable $callback): void
9390
{
9491
if (false == $consumer instanceof MongodbConsumer) {
95-
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', MongodbConsumer::class, get_class($consumer)));
92+
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', MongodbConsumer::class, $consumer::class));
9693
}
9794

9895
$queueName = $consumer->getQueue()->getQueueName();
@@ -113,7 +110,7 @@ public function subscribe(Consumer $consumer, callable $callback): void
113110
public function unsubscribe(Consumer $consumer): void
114111
{
115112
if (false == $consumer instanceof MongodbConsumer) {
116-
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', MongodbConsumer::class, get_class($consumer)));
113+
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', MongodbConsumer::class, $consumer::class));
117114
}
118115

119116
$queueName = $consumer->getQueue()->getQueueName();

Tests/MongodbConsumerTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function isRedelivered(): bool
181181
throw new \BadMethodCallException('This should not be called directly');
182182
}
183183

184-
public function setCorrelationId(string $correlationId = null): void
184+
public function setCorrelationId(?string $correlationId = null): void
185185
{
186186
}
187187

@@ -190,7 +190,7 @@ public function getCorrelationId(): ?string
190190
throw new \BadMethodCallException('This should not be called directly');
191191
}
192192

193-
public function setMessageId(string $messageId = null): void
193+
public function setMessageId(?string $messageId = null): void
194194
{
195195
}
196196

@@ -204,11 +204,11 @@ public function getTimestamp(): ?int
204204
throw new \BadMethodCallException('This should not be called directly');
205205
}
206206

207-
public function setTimestamp(int $timestamp = null): void
207+
public function setTimestamp(?int $timestamp = null): void
208208
{
209209
}
210210

211-
public function setReplyTo(string $replyTo = null): void
211+
public function setReplyTo(?string $replyTo = null): void
212212
{
213213
}
214214

Tests/Spec/MongodbConnectionFactoryTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
*/
1111
class MongodbConnectionFactoryTest extends ConnectionFactorySpec
1212
{
13-
/**
14-
* {@inheritdoc}
15-
*/
1613
protected function createConnectionFactory()
1714
{
1815
return new MongodbConnectionFactory();

Tests/Spec/MongodbContextTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ class MongodbContextTest extends ContextSpec
1313
{
1414
use MongodbExtensionTrait;
1515

16-
/**
17-
* {@inheritdoc}
18-
*/
1916
protected function createContext()
2017
{
2118
return $this->buildMongodbContext();

Tests/Spec/MongodbMessageTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
*/
1111
class MongodbMessageTest extends MessageSpec
1212
{
13-
/**
14-
* {@inheritdoc}
15-
*/
1613
protected function createMessage()
1714
{
1815
return new MongodbMessage();

Tests/Spec/MongodbProducerTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ class MongodbProducerTest extends ProducerSpec
1313
{
1414
use MongodbExtensionTrait;
1515

16-
/**
17-
* {@inheritdoc}
18-
*/
1916
protected function createProducer()
2017
{
2118
return $this->buildMongodbContext()->createProducer();

Tests/Spec/MongodbQueueTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
*/
1111
class MongodbQueueTest extends QueueSpec
1212
{
13-
/**
14-
* {@inheritdoc}
15-
*/
1613
protected function createQueue()
1714
{
1815
return new MongodbDestination(self::EXPECTED_QUEUE_NAME);

Tests/Spec/MongodbRequeueMessageTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ class MongodbRequeueMessageTest extends RequeueMessageSpec
1313
{
1414
use MongodbExtensionTrait;
1515

16-
/**
17-
* {@inheritdoc}
18-
*/
1916
protected function createContext()
2017
{
2118
return $this->buildMongodbContext();

Tests/Spec/MongodbSendAndReceiveDelayedMessageFromQueueTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ class MongodbSendAndReceiveDelayedMessageFromQueueTest extends SendAndReceiveDel
1313
{
1414
use MongodbExtensionTrait;
1515

16-
/**
17-
* {@inheritdoc}
18-
*/
1916
protected function createContext()
2017
{
2118
return $this->buildMongodbContext();

Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php

-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ protected function createContext()
3434
}
3535

3636
/**
37-
* {@inheritdoc}
38-
*
3937
* @param MongodbContext $context
4038
*
4139
* @return MongodbMessage

Tests/Spec/MongodbSendAndReceiveTimeToLiveMessagesFromQueueTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ class MongodbSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiv
1313
{
1414
use MongodbExtensionTrait;
1515

16-
/**
17-
* {@inheritdoc}
18-
*/
1916
protected function createContext()
2017
{
2118
return $this->buildMongodbContext();

Tests/Spec/MongodbSendToAndReceiveFromQueueTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ class MongodbSendToAndReceiveFromQueueTest extends SendToAndReceiveFromQueueSpec
1313
{
1414
use MongodbExtensionTrait;
1515

16-
/**
17-
* {@inheritdoc}
18-
*/
1916
protected function createContext()
2017
{
2118
return $this->buildMongodbContext();

Tests/Spec/MongodbSendToAndReceiveFromTopicTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ class MongodbSendToAndReceiveFromTopicTest extends SendToAndReceiveFromTopicSpec
1313
{
1414
use MongodbExtensionTrait;
1515

16-
/**
17-
* {@inheritdoc}
18-
*/
1916
protected function createContext()
2017
{
2118
return $this->buildMongodbContext();

Tests/Spec/MongodbSendToAndReceiveNoWaitFromQueueTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ class MongodbSendToAndReceiveNoWaitFromQueueTest extends SendToAndReceiveNoWaitF
1313
{
1414
use MongodbExtensionTrait;
1515

16-
/**
17-
* {@inheritdoc}
18-
*/
1916
protected function createContext()
2017
{
2118
return $this->buildMongodbContext();

Tests/Spec/MongodbSendToAndReceiveNoWaitFromTopicTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ class MongodbSendToAndReceiveNoWaitFromTopicTest extends SendToAndReceiveNoWaitF
1313
{
1414
use MongodbExtensionTrait;
1515

16-
/**
17-
* {@inheritdoc}
18-
*/
1916
protected function createContext()
2017
{
2118
return $this->buildMongodbContext();

Tests/Spec/MongodbSubscriptionConsumerConsumeFromAllSubscribedQueuesTest.php

-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ class MongodbSubscriptionConsumerConsumeFromAllSubscribedQueuesTest extends Subs
2020

2121
/**
2222
* @return MongodbContext
23-
*
24-
* {@inheritdoc}
2523
*/
2624
protected function createContext()
2725
{
@@ -30,8 +28,6 @@ protected function createContext()
3028

3129
/**
3230
* @param MongodbContext $context
33-
*
34-
* {@inheritdoc}
3531
*/
3632
protected function createQueue(Context $context, $queueName)
3733
{

0 commit comments

Comments
 (0)