Skip to content

Commit 25eed00

Browse files
authored
fix: add PHP 8.4 compatibility to last release compatible with PHP 7.4 (#592)
1 parent 1a7de77 commit 25eed00

35 files changed

+97
-97
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
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
name: PHP ${{matrix.php }} Unit Test
1616
steps:
1717
- uses: actions/checkout@v4

src/AccessToken.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ class AccessToken
6969
* @param CacheItemPoolInterface $cache [optional] A PSR-6 compatible cache implementation.
7070
*/
7171
public function __construct(
72-
callable $httpHandler = null,
73-
CacheItemPoolInterface $cache = null
72+
?callable $httpHandler = null,
73+
?CacheItemPoolInterface $cache = null
7474
) {
7575
$this->httpHandler = $httpHandler
7676
?: HttpHandlerFactory::build(HttpClientCache::getHttpClient());

src/ApplicationDefaultCredentials.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ class ApplicationDefaultCredentials
8989
*/
9090
public static function getSubscriber(// @phpstan-ignore-line
9191
$scope = null,
92-
callable $httpHandler = null,
93-
array $cacheConfig = null,
94-
CacheItemPoolInterface $cache = null
92+
?callable $httpHandler = null,
93+
?array $cacheConfig = null,
94+
?CacheItemPoolInterface $cache = null
9595
) {
9696
$creds = self::getCredentials($scope, $httpHandler, $cacheConfig, $cache);
9797

@@ -119,9 +119,9 @@ public static function getSubscriber(// @phpstan-ignore-line
119119
*/
120120
public static function getMiddleware(
121121
$scope = null,
122-
callable $httpHandler = null,
123-
array $cacheConfig = null,
124-
CacheItemPoolInterface $cache = null,
122+
?callable $httpHandler = null,
123+
?array $cacheConfig = null,
124+
?CacheItemPoolInterface $cache = null,
125125
$quotaProject = null
126126
) {
127127
$creds = self::getCredentials($scope, $httpHandler, $cacheConfig, $cache, $quotaProject);
@@ -152,12 +152,12 @@ public static function getMiddleware(
152152
*/
153153
public static function getCredentials(
154154
$scope = null,
155-
callable $httpHandler = null,
156-
array $cacheConfig = null,
157-
CacheItemPoolInterface $cache = null,
155+
?callable $httpHandler = null,
156+
?array $cacheConfig = null,
157+
?CacheItemPoolInterface $cache = null,
158158
$quotaProject = null,
159159
$defaultScope = null,
160-
string $universeDomain = null
160+
?string $universeDomain = null
161161
) {
162162
$creds = null;
163163
$jsonKey = CredentialsLoader::fromEnv()
@@ -224,9 +224,9 @@ public static function getCredentials(
224224
*/
225225
public static function getIdTokenMiddleware(
226226
$targetAudience,
227-
callable $httpHandler = null,
228-
array $cacheConfig = null,
229-
CacheItemPoolInterface $cache = null
227+
?callable $httpHandler = null,
228+
?array $cacheConfig = null,
229+
?CacheItemPoolInterface $cache = null
230230
) {
231231
$creds = self::getIdTokenCredentials($targetAudience, $httpHandler, $cacheConfig, $cache);
232232

@@ -251,9 +251,9 @@ public static function getIdTokenMiddleware(
251251
*/
252252
public static function getProxyIdTokenMiddleware(
253253
$targetAudience,
254-
callable $httpHandler = null,
255-
array $cacheConfig = null,
256-
CacheItemPoolInterface $cache = null
254+
?callable $httpHandler = null,
255+
?array $cacheConfig = null,
256+
?CacheItemPoolInterface $cache = null
257257
) {
258258
$creds = self::getIdTokenCredentials($targetAudience, $httpHandler, $cacheConfig, $cache);
259259

@@ -276,9 +276,9 @@ public static function getProxyIdTokenMiddleware(
276276
*/
277277
public static function getIdTokenCredentials(
278278
$targetAudience,
279-
callable $httpHandler = null,
280-
array $cacheConfig = null,
281-
CacheItemPoolInterface $cache = null
279+
?callable $httpHandler = null,
280+
?array $cacheConfig = null,
281+
?CacheItemPoolInterface $cache = null
282282
) {
283283
$creds = null;
284284
$jsonKey = CredentialsLoader::fromEnv()
@@ -340,9 +340,9 @@ private static function notFound()
340340
* @return bool
341341
*/
342342
private static function onGce(
343-
callable $httpHandler = null,
344-
array $cacheConfig = null,
345-
CacheItemPoolInterface $cache = null
343+
?callable $httpHandler = null,
344+
?array $cacheConfig = null,
345+
?CacheItemPoolInterface $cache = null
346346
) {
347347
$gceCacheConfig = [];
348348
foreach (['lifetime', 'prefix'] as $key) {

src/CredentialSource/AwsNativeSource.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ class AwsNativeSource implements ExternalAccountCredentialSourceInterface
5050
public function __construct(
5151
string $audience,
5252
string $regionalCredVerificationUrl,
53-
string $regionUrl = null,
54-
string $securityCredentialsUrl = null,
55-
string $imdsv2SessionTokenUrl = null
53+
?string $regionUrl = null,
54+
?string $securityCredentialsUrl = null,
55+
?string $imdsv2SessionTokenUrl = null
5656
) {
5757
$this->audience = $audience;
5858
$this->regionalCredVerificationUrl = $regionalCredVerificationUrl;
@@ -61,7 +61,7 @@ public function __construct(
6161
$this->imdsv2SessionTokenUrl = $imdsv2SessionTokenUrl;
6262
}
6363

64-
public function fetchSubjectToken(callable $httpHandler = null): string
64+
public function fetchSubjectToken(?callable $httpHandler = null): string
6565
{
6666
if (is_null($httpHandler)) {
6767
$httpHandler = HttpHandlerFactory::build(HttpClientCache::getHttpClient());

src/CredentialSource/FileSource.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class FileSource implements ExternalAccountCredentialSourceInterface
3838
*/
3939
public function __construct(
4040
string $file,
41-
string $format = null,
42-
string $subjectTokenFieldName = null
41+
?string $format = null,
42+
?string $subjectTokenFieldName = null
4343
) {
4444
$this->file = $file;
4545

@@ -53,7 +53,7 @@ public function __construct(
5353
$this->subjectTokenFieldName = $subjectTokenFieldName;
5454
}
5555

56-
public function fetchSubjectToken(callable $httpHandler = null): string
56+
public function fetchSubjectToken(?callable $httpHandler = null): string
5757
{
5858
$contents = file_get_contents($this->file);
5959
if ($this->format === 'json') {

src/CredentialSource/UrlSource.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ class UrlSource implements ExternalAccountCredentialSourceInterface
4747
*/
4848
public function __construct(
4949
string $url,
50-
string $format = null,
51-
string $subjectTokenFieldName = null,
52-
array $headers = null
50+
?string $format = null,
51+
?string $subjectTokenFieldName = null,
52+
?array $headers = null
5353
) {
5454
$this->url = $url;
5555

@@ -64,7 +64,7 @@ public function __construct(
6464
$this->headers = $headers;
6565
}
6666

67-
public function fetchSubjectToken(callable $httpHandler = null): string
67+
public function fetchSubjectToken(?callable $httpHandler = null): string
6868
{
6969
if (is_null($httpHandler)) {
7070
$httpHandler = HttpHandlerFactory::build(HttpClientCache::getHttpClient());

src/Credentials/AppIdentityCredentials.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public static function onAppEngine()
124124
* @type string $expiration_time
125125
* }
126126
*/
127-
public function fetchAuthToken(callable $httpHandler = null)
127+
public function fetchAuthToken(?callable $httpHandler = null)
128128
{
129129
try {
130130
$this->checkAppEngineContext();
@@ -164,7 +164,7 @@ public function signBlob($stringToSign, $forceOpenSsl = false)
164164
* @param callable $httpHandler Not used by this type.
165165
* @return string|null
166166
*/
167-
public function getProjectId(callable $httpHandler = null)
167+
public function getProjectId(?callable $httpHandler = null)
168168
{
169169
try {
170170
$this->checkAppEngineContext();
@@ -185,7 +185,7 @@ public function getProjectId(callable $httpHandler = null)
185185
* @return string
186186
* @throws \Exception If AppEngine SDK or mock is not available.
187187
*/
188-
public function getClientName(callable $httpHandler = null)
188+
public function getClientName(?callable $httpHandler = null)
189189
{
190190
$this->checkAppEngineContext();
191191

src/Credentials/ExternalAccountCredentials.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private static function buildCredentialSource(array $jsonKey): ExternalAccountCr
188188
* @type int $expires_at
189189
* }
190190
*/
191-
private function getImpersonatedAccessToken(string $stsToken, callable $httpHandler = null): array
191+
private function getImpersonatedAccessToken(string $stsToken, ?callable $httpHandler = null): array
192192
{
193193
if (!isset($this->serviceAccountImpersonationUrl)) {
194194
throw new InvalidArgumentException(
@@ -231,7 +231,7 @@ private function getImpersonatedAccessToken(string $stsToken, callable $httpHand
231231
* @type string $token_type (identity pool only)
232232
* }
233233
*/
234-
public function fetchAuthToken(callable $httpHandler = null)
234+
public function fetchAuthToken(?callable $httpHandler = null)
235235
{
236236
$stsToken = $this->auth->fetchAuthToken($httpHandler);
237237

@@ -281,7 +281,7 @@ public function getUniverseDomain(): string
281281
* token. **Defaults to** `null`.
282282
* @return string|null
283283
*/
284-
public function getProjectId(callable $httpHandler = null, string $accessToken = null)
284+
public function getProjectId(?callable $httpHandler = null, ?string $accessToken = null)
285285
{
286286
if (isset($this->projectId)) {
287287
return $this->projectId;

src/Credentials/GCECredentials.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ class GCECredentials extends CredentialsLoader implements
192192
* instead of fetching one from the metadata server.
193193
*/
194194
public function __construct(
195-
Iam $iam = null,
195+
?Iam $iam = null,
196196
$scope = null,
197197
$targetAudience = null,
198198
$quotaProject = null,
199199
$serviceAccountIdentity = null,
200-
string $universeDomain = null
200+
?string $universeDomain = null
201201
) {
202202
$this->iam = $iam;
203203

@@ -339,7 +339,7 @@ public static function onAppEngineFlexible()
339339
* @param callable $httpHandler callback which delivers psr7 request
340340
* @return bool True if this a GCEInstance, false otherwise
341341
*/
342-
public static function onGce(callable $httpHandler = null)
342+
public static function onGce(?callable $httpHandler = null)
343343
{
344344
$httpHandler = $httpHandler
345345
?: HttpHandlerFactory::build(HttpClientCache::getHttpClient());
@@ -408,7 +408,7 @@ private static function detectResidencyLinux(string $productNameFile): bool
408408
* }
409409
* @throws \Exception
410410
*/
411-
public function fetchAuthToken(callable $httpHandler = null)
411+
public function fetchAuthToken(?callable $httpHandler = null)
412412
{
413413
$httpHandler = $httpHandler
414414
?: HttpHandlerFactory::build(HttpClientCache::getHttpClient());
@@ -474,7 +474,7 @@ public function getLastReceivedToken()
474474
* @param callable $httpHandler callback which delivers psr7 request
475475
* @return string
476476
*/
477-
public function getClientName(callable $httpHandler = null)
477+
public function getClientName(?callable $httpHandler = null)
478478
{
479479
if ($this->clientName) {
480480
return $this->clientName;
@@ -508,7 +508,7 @@ public function getClientName(callable $httpHandler = null)
508508
* @param callable $httpHandler Callback which delivers psr7 request
509509
* @return string|null
510510
*/
511-
public function getProjectId(callable $httpHandler = null)
511+
public function getProjectId(?callable $httpHandler = null)
512512
{
513513
if ($this->projectId) {
514514
return $this->projectId;
@@ -536,7 +536,7 @@ public function getProjectId(callable $httpHandler = null)
536536
* @param callable $httpHandler Callback which delivers psr7 request
537537
* @return string
538538
*/
539-
public function getUniverseDomain(callable $httpHandler = null): string
539+
public function getUniverseDomain(?callable $httpHandler = null): string
540540
{
541541
if (null !== $this->universeDomain) {
542542
return $this->universeDomain;

src/Credentials/IAMCredentials.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function getUpdateMetadataFunc()
8080
public function updateMetadata(
8181
$metadata,
8282
$unusedAuthUri = null,
83-
callable $httpHandler = null
83+
?callable $httpHandler = null
8484
) {
8585
$metadata_copy = $metadata;
8686
$metadata_copy[self::SELECTOR_KEY] = $this->selector;

0 commit comments

Comments
 (0)