Skip to content

Commit

Permalink
feat: Upgrade Guzzlehttp/psr7 version (#4508)
Browse files Browse the repository at this point in the history
* Changed the uses of deprecated functions from GuzzleHttp/Psr7 to alternate methods

* Changed the use of Psr7\stream_for() to Utils::streamFor in a missed Storage file

* Bumped dependency versions of guzzlehttp/psr7, google/auth and google/gax

* Bumped psr7 dependency in Core/

* Updated dependencies in Core and the the packages using Psr7 from google/cloud-core

* Updated dependency of google/cloud-core in Vision
  • Loading branch information
saranshdhingra authored Sep 14, 2021
1 parent f3fff3c commit def93ba
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 23 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"require": {
"php": ">=5.5",
"rize/uri-template": "~0.3",
"google/auth": "^1.12",
"google/auth": "^1.18",
"guzzlehttp/guzzle": "^5.3|^6.0|^7.0",
"guzzlehttp/promises": "^1.3",
"guzzlehttp/psr7": "^1.2",
"guzzlehttp/psr7": "^1.7|^2.0",
"monolog/monolog": "^1.1|^2.0",
"psr/http-message": "1.0.*"
},
Expand All @@ -18,7 +18,7 @@
"squizlabs/php_codesniffer": "2.*",
"phpdocumentor/reflection": "^3.0",
"erusev/parsedown": "^1.6",
"google/gax": "^1.1",
"google/gax": "^1.9",
"opis/closure": "^3",
"google/common-protos": "^1.0"
},
Expand Down
4 changes: 2 additions & 2 deletions src/Blob.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Google\Cloud\Core;

use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Utils;
use Psr\Http\Message\StreamInterface;

/**
Expand Down Expand Up @@ -52,7 +52,7 @@ class Blob
*/
public function __construct($value)
{
$this->value = Psr7\stream_for($value);
$this->value = Utils::streamFor($value);
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

namespace Google\Cloud\Core;

use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\RequestInterface;
Expand Down
4 changes: 2 additions & 2 deletions src/RequestWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Google\Cloud\Core\RequestWrapperTrait;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Utils;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
Expand Down Expand Up @@ -304,7 +304,7 @@ private function applyHeaders(RequestInterface $request)
}
}

return Psr7\modify_request($request, ['set_headers' => $headers]);
return Utils::modifyRequest($request, ['set_headers' => $headers]);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Upload/AbstractUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use Google\Cloud\Core\RequestWrapper;
use Google\Cloud\Core\UriTrait;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Utils;
use Psr\Http\Message\StreamInterface;

/**
Expand Down Expand Up @@ -96,7 +96,7 @@ public function __construct(
array $options = []
) {
$this->requestWrapper = $requestWrapper;
$this->data = Psr7\stream_for($data);
$this->data = Utils::streamFor($data);
$this->uri = $uri;
$this->metadata = isset($options['metadata']) ? $options['metadata'] : [];
$this->chunkSize = isset($options['chunkSize']) ? $options['chunkSize'] : null;
Expand Down
1 change: 0 additions & 1 deletion src/Upload/ResumableUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Google\Cloud\Core\JsonTrait;
use Google\Cloud\Core\RequestWrapper;
use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\LimitStream;
use GuzzleHttp\Psr7\Request;
use Psr\Http\Message\ResponseInterface;
Expand Down
5 changes: 3 additions & 2 deletions src/UriTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

namespace Google\Cloud\Core;

use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Query;
use GuzzleHttp\Psr7\Utils;
use Psr\Http\Message\UriInterface;
use Rize\UriTemplate;

Expand Down Expand Up @@ -59,6 +60,6 @@ public function buildUriWithQuery($uri, array $query)
}
}

return Psr7\uri_for($uri)->withQuery(Psr7\build_query($query));
return Utils::uriFor($uri)->withQuery(Query::build($query));
}
}
7 changes: 3 additions & 4 deletions tests/Unit/Upload/MultipartUploaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
use Google\Cloud\Core\RequestWrapper;
use Google\Cloud\Core\Upload\MultipartUploader;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Promise;
use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Psr7\Utils;
use Prophecy\Argument;
use Psr\Http\Message\RequestInterface;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\StreamInterface;

/**
* @group core
Expand All @@ -38,7 +37,7 @@ class MultipartUploaderTest extends TestCase
public function testUploadsData()
{
$requestWrapper = $this->prophesize(RequestWrapper::class);
$stream = Psr7\stream_for('abcd');
$stream = Utils::streamFor('abcd');
$successBody = '{"canI":"kickIt"}';
$response = new Response(200, [], $successBody);

Expand All @@ -59,7 +58,7 @@ public function testUploadsData()
public function testUploadsAsyncData()
{
$requestWrapper = $this->prophesize(RequestWrapper::class);
$stream = Psr7\stream_for('abcd');
$stream = Utils::streamFor('abcd');
$successBody = '{"canI":"kickIt"}';
$response = new Response(200, [], $successBody);
$promise = Promise\promise_for($response);
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Upload/ResumableUploaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
use Google\Cloud\Core\Exception\GoogleException;
use Google\Cloud\Core\RequestWrapper;
use Google\Cloud\Core\Upload\ResumableUploader;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Utils;
use Prophecy\Argument;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\StreamInterface;
Expand All @@ -41,7 +40,7 @@ class ResumableUploaderTest extends TestCase
public function setUp()
{
$this->requestWrapper = $this->prophesize(RequestWrapper::class);
$this->stream = Psr7\stream_for('abcd');
$this->stream = Utils::streamFor('abcd');
$this->successBody = '{"canI":"kickIt"}';
}

Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Upload/SignedUrlUploaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
use Google\Cloud\Core\Exception\GoogleException;
use Google\Cloud\Core\RequestWrapper;
use Google\Cloud\Core\Upload\SignedUrlUploader;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Utils;
use Prophecy\Argument;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\StreamInterface;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -41,7 +40,7 @@ class SignedUrlUploaderTest extends TestCase
public function setUp()
{
$this->requestWrapper = $this->prophesize(RequestWrapper::class);
$this->stream = Psr7\stream_for('abcd');
$this->stream = Utils::streamFor('abcd');
$this->successBody = '{"canI":"kickIt"}';
}

Expand Down

0 comments on commit def93ba

Please sign in to comment.