Skip to content

Commit 7fb246e

Browse files
authored
Upgrade the minimum php version to 8.0 for websocket. (#4525)
1 parent 2551f7b commit 7fb246e

File tree

3 files changed

+12
-27
lines changed

3 files changed

+12
-27
lines changed

src/Client.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,10 @@
1919

2020
class Client
2121
{
22-
/**
23-
* @var UriInterface
24-
*/
25-
protected $uri;
26-
27-
/**
28-
* @var Coroutine\Http\Client
29-
*/
30-
protected $client;
22+
protected Coroutine\Http\Client $client;
3123

32-
public function __construct(UriInterface $uri)
24+
public function __construct(protected UriInterface $uri)
3325
{
34-
$this->uri = $uri;
3526
$host = $uri->getHost();
3627
$port = $uri->getPort();
3728
$ssl = $uri->getScheme() === 'wss';

src/Frame.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,13 @@
1313

1414
use Swoole\WebSocket\Frame as SwFrame;
1515

16-
class Frame
16+
class Frame implements \Stringable
1717
{
18-
/**
19-
* @var bool
20-
*/
21-
public $finish = true;
18+
public bool $finish = true;
2219

23-
/**
24-
* @var string
25-
*/
26-
public $opcode;
20+
public int $opcode;
2721

28-
/**
29-
* @var string
30-
*/
31-
public $data;
22+
public string $data;
3223

3324
public function __construct(SwFrame $frame)
3425
{
@@ -37,7 +28,7 @@ public function __construct(SwFrame $frame)
3728
$this->data = $frame->data;
3829
}
3930

40-
public function __toString()
31+
public function __toString(): string
4132
{
4233
return $this->data;
4334
}
@@ -53,7 +44,7 @@ public function getOpcodeDefinition(): string
5344
return $map[$this->opcode] ?? 'WEBSOCKET_BAD_OPCODE';
5445
}
5546

56-
public function getOpcode(): string
47+
public function getOpcode(): int
5748
{
5849
return $this->opcode;
5950
}

tests/FrameTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ class FrameTest extends TestCase
2424
{
2525
public function testFrame()
2626
{
27-
$frame = new Frame(Mockery::mock(SwFrame::class));
27+
$swframe = Mockery::mock(SwFrame::class);
28+
$swframe->finish = true;
29+
$swframe->opcode = 1;
30+
$frame = new Frame($swframe);
2831

2932
$this->assertSame($frame->data, (string) $frame);
3033
}

0 commit comments

Comments
 (0)