Skip to content

Commit 3b5657a

Browse files
authored
Merge pull request #102 from dotkernel/issue-100
Issue #100: Block symfony/polyfill-php83 <1.30
2 parents c2405ee + c3c309e commit 3b5657a

11 files changed

Lines changed: 22 additions & 35 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ The queue system uses logs to ensure maintainability and implements retry featur
1515

1616
## Version History
1717

18-
| Branch | Release | PSR-11 | OSS Lifecycle | PHP Version |
19-
|--------|---------|--------|----------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
18+
| Branch | Release | PSR-11 | OSS Lifecycle | PHP Version |
19+
|--------|---------|--------|-----------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
2020
| 2.0 | `> 2.0` | 1 | ![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/queue) | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/queue/2.0.0) |
2121
| 1.0 | `< 2.0` | 1 | ![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/queue) | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/queue/1.0.0) |
2222

‎composer.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
"roave/security-advisories": "dev-master",
6363
"swoole/ide-helper": "~6.0.0"
6464
},
65+
"conflict": {
66+
"symfony/polyfill-php83": "<1.30"
67+
},
6568
"autoload": {
6669
"psr-4": {
6770
"Queue\\": "src/"

‎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
}

0 commit comments

Comments
 (0)