Skip to content

Commit 5114a36

Browse files
authored
Upgrade the minimum php version to 8.0 for testing signal and snowflake. (#4387)
1 parent 7a9635d commit 5114a36

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
},
2121
"require": {
22-
"php": ">=7.2",
22+
"php": ">=8.0",
2323
"psr/container": "^1.0|^2.0",
2424
"phpunit/phpunit": "^9.5",
2525
"hyperf/contract": "~3.0.0",

src/Client.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(ContainerInterface $container, PackerInterface $pack
5555
$this->initBaseUri($server);
5656
}
5757

58-
public function get($uri, $data = [], $headers = [])
58+
public function get(string $uri, array $data = [], array $headers = [])
5959
{
6060
$response = $this->request('GET', $uri, [
6161
'headers' => $headers,
@@ -65,7 +65,7 @@ public function get($uri, $data = [], $headers = [])
6565
return $this->packer->unpack((string) $response->getBody());
6666
}
6767

68-
public function post($uri, $data = [], $headers = [])
68+
public function post(string $uri, array $data = [], array $headers = [])
6969
{
7070
$response = $this->request('POST', $uri, [
7171
'headers' => $headers,
@@ -75,7 +75,7 @@ public function post($uri, $data = [], $headers = [])
7575
return $this->packer->unpack((string) $response->getBody());
7676
}
7777

78-
public function put($uri, $data = [], $headers = [])
78+
public function put(string $uri, array $data = [], array $headers = [])
7979
{
8080
$response = $this->request('PUT', $uri, [
8181
'headers' => $headers,
@@ -85,7 +85,7 @@ public function put($uri, $data = [], $headers = [])
8585
return $this->packer->unpack((string) $response->getBody());
8686
}
8787

88-
public function delete($uri, $data = [], $headers = [])
88+
public function delete(string $uri, array $data = [], array $headers = [])
8989
{
9090
$response = $this->request('DELETE', $uri, [
9191
'headers' => $headers,
@@ -95,7 +95,7 @@ public function delete($uri, $data = [], $headers = [])
9595
return $this->packer->unpack((string) $response->getBody());
9696
}
9797

98-
public function json($uri, $data = [], $headers = [])
98+
public function json(string $uri, array $data = [], array $headers = [])
9999
{
100100
$headers['Content-Type'] = 'application/json';
101101
$response = $this->request('POST', $uri, [
@@ -105,7 +105,7 @@ public function json($uri, $data = [], $headers = [])
105105
return $this->packer->unpack((string) $response->getBody());
106106
}
107107

108-
public function file($uri, $data = [], $headers = [])
108+
public function file(string $uri, array $data = [], array $headers = [])
109109
{
110110
$multipart = [];
111111
if (Arr::isAssoc($data)) {
@@ -174,7 +174,7 @@ protected function persistToContext(ServerRequestInterface $request, ResponseInt
174174
Context::set(ResponseInterface::class, $response);
175175
}
176176

177-
protected function initBaseUri($server): void
177+
protected function initBaseUri(string $server): void
178178
{
179179
if ($this->container->has(ConfigInterface::class)) {
180180
$config = $this->container->get(ConfigInterface::class);

src/HttpClient.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Hyperf\Utils\Coroutine;
1919
use Hyperf\Utils\Packer\JsonPacker;
2020
use Psr\Container\ContainerInterface;
21+
use Psr\Http\Message\UriInterface;
2122

2223
class HttpClient
2324
{
@@ -39,7 +40,7 @@ public function __construct(protected ContainerInterface $container, PackerInter
3940
]);
4041
}
4142

42-
public function get($uri, $data = [], $headers = [])
43+
public function get(string|UriInterface $uri, array $data = [], array $headers = [])
4344
{
4445
$response = $this->client->get($uri, [
4546
'headers' => $headers,
@@ -48,7 +49,7 @@ public function get($uri, $data = [], $headers = [])
4849
return $this->packer->unpack((string) $response->getBody());
4950
}
5051

51-
public function post($uri, $data = [], $headers = [])
52+
public function post(string|UriInterface $uri, array $data = [], array $headers = [])
5253
{
5354
$response = $this->client->post($uri, [
5455
'headers' => $headers,
@@ -58,7 +59,7 @@ public function post($uri, $data = [], $headers = [])
5859
return $this->packer->unpack((string) $response->getBody());
5960
}
6061

61-
public function json($uri, $data = [], $headers = [])
62+
public function json(string|UriInterface $uri, array $data = [], array $headers = [])
6263
{
6364
$headers['Content-Type'] = 'application/json';
6465
$response = $this->client->post($uri, [
@@ -69,7 +70,7 @@ public function json($uri, $data = [], $headers = [])
6970
return $this->packer->unpack((string) $response->getBody());
7071
}
7172

72-
public function file($uri, $data = [], $headers = [])
73+
public function file(string|UriInterface $uri, array $data = [], array $headers = [])
7374
{
7475
$multipart = [];
7576
if (Arr::isAssoc($data)) {
@@ -95,7 +96,7 @@ public function file($uri, $data = [], $headers = [])
9596
return $this->packer->unpack((string) $response->getBody());
9697
}
9798

98-
public function client()
99+
public function client(): Client
99100
{
100101
return $this->client;
101102
}

0 commit comments

Comments
 (0)