Skip to content

Commit 067fa5f

Browse files
committed
fix: add php 8.4 compatibility to latest 7.4 release
1 parent 017400f commit 067fa5f

File tree

10 files changed

+22
-20
lines changed

10 files changed

+22
-20
lines changed

Diff for: .github/sync-repo-settings.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ branchProtectionRules:
1111
- 'PHP 8.1 Unit Test'
1212
- 'PHP 8.2 Unit Test'
1313
- 'PHP 8.3 Unit Test'
14-
- 'PHP 8.3 --prefer-lowest Unit Test'
14+
- 'PHP 8.4'
15+
- 'PHP 8.4 --prefer-lowest Unit Test'
1516
- 'PHP Style Check'
1617
- 'cla/google'
1718
requiredApprovingReviewCount: 1

Diff for: .github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
14+
php: [ "7.4", "8.0", "8.1", "8.2", "8.3", "8.4" ]
1515
composer-flags: [""]
1616
include:
1717
- php: "7.4"
1818
composer-flags: "--prefer-lowest "
19-
- php: "8.3"
19+
- php: "8.4"
2020
composer-flags: "--prefer-lowest "
2121
name: PHP ${{ matrix.php }} ${{ matrix.composer-flags }}Unit Test
2222
steps:

Diff for: src/AccessToken/Revoke.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Revoke
3939
* Instantiates the class, but does not initiate the login flow, leaving it
4040
* to the discretion of the caller.
4141
*/
42-
public function __construct(ClientInterface $http = null)
42+
public function __construct(?ClientInterface $http = null)
4343
{
4444
$this->http = $http;
4545
}

Diff for: src/AccessToken/Verify.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class Verify
6767
* to the discretion of the caller.
6868
*/
6969
public function __construct(
70-
ClientInterface $http = null,
71-
CacheItemPoolInterface $cache = null,
70+
?ClientInterface $http = null,
71+
?CacheItemPoolInterface $cache = null,
7272
$jwt = null
7373
) {
7474
if (null === $http) {

Diff for: src/AuthHandler/Guzzle6AuthHandler.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Guzzle6AuthHandler
2020
protected $cache;
2121
protected $cacheConfig;
2222

23-
public function __construct(CacheItemPoolInterface $cache = null, array $cacheConfig = [])
23+
public function __construct(?CacheItemPoolInterface $cache = null, array $cacheConfig = [])
2424
{
2525
$this->cache = $cache;
2626
$this->cacheConfig = $cacheConfig;
@@ -29,7 +29,7 @@ public function __construct(CacheItemPoolInterface $cache = null, array $cacheCo
2929
public function attachCredentials(
3030
ClientInterface $http,
3131
CredentialsLoader $credentials,
32-
callable $tokenCallback = null
32+
?callable $tokenCallback = null
3333
) {
3434
// use the provided cache
3535
if ($this->cache) {
@@ -46,7 +46,7 @@ public function attachCredentials(
4646
public function attachCredentialsCache(
4747
ClientInterface $http,
4848
FetchAuthTokenCache $credentials,
49-
callable $tokenCallback = null
49+
?callable $tokenCallback = null
5050
) {
5151
// if we end up needing to make an HTTP request to retrieve credentials, we
5252
// can use our existing one, but we need to throw exceptions so the error

Diff for: src/Client.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public function refreshTokenWithAssertion()
315315
* @param ClientInterface $authHttp optional.
316316
* @return array access token
317317
*/
318-
public function fetchAccessTokenWithAssertion(ClientInterface $authHttp = null)
318+
public function fetchAccessTokenWithAssertion(?ClientInterface $authHttp = null)
319319
{
320320
if (!$this->isUsingApplicationDefaultCredentials()) {
321321
throw new DomainException(
@@ -448,7 +448,7 @@ public function createAuthUrl($scope = null, array $queryParams = [])
448448
* @param ClientInterface $http the http client object.
449449
* @return ClientInterface the http client object
450450
*/
451-
public function authorize(ClientInterface $http = null)
451+
public function authorize(?ClientInterface $http = null)
452452
{
453453
$http = $http ?: $this->getHttpClient();
454454
$authHandler = $this->getAuthHandler();

Diff for: src/Http/REST.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ interface_exists('\GuzzleHttp\Message\ResponseInterface')
120120
*/
121121
public static function decodeHttpResponse(
122122
ResponseInterface $response,
123-
RequestInterface $request = null,
123+
?RequestInterface $request = null,
124124
$expectedClass = null
125125
) {
126126
$code = $response->getStatusCode();
@@ -147,7 +147,7 @@ public static function decodeHttpResponse(
147147
return $response;
148148
}
149149

150-
private static function decodeBody(ResponseInterface $response, RequestInterface $request = null)
150+
private static function decodeBody(ResponseInterface $response, ?RequestInterface $request = null)
151151
{
152152
if (self::isAltMedia($request)) {
153153
// don't decode the body, it's probably a really long string
@@ -157,7 +157,7 @@ private static function decodeBody(ResponseInterface $response, RequestInterface
157157
return (string) $response->getBody();
158158
}
159159

160-
private static function determineExpectedClass($expectedClass, RequestInterface $request = null)
160+
private static function determineExpectedClass($expectedClass, ?RequestInterface $request = null)
161161
{
162162
// "false" is used to explicitly prevent an expected class from being returned
163163
if (false === $expectedClass) {
@@ -184,7 +184,7 @@ private static function getResponseErrors($body)
184184
return null;
185185
}
186186

187-
private static function isAltMedia(RequestInterface $request = null)
187+
private static function isAltMedia(?RequestInterface $request = null)
188188
{
189189
if ($request && $qs = $request->getUri()->getQuery()) {
190190
parse_str($qs, $query);

Diff for: src/Service/Exception.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Exception extends GoogleException
3939
public function __construct(
4040
$message,
4141
$code = 0,
42-
Exception $previous = null,
42+
?Exception $previous = null,
4343
$errors = []
4444
) {
4545
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {

Diff for: src/Task/Composer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Composer
3030
*/
3131
public static function cleanup(
3232
Event $event,
33-
Filesystem $filesystem = null
33+
?Filesystem $filesystem = null
3434
) {
3535
$composer = $event->getComposer();
3636
$extra = $composer->getPackage()->getExtra();

Diff for: tests/Google/ClientTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -698,13 +698,14 @@ public function testOnGceCacheAndCacheOptions()
698698
$mockUniverseDomainCacheItem->get()
699699
->shouldBeCalledTimes(1)
700700
->willReturn('googleapis.com');
701-
702701
$mockCache = $this->prophesize(CacheItemPoolInterface::class);
703702
$mockCache->getItem($prefix . GCECache::GCE_CACHE_KEY)
704703
->shouldBeCalledTimes(1)
705704
->willReturn($mockCacheItem->reveal());
706-
$mockCache->getItem(GCECredentials::cacheKey . 'universe_domain')
707-
->shouldBeCalledTimes(1)
705+
// cache key from GCECredentials::getTokenUri() . 'universe_domain'
706+
$mockCache->getItem('cc685e3a0717258b6a4cefcb020e96de6bcf904e76fd9fc1647669f42deff9bf') // google/auth < 1.41.0
707+
->willReturn($mockUniverseDomainCacheItem->reveal());
708+
$mockCache->getItem(GCECredentials::cacheKey . 'universe_domain') // google/auth >= 1.41.0
708709
->willReturn($mockUniverseDomainCacheItem->reveal());
709710

710711
$client = new Client(['cache_config' => $cacheConfig]);

0 commit comments

Comments
 (0)