From 55ff2efc57d61c89b4c1dd66237cc7ff619b46e0 Mon Sep 17 00:00:00 2001 From: Scott Aubrey Date: Wed, 23 Oct 2024 04:54:29 +0100 Subject: [PATCH] fix issues with newer depdendencies removing some functions --- src/ApiClient.php | 4 ++-- src/HttpClient/BatchingHttpClient.php | 4 ++-- src/HttpClient/ForbiddingHttpClient.php | 4 ++-- src/HttpClient/Guzzle6HttpClient.php | 4 ++-- src/Log/HttpMessageProcessor.php | 4 ++-- src/MediaType.php | 4 ++-- src/Result/ArrayResult.php | 4 ++-- src/Result/HttpResult.php | 1 - test/HttpClient/NotifyingHttpClientTest.php | 4 ++-- 9 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/ApiClient.php b/src/ApiClient.php index d2bf5cb..9344ae9 100644 --- a/src/ApiClient.php +++ b/src/ApiClient.php @@ -4,7 +4,7 @@ use eLife\ApiClient\HttpClient\UserAgentPrependingHttpClient; use GuzzleHttp\Promise\PromiseInterface; -use function GuzzleHttp\Psr7\build_query; +use GuzzleHttp\Psr7\Query; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Uri; use Psr\Http\Message\StreamInterface; @@ -64,7 +64,7 @@ final protected function putRequest( final protected function createUri(array $parts) : UriInterface { if (!empty($parts['query'])) { - $parts['query'] = build_query(array_filter($parts['query']), false); + $parts['query'] = Query::build(array_filter($parts['query']), false); } return Uri::fromParts($parts); diff --git a/src/HttpClient/BatchingHttpClient.php b/src/HttpClient/BatchingHttpClient.php index ba8cb9a..67f2a77 100644 --- a/src/HttpClient/BatchingHttpClient.php +++ b/src/HttpClient/BatchingHttpClient.php @@ -3,8 +3,8 @@ namespace eLife\ApiClient\HttpClient; use eLife\ApiClient\HttpClient; -use function GuzzleHttp\Promise\all; use GuzzleHttp\Promise\PromiseInterface; +use GuzzleHttp\Promise\Utils; use Psr\Http\Message\RequestInterface; final class BatchingHttpClient implements HttpClient @@ -40,7 +40,7 @@ private function filterResolvedRequests() private function waitOnBatch() { - all($this->batch)->wait(); + Utils::all($this->batch)->wait(); $this->batch = []; } diff --git a/src/HttpClient/ForbiddingHttpClient.php b/src/HttpClient/ForbiddingHttpClient.php index 7ac891d..0029420 100644 --- a/src/HttpClient/ForbiddingHttpClient.php +++ b/src/HttpClient/ForbiddingHttpClient.php @@ -4,14 +4,14 @@ use eLife\ApiClient\Exception\UnintendedInteraction; use eLife\ApiClient\HttpClient; +use GuzzleHttp\Promise\Create; use GuzzleHttp\Promise\PromiseInterface; -use function GuzzleHttp\Promise\rejection_for; use Psr\Http\Message\RequestInterface; final class ForbiddingHttpClient implements HttpClient { public function send(RequestInterface $request) : PromiseInterface { - return rejection_for(new UnintendedInteraction('Forbidden call', $request)); + return Create::rejectionFor(new UnintendedInteraction('Forbidden call', $request)); } } diff --git a/src/HttpClient/Guzzle6HttpClient.php b/src/HttpClient/Guzzle6HttpClient.php index c375a9b..ecb9369 100644 --- a/src/HttpClient/Guzzle6HttpClient.php +++ b/src/HttpClient/Guzzle6HttpClient.php @@ -16,7 +16,7 @@ use GuzzleHttp\Exception\BadResponseException; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; -use function GuzzleHttp\Promise\exception_for; +use GuzzleHttp\Promise\Create; use GuzzleHttp\Promise\PromiseInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -41,7 +41,7 @@ function (ResponseInterface $response) { } )->otherwise( function ($reason) { - $e = exception_for($reason); + $e = Create::exceptionFor($reason); if ($e instanceof BadResponseException) { if ('application/problem+json' === $e->getResponse()->getHeaderLine('Content-Type')) { diff --git a/src/Log/HttpMessageProcessor.php b/src/Log/HttpMessageProcessor.php index 6fe6ce4..d7cce0b 100644 --- a/src/Log/HttpMessageProcessor.php +++ b/src/Log/HttpMessageProcessor.php @@ -4,7 +4,7 @@ use eLife\ApiClient\Exception\BadResponse; use eLife\ApiClient\Exception\HttpProblem; -use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\Message; use Psr\Http\Message\MessageInterface; final class HttpMessageProcessor @@ -26,6 +26,6 @@ public function __invoke(array $record) private function dumpHttpMessage(MessageInterface $message) { - return str_replace("\r", '', Psr7\str($message)); + return str_replace("\r", '', Message::toString($message)); } } diff --git a/src/MediaType.php b/src/MediaType.php index 7e53f90..fb12f85 100644 --- a/src/MediaType.php +++ b/src/MediaType.php @@ -3,7 +3,7 @@ namespace eLife\ApiClient; use Assert\Assertion; -use function GuzzleHttp\Psr7\parse_header; +use GuzzleHttp\Psr7\Header; final class MediaType { @@ -23,7 +23,7 @@ public static function fromString(string $header) { Assertion::notBlank($header, 'Media type is blank'); - $contentType = parse_header($header)[0]; + $contentType = Header::parse($header)[0]; Assertion::keyExists($contentType, 0, "'$header' is not a valid media type"); Assertion::keyExists($contentType, 'version', "Media type '$header' is missing a version parameter"); diff --git a/src/Result/ArrayResult.php b/src/Result/ArrayResult.php index 84bfdf1..29c1ed0 100644 --- a/src/Result/ArrayResult.php +++ b/src/Result/ArrayResult.php @@ -8,7 +8,7 @@ use eLife\ApiClient\Result; use Iterator; use IteratorAggregate; -use function JmesPath\search; +use JmesPath\Env; final class ArrayResult implements IteratorAggregate, Result { @@ -37,7 +37,7 @@ public function search(string $expression) throw new BadMethodCallException('Requires mtdowling/jmespath.php'); } - return search($expression, $this->data); + return Env::search($expression, $this->data); } public function offsetExists($offset) : bool diff --git a/src/Result/HttpResult.php b/src/Result/HttpResult.php index 58e25e5..02871ce 100644 --- a/src/Result/HttpResult.php +++ b/src/Result/HttpResult.php @@ -7,7 +7,6 @@ use InvalidArgumentException; use Iterator; use IteratorAggregate; -use function JmesPath\search; use Psr\Http\Message\ResponseInterface; use UnexpectedValueException; diff --git a/test/HttpClient/NotifyingHttpClientTest.php b/test/HttpClient/NotifyingHttpClientTest.php index cb07917..3fd1fda 100644 --- a/test/HttpClient/NotifyingHttpClientTest.php +++ b/test/HttpClient/NotifyingHttpClientTest.php @@ -4,7 +4,7 @@ use eLife\ApiClient\HttpClient; use PHPUnit\Framework\TestCase; -use function GuzzleHttp\Promise\promise_for; +use GuzzleHttp\Promise\Create; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use RuntimeException; @@ -34,7 +34,7 @@ public function it_allows_listeners_to_monitor_requests() $this->originalClient->expects($this->once()) ->method('send') ->with($request) - ->will($this->returnValue(promise_for($response))); + ->will($this->returnValue(Create::promiseFor($response))); $this->sentRequests = []; $this->client->addRequestListener(function ($request) { $this->sentRequests[] = $request;