Skip to content

Commit c3c309e

Browse files
committed
fixed qodana issues
Signed-off-by: bota <sergiubota@rospace.com>
1 parent 81953e3 commit c3c309e

9 files changed

Lines changed: 17 additions & 33 deletions

File tree

‎src/App/Message/Message.php‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,7 @@
77
class Message
88
{
99
public function __construct(
10-
private array $payload,
10+
public array $payload,
1111
) {
1212
}
13-
14-
public function getPayload(): array
15-
{
16-
return $this->payload;
17-
}
18-
19-
public function setPayload(array $payload): void
20-
{
21-
$this->payload = $payload;
22-
}
2313
}

‎src/App/Message/MessageHandler.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(
2828
*/
2929
public function __invoke(Message $message): void
3030
{
31-
$payload = $message->getPayload();
31+
$payload = $message->payload;
3232

3333
try {
3434
if ($payload['foo'] === 'control') {
@@ -52,7 +52,7 @@ public function __invoke(Message $message): void
5252
}
5353

5454
$payload['retry_count'] = $retryCount + 1;
55-
$message->setPayload($payload);
55+
$message->payload = $payload;
5656

5757
throw $e;
5858
}

‎src/Swoole/Command/StartCommand.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class StartCommand extends Command
2424

2525
public PidManager $pidManager;
2626

27-
public const DEFAULT_PROCESS_NAME = 'dotkernel-queue';
27+
public const string DEFAULT_PROCESS_NAME = 'dotkernel-queue';
2828

29-
public const HELP = <<<'EOH'
29+
public const string HELP = <<<'EOH'
3030
Start the web server. If --daemonize is provided, starts the server as a
3131
background process and returns handling to the shell; otherwise, the
3232
server runs in the current process.

‎src/Swoole/Command/StopCommand.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class StopCommand extends Command
1818
{
1919
use IsRunningTrait;
2020

21-
public const HELP = <<<'EOH'
21+
public const string HELP = <<<'EOH'
2222
Stop the web server. Kills all worker processes and stops the web server.
2323
2424
This command is only relevant when the server was started using the

‎src/Swoole/PidManager.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class PidManager
1919
{
20-
public function __construct(private string $pidFile)
20+
public function __construct(private readonly string $pidFile)
2121
{
2222
}
2323

‎src/Swoole/ServerFactory.php‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,16 @@
3131

3232
class ServerFactory
3333
{
34-
/**
35-
* @var string
36-
*/
37-
public const DEFAULT_HOST = '127.0.0.1';
34+
public const string DEFAULT_HOST = '127.0.0.1';
3835

39-
/**
40-
* @var int
41-
*/
42-
public const DEFAULT_PORT = 8080;
36+
public const int DEFAULT_PORT = 8080;
4337

4438
/**
4539
* Swoole server supported modes
4640
*
4741
* @var int[]
4842
*/
49-
private const MODES = [
43+
private const array MODES = [
5044
SWOOLE_BASE,
5145
SWOOLE_PROCESS,
5246
];
@@ -56,7 +50,7 @@ class ServerFactory
5650
*
5751
* @var int[]
5852
*/
59-
private const PROTOCOLS = [
53+
private const array PROTOCOLS = [
6054
SWOOLE_SOCK_TCP,
6155
SWOOLE_SOCK_TCP6,
6256
SWOOLE_SOCK_UDP,

‎test/App/Message/MessageHandlerTest.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testControlMessageDoesNotThrowAndDoesNotSetRetryCount(): void
6565
$message = new Message(['foo' => 'control']);
6666
$handler($message);
6767

68-
$payload = $message->getPayload();
68+
$payload = $message->payload;
6969
$this->assertArrayNotHasKey('retry_count', $payload);
7070
}
7171

@@ -81,7 +81,7 @@ public function testRetryMessageThrowsExceptionAndSetsRetryCount(): void
8181
try {
8282
$handler($message);
8383
} finally {
84-
$payload = $message->getPayload();
84+
$payload = $message->payload;
8585
$this->assertArrayHasKey('retry_count', $payload);
8686
$this->assertEquals(1, $payload['retry_count']); // first retry
8787
}
@@ -101,7 +101,7 @@ public function testRetryMessageWithExistingRetryCountIncrementsIt(): void
101101
try {
102102
$handler($message);
103103
} finally {
104-
$payload = $message->getPayload();
104+
$payload = $message->payload;
105105
$this->assertEquals(3, $payload['retry_count']); // incremented from 2 → 3
106106
}
107107
}

‎test/App/Message/MessageTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ class MessageTest extends TestCase
1212
public function testMessageAccessors(): void
1313
{
1414
$admin = new Message(['payload' => 'test message payload']);
15-
$this->assertSame(['payload' => 'test message payload'], $admin->getPayload());
15+
$this->assertSame(['payload' => 'test message payload'], $admin->payload);
1616
}
1717
}

‎test/Swoole/Delegators/TCPServerDelegatorTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ public function testReceiveDispatchesMessagesAndLogsWhenUnknownCommand(): void
132132

133133
if ($callCount === 1) {
134134
$this->assertInstanceOf(Message::class, $message);
135-
$this->assertEquals('hello', $message->getPayload()['foo']);
135+
$this->assertEquals('hello', $message->payload['foo']);
136136
} elseif ($callCount === 2) {
137137
$this->assertInstanceOf(Message::class, $message);
138-
$this->assertEquals('with 5 seconds delay', $message->getPayload()['foo']);
138+
$this->assertEquals('with 5 seconds delay', $message->payload['foo']);
139139
} else {
140140
$this->fail('dispatch called more than twice');
141141
}

0 commit comments

Comments
 (0)