Skip to content

Commit 54a7846

Browse files
committed
Running php-cs-fixer
Running php-cs-fixer to fix CS drift
1 parent 14bde94 commit 54a7846

14 files changed

+23
-56
lines changed

FsConnectionFactory.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ private function parseDsn(string $dsn): array
7474

7575
$supportedSchemes = ['file'];
7676
if (false == in_array($dsn->getSchemeProtocol(), $supportedSchemes, true)) {
77-
throw new \LogicException(sprintf(
78-
'The given scheme protocol "%s" is not supported. It must be one of "%s"',
79-
$dsn->getSchemeProtocol(),
80-
implode('", "', $supportedSchemes)
81-
));
77+
throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be one of "%s"', $dsn->getSchemeProtocol(), implode('", "', $supportedSchemes)));
8278
}
8379

8480
return array_filter(array_replace($dsn->getQuery(), [

FsConsumer.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function receiveNoWait(): ?Message
112112
while ($count) {
113113
$frame = $this->readFrame($file, 1);
114114

115-
//guards
115+
// guards
116116
if ($frame && false == ('|' == $frame[0] || ' ' == $frame[0])) {
117117
throw new \LogicException(sprintf('The frame could start from either " " or "|". The malformed frame starts with "%s".', $frame[0]));
118118
}
@@ -188,13 +188,13 @@ private function readFrame($file, int $frameNumber): string
188188
$frameSize = 64;
189189
$offset = $frameNumber * $frameSize;
190190

191-
fseek($file, -$offset, SEEK_END);
191+
fseek($file, -$offset, \SEEK_END);
192192
$frame = fread($file, $frameSize);
193193
if ('' == $frame) {
194194
return '';
195195
}
196196

197-
if (false !== strpos($frame, '|{')) {
197+
if (str_contains($frame, '|{')) {
198198
return $frame;
199199
}
200200

FsContext.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function createQueue(string $queueName): Queue
8383

8484
public function declareDestination(FsDestination $destination): void
8585
{
86-
//InvalidDestinationException::assertDestinationInstanceOf($destination, FsDestination::class);
86+
// InvalidDestinationException::assertDestinationInstanceOf($destination, FsDestination::class);
8787

8888
set_error_handler(function ($severity, $message, $file, $line) {
8989
throw new \ErrorException($message, 0, $severity, $file, $line);
@@ -105,7 +105,7 @@ public function workWithFile(FsDestination $destination, string $mode, callable
105105

106106
set_error_handler(function ($severity, $message, $file, $line) {
107107
throw new \ErrorException($message, 0, $severity, $file, $line);
108-
}, E_ALL & ~E_USER_DEPRECATED);
108+
}, \E_ALL & ~\E_USER_DEPRECATED);
109109

110110
try {
111111
$file = fopen((string) $destination->getFileInfo(), $mode);

FsMessage.php

+6-10
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function setRedelivered(bool $redelivered): void
9696
$this->redelivered = $redelivered;
9797
}
9898

99-
public function setCorrelationId(string $correlationId = null): void
99+
public function setCorrelationId(?string $correlationId = null): void
100100
{
101101
$this->setHeader('correlation_id', (string) $correlationId);
102102
}
@@ -106,7 +106,7 @@ public function getCorrelationId(): ?string
106106
return $this->getHeader('correlation_id');
107107
}
108108

109-
public function setMessageId(string $messageId = null): void
109+
public function setMessageId(?string $messageId = null): void
110110
{
111111
$this->setHeader('message_id', (string) $messageId);
112112
}
@@ -123,12 +123,12 @@ public function getTimestamp(): ?int
123123
return null === $value ? null : (int) $value;
124124
}
125125

126-
public function setTimestamp(int $timestamp = null): void
126+
public function setTimestamp(?int $timestamp = null): void
127127
{
128128
$this->setHeader('timestamp', $timestamp);
129129
}
130130

131-
public function setReplyTo(string $replyTo = null): void
131+
public function setReplyTo(?string $replyTo = null): void
132132
{
133133
$this->setHeader('reply_to', $replyTo);
134134
}
@@ -150,12 +150,8 @@ public function jsonSerialize(): array
150150
public static function jsonUnserialize(string $json): self
151151
{
152152
$data = json_decode($json, true);
153-
if (JSON_ERROR_NONE !== json_last_error()) {
154-
throw new \InvalidArgumentException(sprintf(
155-
'The malformed json given. Error %s and message %s',
156-
json_last_error(),
157-
json_last_error_msg()
158-
));
153+
if (\JSON_ERROR_NONE !== json_last_error()) {
154+
throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
159155
}
160156

161157
return new self($data['body'], $data['properties'], $data['headers']);

FsProducer.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,8 @@ public function send(Destination $destination, Message $message): void
5353
$rawMessage = str_replace('|{', '\|\{', $rawMessage);
5454
$rawMessage = '|'.$rawMessage;
5555

56-
if (JSON_ERROR_NONE !== json_last_error()) {
57-
throw new \InvalidArgumentException(sprintf(
58-
'Could not encode value into json. Error %s and message %s',
59-
json_last_error(),
60-
json_last_error_msg()
61-
));
56+
if (\JSON_ERROR_NONE !== json_last_error()) {
57+
throw new \InvalidArgumentException(sprintf('Could not encode value into json. Error %s and message %s', json_last_error(), json_last_error_msg()));
6258
}
6359

6460
$rawMessage = str_repeat(' ', 64 - (strlen($rawMessage) % 64)).$rawMessage;
@@ -67,7 +63,7 @@ public function send(Destination $destination, Message $message): void
6763
});
6864
}
6965

70-
public function setDeliveryDelay(int $deliveryDelay = null): Producer
66+
public function setDeliveryDelay(?int $deliveryDelay = null): Producer
7167
{
7268
if (null === $deliveryDelay) {
7369
return $this;
@@ -81,7 +77,7 @@ public function getDeliveryDelay(): ?int
8177
return null;
8278
}
8379

84-
public function setPriority(int $priority = null): Producer
80+
public function setPriority(?int $priority = null): Producer
8581
{
8682
if (null === $priority) {
8783
return $this;
@@ -95,7 +91,7 @@ public function getPriority(): ?int
9591
return null;
9692
}
9793

98-
public function setTimeToLive(int $timeToLive = null): Producer
94+
public function setTimeToLive(?int $timeToLive = null): Producer
9995
{
10096
$this->timeToLive = $timeToLive;
10197

LegacyFilesystemLock.php

+2-10
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ public function __construct()
1919
$this->lockHandlers = [];
2020
}
2121

22-
/**
23-
* {@inheritdoc}
24-
*/
2522
public function lock(FsDestination $destination)
2623
{
2724
$lockHandler = $this->getLockHandler($destination);
@@ -31,9 +28,6 @@ public function lock(FsDestination $destination)
3128
}
3229
}
3330

34-
/**
35-
* {@inheritdoc}
36-
*/
3731
public function release(FsDestination $destination)
3832
{
3933
$lockHandler = $this->getLockHandler($destination);
@@ -51,8 +45,6 @@ public function releaseAll()
5145
}
5246

5347
/**
54-
* @param FsDestination $destination
55-
*
5648
* @return LockHandler
5749
*/
5850
private function getLockHandler(FsDestination $destination)
@@ -161,7 +153,7 @@ public function lock($blocking = false)
161153

162154
// On Windows, even if PHP doc says the contrary, LOCK_NB works, see
163155
// https://bugs.php.net/54129
164-
if (!flock($this->handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) {
156+
if (!flock($this->handle, \LOCK_EX | ($blocking ? 0 : \LOCK_NB))) {
165157
fclose($this->handle);
166158
$this->handle = null;
167159

@@ -177,7 +169,7 @@ public function lock($blocking = false)
177169
public function release()
178170
{
179171
if ($this->handle) {
180-
flock($this->handle, LOCK_UN | LOCK_NB);
172+
flock($this->handle, \LOCK_UN | \LOCK_NB);
181173
fclose($this->handle);
182174
$this->handle = null;
183175
}

Lock.php

-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,10 @@ interface Lock
1010
* Returns the control If the look has been obtained
1111
* If not, should throw CannotObtainLockException exception.
1212
*
13-
* @param FsDestination $destination
14-
*
1513
* @throws CannotObtainLockException if look could not be obtained
1614
*/
1715
public function lock(FsDestination $destination);
1816

19-
/**
20-
* @param FsDestination $destination
21-
*/
2217
public function release(FsDestination $destination);
2318

2419
public function releaseAll();

Tests/FsConnectionFactoryConfigTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ public function testThrowIfArrayConfigGivenWithEmptyPath()
5151

5252
/**
5353
* @dataProvider provideConfigs
54-
*
55-
* @param mixed $config
56-
* @param mixed $expectedConfig
5754
*/
5855
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
5956
{

Tests/FsMessageTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testCouldBeUnserializedFromJson()
8989

9090
$json = json_encode($message);
9191

92-
//guard
92+
// guard
9393
$this->assertNotEmpty($json);
9494

9595
$unserializedMessage = FsMessage::jsonUnserialize($json);

Tests/Functional/FsCommonUseCasesTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function testConsumerReceiveMessageWithZeroTimeout()
111111
$topic = $this->fsContext->createTopic('fs_test_queue_exchange');
112112

113113
$consumer = $this->fsContext->createConsumer($topic);
114-
//guard
114+
// guard
115115
$this->assertNull($consumer->receive(1000));
116116

117117
$message = $this->fsContext->createMessage(__METHOD__);

Tests/Functional/FsConsumerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function testShouldThrowExceptionWhenFrameSizeNotDivideExactly()
159159

160160
$context->workWithFile($queue, 'a+', function (FsDestination $destination, $file) {
161161
$msg = '|{"body":""}';
162-
//guard
162+
// guard
163163
$this->assertNotSame(0, strlen($msg) % 64);
164164

165165
fwrite($file, $msg);

Tests/Functional/FsContextTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class FsContextTest extends TestCase
1414
*/
1515
private $fsContext;
1616

17-
public function tearDown(): void
17+
protected function tearDown(): void
1818
{
1919
$fs = new Filesystem();
2020
$fs->remove(sys_get_temp_dir().'/enqueue');

Tests/Spec/FsMessageTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
class FsMessageTest extends MessageSpec
99
{
10-
/**
11-
* {@inheritdoc}
12-
*/
1310
protected function createMessage()
1411
{
1512
return new FsMessage();

Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
class FsSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTimeToLiveMessagesFromQueueSpec
1010
{
1111
/**
12-
* {@inheritdoc}
13-
*
1412
* @return FsContext
1513
*/
1614
protected function createContext()

0 commit comments

Comments
 (0)