Skip to content

Commit

Permalink
fix issues with newer depdendencies removing some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
scottaubrey committed Oct 23, 2024
1 parent 38c965e commit 55ff2ef
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/HttpClient/BatchingHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -40,7 +40,7 @@ private function filterResolvedRequests()

private function waitOnBatch()
{
all($this->batch)->wait();
Utils::all($this->batch)->wait();

$this->batch = [];
}
Expand Down
4 changes: 2 additions & 2 deletions src/HttpClient/ForbiddingHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
4 changes: 2 additions & 2 deletions src/HttpClient/Guzzle6HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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')) {
Expand Down
4 changes: 2 additions & 2 deletions src/Log/HttpMessageProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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));
}
}
4 changes: 2 additions & 2 deletions src/MediaType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace eLife\ApiClient;

use Assert\Assertion;
use function GuzzleHttp\Psr7\parse_header;
use GuzzleHttp\Psr7\Header;

final class MediaType
{
Expand All @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions src/Result/ArrayResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/Result/HttpResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use InvalidArgumentException;
use Iterator;
use IteratorAggregate;
use function JmesPath\search;
use Psr\Http\Message\ResponseInterface;
use UnexpectedValueException;

Expand Down
4 changes: 2 additions & 2 deletions test/HttpClient/NotifyingHttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 55ff2ef

Please sign in to comment.