Skip to content
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

fix: add php 8.4 compatibility to latest 7.4 release #2645

Merged
merged 1 commit into from
Dec 12, 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
3 changes: 2 additions & 1 deletion .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ branchProtectionRules:
- 'PHP 8.1 Unit Test'
- 'PHP 8.2 Unit Test'
- 'PHP 8.3 Unit Test'
- 'PHP 8.3 --prefer-lowest Unit Test'
- 'PHP 8.4'
- 'PHP 8.4 --prefer-lowest Unit Test'
- 'PHP Style Check'
- 'cla/google'
requiredApprovingReviewCount: 1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
php: [ "7.4", "8.0", "8.1", "8.2", "8.3", "8.4" ]
composer-flags: [""]
include:
- php: "7.4"
composer-flags: "--prefer-lowest "
- php: "8.3"
- php: "8.4"
composer-flags: "--prefer-lowest "
name: PHP ${{ matrix.php }} ${{ matrix.composer-flags }}Unit Test
steps:
Expand Down
2 changes: 1 addition & 1 deletion src/AccessToken/Revoke.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Revoke
* Instantiates the class, but does not initiate the login flow, leaving it
* to the discretion of the caller.
*/
public function __construct(ClientInterface $http = null)
public function __construct(?ClientInterface $http = null)
{
$this->http = $http;
}
Expand Down
4 changes: 2 additions & 2 deletions src/AccessToken/Verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class Verify
* to the discretion of the caller.
*/
public function __construct(
ClientInterface $http = null,
CacheItemPoolInterface $cache = null,
?ClientInterface $http = null,
?CacheItemPoolInterface $cache = null,
$jwt = null
) {
if (null === $http) {
Expand Down
6 changes: 3 additions & 3 deletions src/AuthHandler/Guzzle6AuthHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Guzzle6AuthHandler
protected $cache;
protected $cacheConfig;

public function __construct(CacheItemPoolInterface $cache = null, array $cacheConfig = [])
public function __construct(?CacheItemPoolInterface $cache = null, array $cacheConfig = [])
{
$this->cache = $cache;
$this->cacheConfig = $cacheConfig;
Expand All @@ -29,7 +29,7 @@ public function __construct(CacheItemPoolInterface $cache = null, array $cacheCo
public function attachCredentials(
ClientInterface $http,
CredentialsLoader $credentials,
callable $tokenCallback = null
?callable $tokenCallback = null
) {
// use the provided cache
if ($this->cache) {
Expand All @@ -46,7 +46,7 @@ public function attachCredentials(
public function attachCredentialsCache(
ClientInterface $http,
FetchAuthTokenCache $credentials,
callable $tokenCallback = null
?callable $tokenCallback = null
) {
// if we end up needing to make an HTTP request to retrieve credentials, we
// can use our existing one, but we need to throw exceptions so the error
Expand Down
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public function refreshTokenWithAssertion()
* @param ClientInterface $authHttp optional.
* @return array access token
*/
public function fetchAccessTokenWithAssertion(ClientInterface $authHttp = null)
public function fetchAccessTokenWithAssertion(?ClientInterface $authHttp = null)
{
if (!$this->isUsingApplicationDefaultCredentials()) {
throw new DomainException(
Expand Down Expand Up @@ -448,7 +448,7 @@ public function createAuthUrl($scope = null, array $queryParams = [])
* @param ClientInterface $http the http client object.
* @return ClientInterface the http client object
*/
public function authorize(ClientInterface $http = null)
public function authorize(?ClientInterface $http = null)
{
$http = $http ?: $this->getHttpClient();
$authHandler = $this->getAuthHandler();
Expand Down
8 changes: 4 additions & 4 deletions src/Http/REST.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ interface_exists('\GuzzleHttp\Message\ResponseInterface')
*/
public static function decodeHttpResponse(
ResponseInterface $response,
RequestInterface $request = null,
?RequestInterface $request = null,
$expectedClass = null
) {
$code = $response->getStatusCode();
Expand All @@ -147,7 +147,7 @@ public static function decodeHttpResponse(
return $response;
}

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

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

private static function isAltMedia(RequestInterface $request = null)
private static function isAltMedia(?RequestInterface $request = null)
{
if ($request && $qs = $request->getUri()->getQuery()) {
parse_str($qs, $query);
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Exception extends GoogleException
public function __construct(
$message,
$code = 0,
Exception $previous = null,
?Exception $previous = null,
$errors = []
) {
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Task/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Composer
*/
public static function cleanup(
Event $event,
Filesystem $filesystem = null
?Filesystem $filesystem = null
) {
$composer = $event->getComposer();
$extra = $composer->getPackage()->getExtra();
Expand Down
7 changes: 4 additions & 3 deletions tests/Google/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -698,13 +698,14 @@ public function testOnGceCacheAndCacheOptions()
$mockUniverseDomainCacheItem->get()
->shouldBeCalledTimes(1)
->willReturn('googleapis.com');

$mockCache = $this->prophesize(CacheItemPoolInterface::class);
$mockCache->getItem($prefix . GCECache::GCE_CACHE_KEY)
->shouldBeCalledTimes(1)
->willReturn($mockCacheItem->reveal());
$mockCache->getItem(GCECredentials::cacheKey . 'universe_domain')
->shouldBeCalledTimes(1)
// cache key from GCECredentials::getTokenUri() . 'universe_domain'
$mockCache->getItem('cc685e3a0717258b6a4cefcb020e96de6bcf904e76fd9fc1647669f42deff9bf') // google/auth < 1.41.0
->willReturn($mockUniverseDomainCacheItem->reveal());
$mockCache->getItem(GCECredentials::cacheKey . 'universe_domain') // google/auth >= 1.41.0
->willReturn($mockUniverseDomainCacheItem->reveal());

$client = new Client(['cache_config' => $cacheConfig]);
Expand Down
Loading