diff --git a/phpstan.neon b/phpstan.neon index 88be8a7e1..b689b6b8a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -14,10 +14,3 @@ parameters: - pkg/enqueue-bundle/DependencyInjection/Configuration.php - pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php - pkg/simple-client/SimpleClient.php - ignoreErrors: - - - message: '#Class Symfony\\Component\\EventDispatcher\\LegacyEventDispatcherProxy not found#' - path: %currentWorkingDirectory%/* - - - message: '#.*Symfony\\Contracts\\EventDispatcher\\Event.*#' - path: %currentWorkingDirectory%/* diff --git a/pkg/enqueue/Client/Config.php b/pkg/enqueue/Client/Config.php index 34057e1c1..8210dff68 100644 --- a/pkg/enqueue/Client/Config.php +++ b/pkg/enqueue/Client/Config.php @@ -163,7 +163,7 @@ public static function create( array $transportConfig = [], array $driverConfig = [], ): self { - return new static( + return new self( $prefix ?: '', $separator ?: '.', $app ?: '', diff --git a/pkg/enqueue/Client/Driver/StompManagementClient.php b/pkg/enqueue/Client/Driver/StompManagementClient.php index 5880672b5..0d64450dd 100644 --- a/pkg/enqueue/Client/Driver/StompManagementClient.php +++ b/pkg/enqueue/Client/Driver/StompManagementClient.php @@ -24,7 +24,7 @@ public function __construct(Client $client, string $vhost = '/') public static function create(string $vhost = '/', string $host = 'localhost', int $port = 15672, string $login = 'guest', string $password = 'guest'): self { - return new static(new Client(null, 'http://'.$host.':'.$port, $login, $password), $vhost); + return new self(new Client(null, 'http://'.$host.':'.$port, $login, $password), $vhost); } public function declareQueue(string $name, array $options) diff --git a/pkg/enqueue/Consumption/Exception/InvalidArgumentException.php b/pkg/enqueue/Consumption/Exception/InvalidArgumentException.php index 76ea83ad7..89a2f4ca7 100644 --- a/pkg/enqueue/Consumption/Exception/InvalidArgumentException.php +++ b/pkg/enqueue/Consumption/Exception/InvalidArgumentException.php @@ -12,7 +12,7 @@ class InvalidArgumentException extends \InvalidArgumentException implements Exce public static function assertInstanceOf($argument, $class) { if (false == $argument instanceof $class) { - throw new static(sprintf('The argument must be an instance of %s but got %s.', $class, is_object($argument) ? $argument::class : gettype($argument))); + throw new self(sprintf('The argument must be an instance of %s but got %s.', $class, is_object($argument) ? $argument::class : gettype($argument))); } } } diff --git a/pkg/enqueue/Consumption/Result.php b/pkg/enqueue/Consumption/Result.php index efa929c7d..69dd7907b 100644 --- a/pkg/enqueue/Consumption/Result.php +++ b/pkg/enqueue/Consumption/Result.php @@ -89,7 +89,7 @@ public function setReply(?InteropMessage $reply = null) */ public static function ack($reason = '') { - return new static(self::ACK, $reason); + return new self(self::ACK, $reason); } /** @@ -99,7 +99,7 @@ public static function ack($reason = '') */ public static function reject($reason) { - return new static(self::REJECT, $reason); + return new self(self::REJECT, $reason); } /** @@ -109,7 +109,7 @@ public static function reject($reason) */ public static function requeue($reason = '') { - return new static(self::REQUEUE, $reason); + return new self(self::REQUEUE, $reason); } /** @@ -122,7 +122,7 @@ public static function reply(InteropMessage $replyMessage, $status = self::ACK, { $status = null === $status ? self::ACK : $status; - $result = new static($status, $reason); + $result = new self($status, $reason); $result->setReply($replyMessage); return $result; diff --git a/pkg/enqueue/Rpc/TimeoutException.php b/pkg/enqueue/Rpc/TimeoutException.php index a0b065511..a7f68b967 100644 --- a/pkg/enqueue/Rpc/TimeoutException.php +++ b/pkg/enqueue/Rpc/TimeoutException.php @@ -12,6 +12,6 @@ class TimeoutException extends \LogicException */ public static function create($timeout, $correlationId) { - return new static(sprintf('Rpc call timeout is reached without receiving a reply message. Timeout: %s, CorrelationId: %s', $timeout, $correlationId)); + return new self(sprintf('Rpc call timeout is reached without receiving a reply message. Timeout: %s, CorrelationId: %s', $timeout, $correlationId)); } } diff --git a/pkg/enqueue/Symfony/Client/SetupBrokerExtensionCommandTrait.php b/pkg/enqueue/Symfony/Client/SetupBrokerExtensionCommandTrait.php index 96e0d2d6b..bcc4f7bb2 100644 --- a/pkg/enqueue/Symfony/Client/SetupBrokerExtensionCommandTrait.php +++ b/pkg/enqueue/Symfony/Client/SetupBrokerExtensionCommandTrait.php @@ -18,7 +18,7 @@ protected function configureSetupBrokerExtension() } /** - * @return ExtensionInterface + * @return ExtensionInterface|null */ protected function getSetupBrokerExtension(InputInterface $input, DriverInterface $driver) { diff --git a/pkg/enqueue/Symfony/DiUtils.php b/pkg/enqueue/Symfony/DiUtils.php index 335ff04b9..be45287be 100644 --- a/pkg/enqueue/Symfony/DiUtils.php +++ b/pkg/enqueue/Symfony/DiUtils.php @@ -27,7 +27,7 @@ public function __construct(string $moduleName, string $configName) public static function create(string $moduleName, string $configName): self { - return new static($moduleName, $configName); + return new self($moduleName, $configName); } public function getModuleName(): string diff --git a/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php b/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php index 5391f0c68..73fba7bfd 100644 --- a/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php +++ b/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php @@ -147,34 +147,18 @@ public function testShouldConsumeMessagesFromTwoQueuesInExpectedOrder() $fourthMessage = $this->createMessageStub('fourth'); $fifthMessage = $this->createMessageStub('fifth'); - $fooMessages = [null, $firstMessage, null, $secondMessage, $thirdMessage]; - $fooConsumer = $this->createConsumerStub('foo_queue'); $fooConsumer ->expects($this->any()) ->method('receiveNoWait') - ->willReturnCallback(function () use (&$fooMessages) { - if (empty($fooMessages)) { - return null; - } - - return array_shift($fooMessages); - }) + ->willReturnOnConsecutiveCalls(null, $firstMessage, null, $secondMessage, $thirdMessage) ; - $barMessages = [$fourthMessage, null, null, $fifthMessage]; - $barConsumer = $this->createConsumerStub('bar_queue'); $barConsumer ->expects($this->any()) ->method('receiveNoWait') - ->willReturnCallback(function () use (&$barMessages) { - if (empty($barMessages)) { - return null; - } - - return array_shift($barMessages); - }) + ->willReturnOnConsecutiveCalls($fourthMessage, null, null, $fifthMessage) ; $actualOrder = []; diff --git a/pkg/enqueue/Tests/Mocks/JsonSerializableObject.php b/pkg/enqueue/Tests/Mocks/JsonSerializableObject.php index 5b74106dc..84885c316 100644 --- a/pkg/enqueue/Tests/Mocks/JsonSerializableObject.php +++ b/pkg/enqueue/Tests/Mocks/JsonSerializableObject.php @@ -4,7 +4,8 @@ class JsonSerializableObject implements \JsonSerializable { - public function jsonSerialize() + #[\ReturnTypeWillChange] + public function jsonSerialize(): array { return ['foo' => 'fooVal']; } diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php index 14a48be93..e1ed297c6 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php @@ -443,6 +443,7 @@ private function createCommandSubscriberProcessor($commandSubscriberReturns = [' public function process(InteropMessage $message, Context $context) { + return self::ACK; } public static function getSubscribedCommand() diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php index b9d798c11..a954d9a41 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php @@ -407,6 +407,7 @@ private function createTopicSubscriberProcessor($topicSubscriberReturns = ['aTop public function process(InteropMessage $message, Context $context) { + return self::ACK; } public static function getSubscribedTopics() diff --git a/pkg/enqueue/Tests/Symfony/Consumption/Mock/QueueSubscriberProcessor.php b/pkg/enqueue/Tests/Symfony/Consumption/Mock/QueueSubscriberProcessor.php index 56b3c9319..a210b0e6b 100644 --- a/pkg/enqueue/Tests/Symfony/Consumption/Mock/QueueSubscriberProcessor.php +++ b/pkg/enqueue/Tests/Symfony/Consumption/Mock/QueueSubscriberProcessor.php @@ -11,6 +11,7 @@ class QueueSubscriberProcessor implements Processor, QueueSubscriberInterface { public function process(InteropMessage $message, Context $context) { + return self::ACK; } public static function getSubscribedQueues() diff --git a/pkg/enqueue/Tests/Util/Fixtures/JsonSerializableClass.php b/pkg/enqueue/Tests/Util/Fixtures/JsonSerializableClass.php index b612978e7..1a77ce0cf 100644 --- a/pkg/enqueue/Tests/Util/Fixtures/JsonSerializableClass.php +++ b/pkg/enqueue/Tests/Util/Fixtures/JsonSerializableClass.php @@ -6,7 +6,8 @@ class JsonSerializableClass implements \JsonSerializable { public $keyPublic = 'public'; - public function jsonSerialize() + #[\ReturnTypeWillChange] + public function jsonSerialize(): array { return [ 'key' => 'value', diff --git a/pkg/enqueue/Util/Stringify.php b/pkg/enqueue/Util/Stringify.php index 12358d785..d8a48a8d6 100644 --- a/pkg/enqueue/Util/Stringify.php +++ b/pkg/enqueue/Util/Stringify.php @@ -25,6 +25,6 @@ public function __toString(): string public static function that($value): self { - return new static($value); + return new self($value); } } diff --git a/pkg/job-queue/Test/DbalPersistedConnection.php b/pkg/job-queue/Test/DbalPersistedConnection.php index 6e1dc4ca6..470a65176 100644 --- a/pkg/job-queue/Test/DbalPersistedConnection.php +++ b/pkg/job-queue/Test/DbalPersistedConnection.php @@ -41,16 +41,22 @@ public function connect() public function beginTransaction() { $this->wrapTransactionNestingLevel('beginTransaction'); + + return true; } public function commit() { $this->wrapTransactionNestingLevel('commit'); + + return true; } public function rollBack() { $this->wrapTransactionNestingLevel('rollBack'); + + return true; } /** diff --git a/pkg/monitoring/InfluxDbStorage.php b/pkg/monitoring/InfluxDbStorage.php index 3084864f8..e39cccfd2 100644 --- a/pkg/monitoring/InfluxDbStorage.php +++ b/pkg/monitoring/InfluxDbStorage.php @@ -109,7 +109,7 @@ public static function createWithClient(Client $client, $config = 'influxdb:'): } $config['client'] = $client; - return new static($config); + return new self($config); } public function pushConsumerStats(ConsumerStats $stats): void diff --git a/pkg/rdkafka/RdKafkaProducer.php b/pkg/rdkafka/RdKafkaProducer.php index c70f1fbe6..24589b3e7 100644 --- a/pkg/rdkafka/RdKafkaProducer.php +++ b/pkg/rdkafka/RdKafkaProducer.php @@ -121,5 +121,7 @@ public function flush(int $timeout): ?int if (method_exists($this->producer, 'flush')) { return $this->producer->flush($timeout); } + + return null; } }