Skip to content

Upgrade library for PHP 8 compatibility #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}
},
"require": {
"php": "^7.1 || ^8.3",
"php": "^8.3",
"ext-curl": "*",
"ext-mbstring": "*",
"chroma-x/url-util": "~2.0",
Expand Down
63 changes: 9 additions & 54 deletions src/BasicHttpClient.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace ChromaX\BasicHttpClient;

use ChromaX\BasicHttpClient\Request\RequestInterface;
Expand All @@ -21,16 +23,8 @@
class BasicHttpClient implements HttpClientInterface
{

/**
* @var RequestInterface
*/
private $request;
private RequestInterface $request;

/**
* BasicHttpClient constructor.
*
* @param string $endpoint
*/
public function __construct(string $endpoint)
{
$url = new Url($endpoint);
Expand All @@ -45,21 +39,12 @@ public function __construct(string $endpoint)
->setUrl(new Url($endpoint));
}

/**
* @return RequestInterface
*/
public function getRequest(): RequestInterface
{
return $this->request;
}

/**
* @param mixed[] $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)
Expand All @@ -69,13 +54,7 @@ public function get(array $queryParameters = array()): ResponseInterface
return $this->request->getResponse();
}

/**
* @param mixed[] $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)
Expand All @@ -85,13 +64,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
{
$body = new Body();
$body->setBodyTextFromArray($postData);
Expand All @@ -104,13 +77,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
{
$body = new Body();
$body->setBodyTextFromArray($putData);
Expand All @@ -123,13 +90,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
{
$body = new Body();
$body->setBodyTextFromArray($patchData);
Expand All @@ -142,13 +103,7 @@ public function patch(array $patchData = array()): ResponseInterface
return $this->request->getResponse();
}

/**
* @param mixed[] $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)
Expand Down
2 changes: 2 additions & 0 deletions src/Exception/HttpRequestAuthenticationException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace ChromaX\BasicHttpClient\Exception;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Exception/HttpRequestException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace ChromaX\BasicHttpClient\Exception;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Exception/HttpRequestMessageException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace ChromaX\BasicHttpClient\Exception;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Exception/HttpResponseException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace ChromaX\BasicHttpClient\Exception;

/**
Expand Down
50 changes: 12 additions & 38 deletions src/HttpClientInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace ChromaX\BasicHttpClient;

use ChromaX\BasicHttpClient\Request\RequestInterface;
Expand All @@ -13,45 +15,17 @@
interface HttpClientInterface
{

/**
* @return RequestInterface
*/
public function getRequest(): RequestInterface;

/**
* @param mixed[] $queryParameters
* @return ResponseInterface
*/
public function get(array $queryParameters = array()): ResponseInterface;

/**
* @param mixed[] $queryParameters
* @return ResponseInterface
*/
public function head(array $queryParameters = array()): ResponseInterface;

/**
* @param array $postData
* @return ResponseInterface
*/
public function post(array $postData = array()): ResponseInterface;

/**
* @param array $putData
* @return ResponseInterface
*/
public function put(array $putData = array()): ResponseInterface;

/**
* @param array $patchData
* @return ResponseInterface
*/
public function patch(array $patchData = array()): ResponseInterface;

/**
* @param mixed[] $queryParameters
* @return ResponseInterface
*/
public function delete(array $queryParameters = array()): ResponseInterface;
public function get(array $queryParameters = []): ResponseInterface;

public function head(array $queryParameters = []): ResponseInterface;

public function post(array $postData = []): ResponseInterface;

public function put(array $putData = []): ResponseInterface;

public function patch(array $patchData = []): ResponseInterface;

public function delete(array $queryParameters = []): ResponseInterface;
}
Loading