From 755ff43b37357651cd4137c55ccb630881ede5e0 Mon Sep 17 00:00:00 2001 From: andriusbaliutis Date: Fri, 2 Aug 2024 09:39:06 +0200 Subject: [PATCH 1/2] Make package compatible with PHP 8.3 --- composer.json | 8 ++-- src/JsonHttpClient.php | 59 +++++---------------------- src/Request/JsonRequest.php | 5 +-- src/Request/Message/Body/JsonBody.php | 19 ++------- src/Response/JsonResponse.php | 14 ++----- 5 files changed, 24 insertions(+), 81 deletions(-) diff --git a/composer.json b/composer.json index 2c23456..644038f 100644 --- a/composer.json +++ b/composer.json @@ -10,13 +10,13 @@ "Basic Auth", "Client Certificate Auth" ], - "homepage": "http://chroma-x.de/", + "homepage": "https://chroma-x.de/", "license": "MIT", "authors": [ { "name": "Martin Brecht-Precht", "email": "mb@chroma-x.de", - "homepage": "http://chroma-x.de" + "homepage": "https://chroma-x.de" } ], "autoload": { @@ -25,10 +25,10 @@ } }, "require": { - "php": "^7.1 || ^8.3", + "php": "^8.3", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", - "chroma-x/basic-http-client": "~3.0" + "chroma-x/basic-http-client": "~4.0" } } diff --git a/src/JsonHttpClient.php b/src/JsonHttpClient.php index c16a989..89d35b1 100644 --- a/src/JsonHttpClient.php +++ b/src/JsonHttpClient.php @@ -1,5 +1,7 @@ setUrl($url); } - /** - * @return RequestInterface - */ public function getRequest(): RequestInterface { return $this->request; @@ -61,11 +52,8 @@ public function getRequest(): RequestInterface /** * @param string[] $queryParameters - * @return ResponseInterface - * @throws NetworkException - * @throws ConnectionTimeoutException */ - public function get(array $queryParameters = array()): ResponseInterface + public function get(array $queryParameters = []): ResponseInterface { $this->request ->setMethod(RequestInterface::REQUEST_METHOD_GET) @@ -77,11 +65,8 @@ public function get(array $queryParameters = array()): ResponseInterface /** * @param string[] $queryParameters - * @return ResponseInterface - * @throws NetworkException - * @throws ConnectionTimeoutException */ - public function head(array $queryParameters = array()): ResponseInterface + public function head(array $queryParameters = []): ResponseInterface { $this->request ->setMethod(RequestInterface::REQUEST_METHOD_HEAD) @@ -91,13 +76,7 @@ public function head(array $queryParameters = array()): ResponseInterface return $this->request->getResponse(); } - /** - * @param array $postData - * @return ResponseInterface - * @throws NetworkException - * @throws ConnectionTimeoutException - */ - public function post(array $postData = array()): ResponseInterface + public function post(array $postData = []): ResponseInterface { $this->request ->getMessage() @@ -108,13 +87,7 @@ public function post(array $postData = array()): ResponseInterface return $this->request->getResponse(); } - /** - * @param array $putData - * @return ResponseInterface - * @throws NetworkException - * @throws ConnectionTimeoutException - */ - public function put(array $putData = array()): ResponseInterface + public function put(array $putData = []): ResponseInterface { $this->request ->getMessage() @@ -125,13 +98,7 @@ public function put(array $putData = array()): ResponseInterface return $this->request->getResponse(); } - /** - * @param array $patchData - * @return ResponseInterface - * @throws NetworkException - * @throws ConnectionTimeoutException - */ - public function patch(array $patchData = array()): ResponseInterface + public function patch(array $patchData = []): ResponseInterface { $this->request ->getMessage() @@ -142,13 +109,7 @@ public function patch(array $patchData = array()): ResponseInterface return $this->request->getResponse(); } - /** - * @param string[] $queryParameters - * @return ResponseInterface - * @throws NetworkException - * @throws ConnectionTimeoutException - */ - public function delete(array $queryParameters = array()): ResponseInterface + public function delete(array $queryParameters = []): ResponseInterface { $this->request ->setMethod(RequestInterface::REQUEST_METHOD_DELETE) diff --git a/src/Request/JsonRequest.php b/src/Request/JsonRequest.php index 8209905..af98971 100644 --- a/src/Request/JsonRequest.php +++ b/src/Request/JsonRequest.php @@ -1,5 +1,7 @@ bodyData = $bodyData; } - /** - * @param resource $curl - * @return $this - * @throws HttpRequestMessageException - */ - public function configureCurl($curl) + public function configureCurl(\CurlHandle $curl): self { $jsonBody = json_encode($this->bodyData); if ($jsonBody === false) { diff --git a/src/Response/JsonResponse.php b/src/Response/JsonResponse.php index b53ca49..c739004 100644 --- a/src/Response/JsonResponse.php +++ b/src/Response/JsonResponse.php @@ -1,5 +1,7 @@ getStatusCode() === 204) { parent::setBody(null); @@ -31,10 +28,7 @@ protected function setBody($body) parent::setBody($body); return $this; } - - /** - * @return array - */ + public function getBody(): array { return parent::getBody(); From 7375680a94aa701c30925d8dd4aac3b3b3f692ca Mon Sep 17 00:00:00 2001 From: andriusbaliutis Date: Fri, 2 Aug 2024 09:54:15 +0200 Subject: [PATCH 2/2] extend composer.json authors section --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index 644038f..875ff35 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,11 @@ "name": "Martin Brecht-Precht", "email": "mb@chroma-x.de", "homepage": "https://chroma-x.de" + }, + { + "name": "Andrius Baliutis", + "email": "ab@chroma-x.de", + "homepage": "https://chroma-x.de" } ], "autoload": {