Skip to content

Commit fa0cf13

Browse files
authoredAug 2, 2024
Merge pull request #1 from andriusbaliutis/master
Make package compatible with PHP 8.3
2 parents f5e925d + 7375680 commit fa0cf13

File tree

5 files changed

+29
-81
lines changed

5 files changed

+29
-81
lines changed
 

‎composer.json

+9-4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@
1010
"Basic Auth",
1111
"Client Certificate Auth"
1212
],
13-
"homepage": "http://chroma-x.de/",
13+
"homepage": "https://chroma-x.de/",
1414
"license": "MIT",
1515
"authors": [
1616
{
1717
"name": "Martin Brecht-Precht",
1818
"email": "mb@chroma-x.de",
19-
"homepage": "http://chroma-x.de"
19+
"homepage": "https://chroma-x.de"
20+
},
21+
{
22+
"name": "Andrius Baliutis",
23+
"email": "ab@chroma-x.de",
24+
"homepage": "https://chroma-x.de"
2025
}
2126
],
2227
"autoload": {
@@ -25,10 +30,10 @@
2530
}
2631
},
2732
"require": {
28-
"php": "^7.1 || ^8.3",
33+
"php": "^8.3",
2934
"ext-curl": "*",
3035
"ext-json": "*",
3136
"ext-mbstring": "*",
32-
"chroma-x/basic-http-client": "~3.0"
37+
"chroma-x/basic-http-client": "~4.0"
3338
}
3439
}

‎src/JsonHttpClient.php

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

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

57
use ChromaX\BasicHttpClient\HttpClientInterface;
@@ -23,17 +25,9 @@
2325
class JsonHttpClient implements HttpClientInterface
2426
{
2527

26-
/**
27-
* @var RequestInterface
28-
*/
29-
private $request;
28+
private RequestInterface $request;
3029

31-
/**
32-
* BasicHttpClient constructor.
33-
*
34-
* @param string $endpoint
35-
*/
36-
public function __construct($endpoint)
30+
public function __construct(string $endpoint)
3731
{
3832
$url = new Url($endpoint);
3933
$transport = new HttpTransport();
@@ -51,21 +45,15 @@ public function __construct($endpoint)
5145
->setUrl($url);
5246
}
5347

54-
/**
55-
* @return RequestInterface
56-
*/
5748
public function getRequest(): RequestInterface
5849
{
5950
return $this->request;
6051
}
6152

6253
/**
6354
* @param string[] $queryParameters
64-
* @return ResponseInterface
65-
* @throws NetworkException
66-
* @throws ConnectionTimeoutException
6755
*/
68-
public function get(array $queryParameters = array()): ResponseInterface
56+
public function get(array $queryParameters = []): ResponseInterface
6957
{
7058
$this->request
7159
->setMethod(RequestInterface::REQUEST_METHOD_GET)
@@ -77,11 +65,8 @@ public function get(array $queryParameters = array()): ResponseInterface
7765

7866
/**
7967
* @param string[] $queryParameters
80-
* @return ResponseInterface
81-
* @throws NetworkException
82-
* @throws ConnectionTimeoutException
8368
*/
84-
public function head(array $queryParameters = array()): ResponseInterface
69+
public function head(array $queryParameters = []): ResponseInterface
8570
{
8671
$this->request
8772
->setMethod(RequestInterface::REQUEST_METHOD_HEAD)
@@ -91,13 +76,7 @@ public function head(array $queryParameters = array()): ResponseInterface
9176
return $this->request->getResponse();
9277
}
9378

94-
/**
95-
* @param array $postData
96-
* @return ResponseInterface
97-
* @throws NetworkException
98-
* @throws ConnectionTimeoutException
99-
*/
100-
public function post(array $postData = array()): ResponseInterface
79+
public function post(array $postData = []): ResponseInterface
10180
{
10281
$this->request
10382
->getMessage()
@@ -108,13 +87,7 @@ public function post(array $postData = array()): ResponseInterface
10887
return $this->request->getResponse();
10988
}
11089

111-
/**
112-
* @param array $putData
113-
* @return ResponseInterface
114-
* @throws NetworkException
115-
* @throws ConnectionTimeoutException
116-
*/
117-
public function put(array $putData = array()): ResponseInterface
90+
public function put(array $putData = []): ResponseInterface
11891
{
11992
$this->request
12093
->getMessage()
@@ -125,13 +98,7 @@ public function put(array $putData = array()): ResponseInterface
12598
return $this->request->getResponse();
12699
}
127100

128-
/**
129-
* @param array $patchData
130-
* @return ResponseInterface
131-
* @throws NetworkException
132-
* @throws ConnectionTimeoutException
133-
*/
134-
public function patch(array $patchData = array()): ResponseInterface
101+
public function patch(array $patchData = []): ResponseInterface
135102
{
136103
$this->request
137104
->getMessage()
@@ -142,13 +109,7 @@ public function patch(array $patchData = array()): ResponseInterface
142109
return $this->request->getResponse();
143110
}
144111

145-
/**
146-
* @param string[] $queryParameters
147-
* @return ResponseInterface
148-
* @throws NetworkException
149-
* @throws ConnectionTimeoutException
150-
*/
151-
public function delete(array $queryParameters = array()): ResponseInterface
112+
public function delete(array $queryParameters = []): ResponseInterface
152113
{
153114
$this->request
154115
->setMethod(RequestInterface::REQUEST_METHOD_DELETE)

‎src/Request/JsonRequest.php

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

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

57
use ChromaX\BasicHttpClient\Request\AbstractRequest;
@@ -14,9 +16,6 @@
1416
class JsonRequest extends AbstractRequest
1517
{
1618

17-
/**
18-
* @return ResponseInterface
19-
*/
2019
protected function buildResponse(): ResponseInterface
2120
{
2221
return new JsonResponse($this);

‎src/Request/Message/Body/JsonBody.php

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

3+
declare(strict_types=1);
4+
35
namespace ChromaX\JsonHttpClient\Request\Message\Body;
46

57
use ChromaX\BasicHttpClient\Exception\HttpRequestMessageException;
@@ -13,27 +15,14 @@
1315
class JsonBody implements BodyInterface
1416
{
1517

16-
/**
17-
* @var array
18-
*/
19-
private $bodyData;
18+
private array $bodyData;
2019

21-
/**
22-
* Body constructor.
23-
*
24-
* @param array $bodyData
25-
*/
2620
public function __construct(array $bodyData)
2721
{
2822
$this->bodyData = $bodyData;
2923
}
3024

31-
/**
32-
* @param resource $curl
33-
* @return $this
34-
* @throws HttpRequestMessageException
35-
*/
36-
public function configureCurl($curl)
25+
public function configureCurl(\CurlHandle $curl): self
3726
{
3827
$jsonBody = json_encode($this->bodyData);
3928
if ($jsonBody === false) {

‎src/Response/JsonResponse.php

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

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

57
use ChromaX\BasicHttpClient\Exception\HttpResponseException;
@@ -13,12 +15,7 @@
1315
class JsonResponse extends AbstractResponse
1416
{
1517

16-
/**
17-
* @param mixed $body
18-
* @return $this
19-
* @throws HttpResponseException
20-
*/
21-
protected function setBody($body)
18+
protected function setBody(mixed $body): self
2219
{
2320
if ($this->getStatusCode() === 204) {
2421
parent::setBody(null);
@@ -31,10 +28,7 @@ protected function setBody($body)
3128
parent::setBody($body);
3229
return $this;
3330
}
34-
35-
/**
36-
* @return array
37-
*/
31+
3832
public function getBody(): array
3933
{
4034
return parent::getBody();

0 commit comments

Comments
 (0)
Please sign in to comment.