Skip to content

Commit 017a15b

Browse files
committed
Fixing static analysis issues
Fixing issue raised by phpstan
1 parent 2b3f908 commit 017a15b

18 files changed

+29
-39
lines changed

phpstan.neon

-7
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,3 @@ parameters:
1414
- pkg/enqueue-bundle/DependencyInjection/Configuration.php
1515
- pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php
1616
- pkg/simple-client/SimpleClient.php
17-
ignoreErrors:
18-
-
19-
message: '#Class Symfony\\Component\\EventDispatcher\\LegacyEventDispatcherProxy not found#'
20-
path: %currentWorkingDirectory%/*
21-
-
22-
message: '#.*Symfony\\Contracts\\EventDispatcher\\Event.*#'
23-
path: %currentWorkingDirectory%/*

pkg/enqueue/Client/Config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public static function create(
163163
array $transportConfig = [],
164164
array $driverConfig = [],
165165
): self {
166-
return new static(
166+
return new self(
167167
$prefix ?: '',
168168
$separator ?: '.',
169169
$app ?: '',

pkg/enqueue/Client/Driver/StompManagementClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(Client $client, string $vhost = '/')
2424

2525
public static function create(string $vhost = '/', string $host = 'localhost', int $port = 15672, string $login = 'guest', string $password = 'guest'): self
2626
{
27-
return new static(new Client(null, 'http://'.$host.':'.$port, $login, $password), $vhost);
27+
return new self(new Client(null, 'http://'.$host.':'.$port, $login, $password), $vhost);
2828
}
2929

3030
public function declareQueue(string $name, array $options)

pkg/enqueue/Consumption/Exception/InvalidArgumentException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class InvalidArgumentException extends \InvalidArgumentException implements Exce
1212
public static function assertInstanceOf($argument, $class)
1313
{
1414
if (false == $argument instanceof $class) {
15-
throw new static(sprintf('The argument must be an instance of %s but got %s.', $class, is_object($argument) ? $argument::class : gettype($argument)));
15+
throw new self(sprintf('The argument must be an instance of %s but got %s.', $class, is_object($argument) ? $argument::class : gettype($argument)));
1616
}
1717
}
1818
}

pkg/enqueue/Consumption/Result.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function setReply(?InteropMessage $reply = null)
8989
*/
9090
public static function ack($reason = '')
9191
{
92-
return new static(self::ACK, $reason);
92+
return new self(self::ACK, $reason);
9393
}
9494

9595
/**
@@ -99,7 +99,7 @@ public static function ack($reason = '')
9999
*/
100100
public static function reject($reason)
101101
{
102-
return new static(self::REJECT, $reason);
102+
return new self(self::REJECT, $reason);
103103
}
104104

105105
/**
@@ -109,7 +109,7 @@ public static function reject($reason)
109109
*/
110110
public static function requeue($reason = '')
111111
{
112-
return new static(self::REQUEUE, $reason);
112+
return new self(self::REQUEUE, $reason);
113113
}
114114

115115
/**
@@ -122,7 +122,7 @@ public static function reply(InteropMessage $replyMessage, $status = self::ACK,
122122
{
123123
$status = null === $status ? self::ACK : $status;
124124

125-
$result = new static($status, $reason);
125+
$result = new self($status, $reason);
126126
$result->setReply($replyMessage);
127127

128128
return $result;

pkg/enqueue/Rpc/TimeoutException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ class TimeoutException extends \LogicException
1212
*/
1313
public static function create($timeout, $correlationId)
1414
{
15-
return new static(sprintf('Rpc call timeout is reached without receiving a reply message. Timeout: %s, CorrelationId: %s', $timeout, $correlationId));
15+
return new self(sprintf('Rpc call timeout is reached without receiving a reply message. Timeout: %s, CorrelationId: %s', $timeout, $correlationId));
1616
}
1717
}

pkg/enqueue/Symfony/Client/SetupBrokerExtensionCommandTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected function configureSetupBrokerExtension()
1818
}
1919

2020
/**
21-
* @return ExtensionInterface
21+
* @return ExtensionInterface|null
2222
*/
2323
protected function getSetupBrokerExtension(InputInterface $input, DriverInterface $driver)
2424
{

pkg/enqueue/Symfony/DiUtils.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(string $moduleName, string $configName)
2727

2828
public static function create(string $moduleName, string $configName): self
2929
{
30-
return new static($moduleName, $configName);
30+
return new self($moduleName, $configName);
3131
}
3232

3333
public function getModuleName(): string

pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php

+2-18
Original file line numberDiff line numberDiff line change
@@ -149,34 +149,18 @@ public function testShouldConsumeMessagesFromTwoQueuesInExpectedOrder()
149149
$fourthMessage = $this->createMessageStub('fourth');
150150
$fifthMessage = $this->createMessageStub('fifth');
151151

152-
$fooMessages = [null, $firstMessage, null, $secondMessage, $thirdMessage];
153-
154152
$fooConsumer = $this->createConsumerStub('foo_queue');
155153
$fooConsumer
156154
->expects($this->any())
157155
->method('receiveNoWait')
158-
->willReturnCallback(function () use (&$fooMessages) {
159-
if (empty($fooMessages)) {
160-
return null;
161-
}
162-
163-
return array_shift($fooMessages);
164-
})
156+
->willReturnOnConsecutiveCalls(null, $firstMessage, null, $secondMessage, $thirdMessage)
165157
;
166158

167-
$barMessages = [$fourthMessage, null, null, $fifthMessage];
168-
169159
$barConsumer = $this->createConsumerStub('bar_queue');
170160
$barConsumer
171161
->expects($this->any())
172162
->method('receiveNoWait')
173-
->willReturnCallback(function () use (&$barMessages) {
174-
if (empty($barMessages)) {
175-
return null;
176-
}
177-
178-
return array_shift($barMessages);
179-
})
163+
->willReturnOnConsecutiveCalls($fourthMessage, null, null, $fifthMessage)
180164
;
181165

182166
$actualOrder = [];

pkg/enqueue/Tests/Mocks/JsonSerializableObject.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
class JsonSerializableObject implements \JsonSerializable
66
{
7-
public function jsonSerialize()
7+
#[\ReturnTypeWillChange]
8+
public function jsonSerialize(): array
89
{
910
return ['foo' => 'fooVal'];
1011
}

pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ private function createCommandSubscriberProcessor($commandSubscriberReturns = ['
448448

449449
public function process(InteropMessage $message, Context $context)
450450
{
451+
return self::ACK;
451452
}
452453

453454
public static function getSubscribedCommand()

pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ private function createTopicSubscriberProcessor($topicSubscriberReturns = ['aTop
412412

413413
public function process(InteropMessage $message, Context $context)
414414
{
415+
return self::ACK;
415416
}
416417

417418
public static function getSubscribedTopics()

pkg/enqueue/Tests/Symfony/Consumption/Mock/QueueSubscriberProcessor.php

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class QueueSubscriberProcessor implements Processor, QueueSubscriberInterface
1111
{
1212
public function process(InteropMessage $message, Context $context)
1313
{
14+
return self::ACK;
1415
}
1516

1617
public static function getSubscribedQueues()

pkg/enqueue/Tests/Util/Fixtures/JsonSerializableClass.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ class JsonSerializableClass implements \JsonSerializable
66
{
77
public $keyPublic = 'public';
88

9-
public function jsonSerialize()
9+
#[\ReturnTypeWillChange]
10+
public function jsonSerialize(): array
1011
{
1112
return [
1213
'key' => 'value',

pkg/enqueue/Util/Stringify.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public function __toString(): string
2525

2626
public static function that($value): self
2727
{
28-
return new static($value);
28+
return new self($value);
2929
}
3030
}

pkg/job-queue/Test/DbalPersistedConnection.php

+6
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,22 @@ public function connect()
4141
public function beginTransaction()
4242
{
4343
$this->wrapTransactionNestingLevel('beginTransaction');
44+
45+
return true;
4446
}
4547

4648
public function commit()
4749
{
4850
$this->wrapTransactionNestingLevel('commit');
51+
52+
return true;
4953
}
5054

5155
public function rollBack()
5256
{
5357
$this->wrapTransactionNestingLevel('rollBack');
58+
59+
return true;
5460
}
5561

5662
/**

pkg/monitoring/InfluxDbStorage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static function createWithClient(Client $client, $config = 'influxdb:'):
109109
}
110110
$config['client'] = $client;
111111

112-
return new static($config);
112+
return new self($config);
113113
}
114114

115115
public function pushConsumerStats(ConsumerStats $stats): void

pkg/rdkafka/RdKafkaProducer.php

+2
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,7 @@ public function flush(int $timeout): ?int
121121
if (method_exists($this->producer, 'flush')) {
122122
return $this->producer->flush($timeout);
123123
}
124+
125+
return null;
124126
}
125127
}

0 commit comments

Comments
 (0)