Skip to content

Commit 20bc9ef

Browse files
committed
Upgrade library for PHP 8 compatibility
1 parent ee39e9c commit 20bc9ef

31 files changed

+280
-1178
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626
},
2727
"require": {
28-
"php": "^7.1 || ^8.3",
28+
"php": "^8.3",
2929
"ext-curl": "*",
3030
"ext-mbstring": "*",
3131
"chroma-x/url-util": "~2.0",

src/BasicHttpClient.php

+9-54
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace ChromaX\BasicHttpClient;
46

57
use ChromaX\BasicHttpClient\Request\RequestInterface;
@@ -21,16 +23,8 @@
2123
class BasicHttpClient implements HttpClientInterface
2224
{
2325

24-
/**
25-
* @var RequestInterface
26-
*/
27-
private $request;
26+
private RequestInterface $request;
2827

29-
/**
30-
* BasicHttpClient constructor.
31-
*
32-
* @param string $endpoint
33-
*/
3428
public function __construct(string $endpoint)
3529
{
3630
$url = new Url($endpoint);
@@ -45,21 +39,12 @@ public function __construct(string $endpoint)
4539
->setUrl(new Url($endpoint));
4640
}
4741

48-
/**
49-
* @return RequestInterface
50-
*/
5142
public function getRequest(): RequestInterface
5243
{
5344
return $this->request;
5445
}
5546

56-
/**
57-
* @param mixed[] $queryParameters
58-
* @return ResponseInterface
59-
* @throws NetworkException
60-
* @throws ConnectionTimeoutException
61-
*/
62-
public function get(array $queryParameters = array()): ResponseInterface
47+
public function get(array $queryParameters = []): ResponseInterface
6348
{
6449
$this->request
6550
->setMethod(RequestInterface::REQUEST_METHOD_GET)
@@ -69,13 +54,7 @@ public function get(array $queryParameters = array()): ResponseInterface
6954
return $this->request->getResponse();
7055
}
7156

72-
/**
73-
* @param mixed[] $queryParameters
74-
* @return ResponseInterface
75-
* @throws NetworkException
76-
* @throws ConnectionTimeoutException
77-
*/
78-
public function head(array $queryParameters = array()): ResponseInterface
57+
public function head(array $queryParameters = []): ResponseInterface
7958
{
8059
$this->request
8160
->setMethod(RequestInterface::REQUEST_METHOD_HEAD)
@@ -85,13 +64,7 @@ public function head(array $queryParameters = array()): ResponseInterface
8564
return $this->request->getResponse();
8665
}
8766

88-
/**
89-
* @param array $postData
90-
* @return ResponseInterface
91-
* @throws NetworkException
92-
* @throws ConnectionTimeoutException
93-
*/
94-
public function post(array $postData = array()): ResponseInterface
67+
public function post(array $postData = []): ResponseInterface
9568
{
9669
$body = new Body();
9770
$body->setBodyTextFromArray($postData);
@@ -104,13 +77,7 @@ public function post(array $postData = array()): ResponseInterface
10477
return $this->request->getResponse();
10578
}
10679

107-
/**
108-
* @param array $putData
109-
* @return ResponseInterface
110-
* @throws NetworkException
111-
* @throws ConnectionTimeoutException
112-
*/
113-
public function put(array $putData = array()): ResponseInterface
80+
public function put(array $putData = []): ResponseInterface
11481
{
11582
$body = new Body();
11683
$body->setBodyTextFromArray($putData);
@@ -123,13 +90,7 @@ public function put(array $putData = array()): ResponseInterface
12390
return $this->request->getResponse();
12491
}
12592

126-
/**
127-
* @param array $patchData
128-
* @return ResponseInterface
129-
* @throws NetworkException
130-
* @throws ConnectionTimeoutException
131-
*/
132-
public function patch(array $patchData = array()): ResponseInterface
93+
public function patch(array $patchData = []): ResponseInterface
13394
{
13495
$body = new Body();
13596
$body->setBodyTextFromArray($patchData);
@@ -142,13 +103,7 @@ public function patch(array $patchData = array()): ResponseInterface
142103
return $this->request->getResponse();
143104
}
144105

145-
/**
146-
* @param mixed[] $queryParameters
147-
* @return ResponseInterface
148-
* @throws NetworkException
149-
* @throws ConnectionTimeoutException
150-
*/
151-
public function delete(array $queryParameters = array()): ResponseInterface
106+
public function delete(array $queryParameters = []): ResponseInterface
152107
{
153108
$this->request
154109
->setMethod(RequestInterface::REQUEST_METHOD_DELETE)

src/Exception/HttpRequestAuthenticationException.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace ChromaX\BasicHttpClient\Exception;
46

57
/**

src/Exception/HttpRequestException.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace ChromaX\BasicHttpClient\Exception;
46

57
/**

src/Exception/HttpRequestMessageException.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace ChromaX\BasicHttpClient\Exception;
46

57
/**

src/Exception/HttpResponseException.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace ChromaX\BasicHttpClient\Exception;
46

57
/**

src/HttpClientInterface.php

+12-38
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace ChromaX\BasicHttpClient;
46

57
use ChromaX\BasicHttpClient\Request\RequestInterface;
@@ -13,45 +15,17 @@
1315
interface HttpClientInterface
1416
{
1517

16-
/**
17-
* @return RequestInterface
18-
*/
1918
public function getRequest(): RequestInterface;
2019

21-
/**
22-
* @param mixed[] $queryParameters
23-
* @return ResponseInterface
24-
*/
25-
public function get(array $queryParameters = array()): ResponseInterface;
26-
27-
/**
28-
* @param mixed[] $queryParameters
29-
* @return ResponseInterface
30-
*/
31-
public function head(array $queryParameters = array()): ResponseInterface;
32-
33-
/**
34-
* @param array $postData
35-
* @return ResponseInterface
36-
*/
37-
public function post(array $postData = array()): ResponseInterface;
38-
39-
/**
40-
* @param array $putData
41-
* @return ResponseInterface
42-
*/
43-
public function put(array $putData = array()): ResponseInterface;
44-
45-
/**
46-
* @param array $patchData
47-
* @return ResponseInterface
48-
*/
49-
public function patch(array $patchData = array()): ResponseInterface;
50-
51-
/**
52-
* @param mixed[] $queryParameters
53-
* @return ResponseInterface
54-
*/
55-
public function delete(array $queryParameters = array()): ResponseInterface;
20+
public function get(array $queryParameters = []): ResponseInterface;
21+
22+
public function head(array $queryParameters = []): ResponseInterface;
23+
24+
public function post(array $postData = []): ResponseInterface;
25+
26+
public function put(array $putData = []): ResponseInterface;
27+
28+
public function patch(array $patchData = []): ResponseInterface;
5629

30+
public function delete(array $queryParameters = []): ResponseInterface;
5731
}

0 commit comments

Comments
 (0)