diff --git a/FsConnectionFactory.php b/FsConnectionFactory.php index ad13e9e..9c4ba17 100644 --- a/FsConnectionFactory.php +++ b/FsConnectionFactory.php @@ -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(), [ diff --git a/FsConsumer.php b/FsConsumer.php index 46e7b96..614461e 100644 --- a/FsConsumer.php +++ b/FsConsumer.php @@ -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])); } @@ -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; } diff --git a/FsContext.php b/FsContext.php index 480074e..c735e13 100644 --- a/FsContext.php +++ b/FsContext.php @@ -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); @@ -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); diff --git a/FsMessage.php b/FsMessage.php index d66ee52..45312e5 100644 --- a/FsMessage.php +++ b/FsMessage.php @@ -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); } @@ -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); } @@ -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); } @@ -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']); diff --git a/FsProducer.php b/FsProducer.php index 55ff88c..067e54b 100644 --- a/FsProducer.php +++ b/FsProducer.php @@ -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; @@ -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; @@ -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; @@ -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; diff --git a/LegacyFilesystemLock.php b/LegacyFilesystemLock.php index a765d2c..328fb70 100644 --- a/LegacyFilesystemLock.php +++ b/LegacyFilesystemLock.php @@ -19,9 +19,6 @@ public function __construct() $this->lockHandlers = []; } - /** - * {@inheritdoc} - */ public function lock(FsDestination $destination) { $lockHandler = $this->getLockHandler($destination); @@ -31,9 +28,6 @@ public function lock(FsDestination $destination) } } - /** - * {@inheritdoc} - */ public function release(FsDestination $destination) { $lockHandler = $this->getLockHandler($destination); @@ -51,8 +45,6 @@ public function releaseAll() } /** - * @param FsDestination $destination - * * @return LockHandler */ private function getLockHandler(FsDestination $destination) @@ -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; @@ -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; } diff --git a/Lock.php b/Lock.php index 91125fa..16349f2 100644 --- a/Lock.php +++ b/Lock.php @@ -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(); diff --git a/Tests/FsConnectionFactoryConfigTest.php b/Tests/FsConnectionFactoryConfigTest.php index 970fef3..0b3411f 100644 --- a/Tests/FsConnectionFactoryConfigTest.php +++ b/Tests/FsConnectionFactoryConfigTest.php @@ -51,9 +51,6 @@ public function testThrowIfArrayConfigGivenWithEmptyPath() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/Tests/FsMessageTest.php b/Tests/FsMessageTest.php index c2f788d..90655b6 100644 --- a/Tests/FsMessageTest.php +++ b/Tests/FsMessageTest.php @@ -89,7 +89,7 @@ public function testCouldBeUnserializedFromJson() $json = json_encode($message); - //guard + // guard $this->assertNotEmpty($json); $unserializedMessage = FsMessage::jsonUnserialize($json); diff --git a/Tests/Functional/FsCommonUseCasesTest.php b/Tests/Functional/FsCommonUseCasesTest.php index 7abb9d9..b96091e 100644 --- a/Tests/Functional/FsCommonUseCasesTest.php +++ b/Tests/Functional/FsCommonUseCasesTest.php @@ -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__); diff --git a/Tests/Functional/FsConsumerTest.php b/Tests/Functional/FsConsumerTest.php index 984ea16..3be009b 100644 --- a/Tests/Functional/FsConsumerTest.php +++ b/Tests/Functional/FsConsumerTest.php @@ -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); diff --git a/Tests/Functional/FsContextTest.php b/Tests/Functional/FsContextTest.php index 287fd6c..806b9f5 100644 --- a/Tests/Functional/FsContextTest.php +++ b/Tests/Functional/FsContextTest.php @@ -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'); diff --git a/Tests/Spec/FsMessageTest.php b/Tests/Spec/FsMessageTest.php index 20dd4be..f1ece8e 100644 --- a/Tests/Spec/FsMessageTest.php +++ b/Tests/Spec/FsMessageTest.php @@ -7,9 +7,6 @@ class FsMessageTest extends MessageSpec { - /** - * {@inheritdoc} - */ protected function createMessage() { return new FsMessage(); diff --git a/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php b/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php index 3dd1697..d6a76ca 100644 --- a/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php +++ b/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php @@ -9,8 +9,6 @@ class FsSendAndReceiveTimeToLiveMessagesFromQueueTest extends SendAndReceiveTimeToLiveMessagesFromQueueSpec { /** - * {@inheritdoc} - * * @return FsContext */ protected function createContext()