Skip to content

Commit

Permalink
Running php-cs-fixer
Browse files Browse the repository at this point in the history
Running php-cs-fixer to fix CS drift
  • Loading branch information
JimTools committed Jan 17, 2025
1 parent 14bde94 commit 54a7846
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 56 deletions.
6 changes: 1 addition & 5 deletions FsConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ private function parseDsn(string $dsn): array

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

return array_filter(array_replace($dsn->getQuery(), [
Expand Down
6 changes: 3 additions & 3 deletions FsConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function receiveNoWait(): ?Message
while ($count) {
$frame = $this->readFrame($file, 1);

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

fseek($file, -$offset, SEEK_END);
fseek($file, -$offset, \SEEK_END);
$frame = fread($file, $frameSize);
if ('' == $frame) {
return '';
}

if (false !== strpos($frame, '|{')) {
if (str_contains($frame, '|{')) {
return $frame;
}

Expand Down
4 changes: 2 additions & 2 deletions FsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function createQueue(string $queueName): Queue

public function declareDestination(FsDestination $destination): void
{
//InvalidDestinationException::assertDestinationInstanceOf($destination, FsDestination::class);
// InvalidDestinationException::assertDestinationInstanceOf($destination, FsDestination::class);

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

set_error_handler(function ($severity, $message, $file, $line) {
throw new \ErrorException($message, 0, $severity, $file, $line);
}, E_ALL & ~E_USER_DEPRECATED);
}, \E_ALL & ~\E_USER_DEPRECATED);

try {
$file = fopen((string) $destination->getFileInfo(), $mode);
Expand Down
16 changes: 6 additions & 10 deletions FsMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function setRedelivered(bool $redelivered): void
$this->redelivered = $redelivered;
}

public function setCorrelationId(string $correlationId = null): void
public function setCorrelationId(?string $correlationId = null): void
{
$this->setHeader('correlation_id', (string) $correlationId);
}
Expand All @@ -106,7 +106,7 @@ public function getCorrelationId(): ?string
return $this->getHeader('correlation_id');
}

public function setMessageId(string $messageId = null): void
public function setMessageId(?string $messageId = null): void
{
$this->setHeader('message_id', (string) $messageId);
}
Expand All @@ -123,12 +123,12 @@ public function getTimestamp(): ?int
return null === $value ? null : (int) $value;
}

public function setTimestamp(int $timestamp = null): void
public function setTimestamp(?int $timestamp = null): void
{
$this->setHeader('timestamp', $timestamp);
}

public function setReplyTo(string $replyTo = null): void
public function setReplyTo(?string $replyTo = null): void
{
$this->setHeader('reply_to', $replyTo);
}
Expand All @@ -150,12 +150,8 @@ public function jsonSerialize(): array
public static function jsonUnserialize(string $json): self
{
$data = json_decode($json, true);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(sprintf(
'The malformed json given. Error %s and message %s',
json_last_error(),
json_last_error_msg()
));
if (\JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg()));
}

return new self($data['body'], $data['properties'], $data['headers']);
Expand Down
14 changes: 5 additions & 9 deletions FsProducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,8 @@ public function send(Destination $destination, Message $message): void
$rawMessage = str_replace('|{', '\|\{', $rawMessage);
$rawMessage = '|'.$rawMessage;

if (JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(sprintf(
'Could not encode value into json. Error %s and message %s',
json_last_error(),
json_last_error_msg()
));
if (\JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(sprintf('Could not encode value into json. Error %s and message %s', json_last_error(), json_last_error_msg()));
}

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

public function setDeliveryDelay(int $deliveryDelay = null): Producer
public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
if (null === $deliveryDelay) {
return $this;
Expand All @@ -81,7 +77,7 @@ public function getDeliveryDelay(): ?int
return null;
}

public function setPriority(int $priority = null): Producer
public function setPriority(?int $priority = null): Producer
{
if (null === $priority) {
return $this;
Expand All @@ -95,7 +91,7 @@ public function getPriority(): ?int
return null;
}

public function setTimeToLive(int $timeToLive = null): Producer
public function setTimeToLive(?int $timeToLive = null): Producer
{
$this->timeToLive = $timeToLive;

Expand Down
12 changes: 2 additions & 10 deletions LegacyFilesystemLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public function __construct()
$this->lockHandlers = [];
}

/**
* {@inheritdoc}
*/
public function lock(FsDestination $destination)
{
$lockHandler = $this->getLockHandler($destination);
Expand All @@ -31,9 +28,6 @@ public function lock(FsDestination $destination)
}
}

/**
* {@inheritdoc}
*/
public function release(FsDestination $destination)
{
$lockHandler = $this->getLockHandler($destination);
Expand All @@ -51,8 +45,6 @@ public function releaseAll()
}

/**
* @param FsDestination $destination
*
* @return LockHandler
*/
private function getLockHandler(FsDestination $destination)
Expand Down Expand Up @@ -161,7 +153,7 @@ public function lock($blocking = false)

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

Expand All @@ -177,7 +169,7 @@ public function lock($blocking = false)
public function release()
{
if ($this->handle) {
flock($this->handle, LOCK_UN | LOCK_NB);
flock($this->handle, \LOCK_UN | \LOCK_NB);
fclose($this->handle);
$this->handle = null;
}
Expand Down
5 changes: 0 additions & 5 deletions Lock.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ interface Lock
* Returns the control If the look has been obtained
* If not, should throw CannotObtainLockException exception.
*
* @param FsDestination $destination
*
* @throws CannotObtainLockException if look could not be obtained
*/
public function lock(FsDestination $destination);

/**
* @param FsDestination $destination
*/
public function release(FsDestination $destination);

public function releaseAll();
Expand Down
3 changes: 0 additions & 3 deletions Tests/FsConnectionFactoryConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ public function testThrowIfArrayConfigGivenWithEmptyPath()

/**
* @dataProvider provideConfigs
*
* @param mixed $config
* @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/FsMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function testCouldBeUnserializedFromJson()

$json = json_encode($message);

//guard
// guard
$this->assertNotEmpty($json);

$unserializedMessage = FsMessage::jsonUnserialize($json);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/FsCommonUseCasesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function testConsumerReceiveMessageWithZeroTimeout()
$topic = $this->fsContext->createTopic('fs_test_queue_exchange');

$consumer = $this->fsContext->createConsumer($topic);
//guard
// guard
$this->assertNull($consumer->receive(1000));

$message = $this->fsContext->createMessage(__METHOD__);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/FsConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function testShouldThrowExceptionWhenFrameSizeNotDivideExactly()

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

fwrite($file, $msg);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/FsContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class FsContextTest extends TestCase
*/
private $fsContext;

public function tearDown(): void
protected function tearDown(): void
{
$fs = new Filesystem();
$fs->remove(sys_get_temp_dir().'/enqueue');
Expand Down
3 changes: 0 additions & 3 deletions Tests/Spec/FsMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

class FsMessageTest extends MessageSpec
{
/**
* {@inheritdoc}
*/
protected function createMessage()
{
return new FsMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
class FsSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTimeToLiveMessagesFromQueueSpec
{
/**
* {@inheritdoc}
*
* @return FsContext
*/
protected function createContext()
Expand Down

0 comments on commit 54a7846

Please sign in to comment.