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 last release compatible with PHP 7.4 #592

Merged
merged 1 commit into from
Dec 11, 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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
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" ]
name: PHP ${{matrix.php }} Unit Test
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions src/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class AccessToken
* @param CacheItemPoolInterface $cache [optional] A PSR-6 compatible cache implementation.
*/
public function __construct(
callable $httpHandler = null,
CacheItemPoolInterface $cache = null
?callable $httpHandler = null,
?CacheItemPoolInterface $cache = null
) {
$this->httpHandler = $httpHandler
?: HttpHandlerFactory::build(HttpClientCache::getHttpClient());
Expand Down
44 changes: 22 additions & 22 deletions src/ApplicationDefaultCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ class ApplicationDefaultCredentials
*/
public static function getSubscriber(// @phpstan-ignore-line
$scope = null,
callable $httpHandler = null,
array $cacheConfig = null,
CacheItemPoolInterface $cache = null
?callable $httpHandler = null,
?array $cacheConfig = null,
?CacheItemPoolInterface $cache = null
) {
$creds = self::getCredentials($scope, $httpHandler, $cacheConfig, $cache);

Expand Down Expand Up @@ -119,9 +119,9 @@ public static function getSubscriber(// @phpstan-ignore-line
*/
public static function getMiddleware(
$scope = null,
callable $httpHandler = null,
array $cacheConfig = null,
CacheItemPoolInterface $cache = null,
?callable $httpHandler = null,
?array $cacheConfig = null,
?CacheItemPoolInterface $cache = null,
$quotaProject = null
) {
$creds = self::getCredentials($scope, $httpHandler, $cacheConfig, $cache, $quotaProject);
Expand Down Expand Up @@ -152,12 +152,12 @@ public static function getMiddleware(
*/
public static function getCredentials(
$scope = null,
callable $httpHandler = null,
array $cacheConfig = null,
CacheItemPoolInterface $cache = null,
?callable $httpHandler = null,
?array $cacheConfig = null,
?CacheItemPoolInterface $cache = null,
$quotaProject = null,
$defaultScope = null,
string $universeDomain = null
?string $universeDomain = null
) {
$creds = null;
$jsonKey = CredentialsLoader::fromEnv()
Expand Down Expand Up @@ -224,9 +224,9 @@ public static function getCredentials(
*/
public static function getIdTokenMiddleware(
$targetAudience,
callable $httpHandler = null,
array $cacheConfig = null,
CacheItemPoolInterface $cache = null
?callable $httpHandler = null,
?array $cacheConfig = null,
?CacheItemPoolInterface $cache = null
) {
$creds = self::getIdTokenCredentials($targetAudience, $httpHandler, $cacheConfig, $cache);

Expand All @@ -251,9 +251,9 @@ public static function getIdTokenMiddleware(
*/
public static function getProxyIdTokenMiddleware(
$targetAudience,
callable $httpHandler = null,
array $cacheConfig = null,
CacheItemPoolInterface $cache = null
?callable $httpHandler = null,
?array $cacheConfig = null,
?CacheItemPoolInterface $cache = null
) {
$creds = self::getIdTokenCredentials($targetAudience, $httpHandler, $cacheConfig, $cache);

Expand All @@ -276,9 +276,9 @@ public static function getProxyIdTokenMiddleware(
*/
public static function getIdTokenCredentials(
$targetAudience,
callable $httpHandler = null,
array $cacheConfig = null,
CacheItemPoolInterface $cache = null
?callable $httpHandler = null,
?array $cacheConfig = null,
?CacheItemPoolInterface $cache = null
) {
$creds = null;
$jsonKey = CredentialsLoader::fromEnv()
Expand Down Expand Up @@ -340,9 +340,9 @@ private static function notFound()
* @return bool
*/
private static function onGce(
callable $httpHandler = null,
array $cacheConfig = null,
CacheItemPoolInterface $cache = null
?callable $httpHandler = null,
?array $cacheConfig = null,
?CacheItemPoolInterface $cache = null
) {
$gceCacheConfig = [];
foreach (['lifetime', 'prefix'] as $key) {
Expand Down
8 changes: 4 additions & 4 deletions src/CredentialSource/AwsNativeSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class AwsNativeSource implements ExternalAccountCredentialSourceInterface
public function __construct(
string $audience,
string $regionalCredVerificationUrl,
string $regionUrl = null,
string $securityCredentialsUrl = null,
string $imdsv2SessionTokenUrl = null
?string $regionUrl = null,
?string $securityCredentialsUrl = null,
?string $imdsv2SessionTokenUrl = null
) {
$this->audience = $audience;
$this->regionalCredVerificationUrl = $regionalCredVerificationUrl;
Expand All @@ -61,7 +61,7 @@ public function __construct(
$this->imdsv2SessionTokenUrl = $imdsv2SessionTokenUrl;
}

public function fetchSubjectToken(callable $httpHandler = null): string
public function fetchSubjectToken(?callable $httpHandler = null): string
{
if (is_null($httpHandler)) {
$httpHandler = HttpHandlerFactory::build(HttpClientCache::getHttpClient());
Expand Down
6 changes: 3 additions & 3 deletions src/CredentialSource/FileSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class FileSource implements ExternalAccountCredentialSourceInterface
*/
public function __construct(
string $file,
string $format = null,
string $subjectTokenFieldName = null
?string $format = null,
?string $subjectTokenFieldName = null
) {
$this->file = $file;

Expand All @@ -53,7 +53,7 @@ public function __construct(
$this->subjectTokenFieldName = $subjectTokenFieldName;
}

public function fetchSubjectToken(callable $httpHandler = null): string
public function fetchSubjectToken(?callable $httpHandler = null): string
{
$contents = file_get_contents($this->file);
if ($this->format === 'json') {
Expand Down
8 changes: 4 additions & 4 deletions src/CredentialSource/UrlSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class UrlSource implements ExternalAccountCredentialSourceInterface
*/
public function __construct(
string $url,
string $format = null,
string $subjectTokenFieldName = null,
array $headers = null
?string $format = null,
?string $subjectTokenFieldName = null,
?array $headers = null
) {
$this->url = $url;

Expand All @@ -64,7 +64,7 @@ public function __construct(
$this->headers = $headers;
}

public function fetchSubjectToken(callable $httpHandler = null): string
public function fetchSubjectToken(?callable $httpHandler = null): string
{
if (is_null($httpHandler)) {
$httpHandler = HttpHandlerFactory::build(HttpClientCache::getHttpClient());
Expand Down
6 changes: 3 additions & 3 deletions src/Credentials/AppIdentityCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static function onAppEngine()
* @type string $expiration_time
* }
*/
public function fetchAuthToken(callable $httpHandler = null)
public function fetchAuthToken(?callable $httpHandler = null)
{
try {
$this->checkAppEngineContext();
Expand Down Expand Up @@ -164,7 +164,7 @@ public function signBlob($stringToSign, $forceOpenSsl = false)
* @param callable $httpHandler Not used by this type.
* @return string|null
*/
public function getProjectId(callable $httpHandler = null)
public function getProjectId(?callable $httpHandler = null)
{
try {
$this->checkAppEngineContext();
Expand All @@ -185,7 +185,7 @@ public function getProjectId(callable $httpHandler = null)
* @return string
* @throws \Exception If AppEngine SDK or mock is not available.
*/
public function getClientName(callable $httpHandler = null)
public function getClientName(?callable $httpHandler = null)
{
$this->checkAppEngineContext();

Expand Down
6 changes: 3 additions & 3 deletions src/Credentials/ExternalAccountCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private static function buildCredentialSource(array $jsonKey): ExternalAccountCr
* @type int $expires_at
* }
*/
private function getImpersonatedAccessToken(string $stsToken, callable $httpHandler = null): array
private function getImpersonatedAccessToken(string $stsToken, ?callable $httpHandler = null): array
{
if (!isset($this->serviceAccountImpersonationUrl)) {
throw new InvalidArgumentException(
Expand Down Expand Up @@ -231,7 +231,7 @@ private function getImpersonatedAccessToken(string $stsToken, callable $httpHand
* @type string $token_type (identity pool only)
* }
*/
public function fetchAuthToken(callable $httpHandler = null)
public function fetchAuthToken(?callable $httpHandler = null)
{
$stsToken = $this->auth->fetchAuthToken($httpHandler);

Expand Down Expand Up @@ -281,7 +281,7 @@ public function getUniverseDomain(): string
* token. **Defaults to** `null`.
* @return string|null
*/
public function getProjectId(callable $httpHandler = null, string $accessToken = null)
public function getProjectId(?callable $httpHandler = null, ?string $accessToken = null)
{
if (isset($this->projectId)) {
return $this->projectId;
Expand Down
14 changes: 7 additions & 7 deletions src/Credentials/GCECredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ class GCECredentials extends CredentialsLoader implements
* instead of fetching one from the metadata server.
*/
public function __construct(
Iam $iam = null,
?Iam $iam = null,
$scope = null,
$targetAudience = null,
$quotaProject = null,
$serviceAccountIdentity = null,
string $universeDomain = null
?string $universeDomain = null
) {
$this->iam = $iam;

Expand Down Expand Up @@ -339,7 +339,7 @@ public static function onAppEngineFlexible()
* @param callable $httpHandler callback which delivers psr7 request
* @return bool True if this a GCEInstance, false otherwise
*/
public static function onGce(callable $httpHandler = null)
public static function onGce(?callable $httpHandler = null)
{
$httpHandler = $httpHandler
?: HttpHandlerFactory::build(HttpClientCache::getHttpClient());
Expand Down Expand Up @@ -408,7 +408,7 @@ private static function detectResidencyLinux(string $productNameFile): bool
* }
* @throws \Exception
*/
public function fetchAuthToken(callable $httpHandler = null)
public function fetchAuthToken(?callable $httpHandler = null)
{
$httpHandler = $httpHandler
?: HttpHandlerFactory::build(HttpClientCache::getHttpClient());
Expand Down Expand Up @@ -474,7 +474,7 @@ public function getLastReceivedToken()
* @param callable $httpHandler callback which delivers psr7 request
* @return string
*/
public function getClientName(callable $httpHandler = null)
public function getClientName(?callable $httpHandler = null)
{
if ($this->clientName) {
return $this->clientName;
Expand Down Expand Up @@ -508,7 +508,7 @@ public function getClientName(callable $httpHandler = null)
* @param callable $httpHandler Callback which delivers psr7 request
* @return string|null
*/
public function getProjectId(callable $httpHandler = null)
public function getProjectId(?callable $httpHandler = null)
{
if ($this->projectId) {
return $this->projectId;
Expand Down Expand Up @@ -536,7 +536,7 @@ public function getProjectId(callable $httpHandler = null)
* @param callable $httpHandler Callback which delivers psr7 request
* @return string
*/
public function getUniverseDomain(callable $httpHandler = null): string
public function getUniverseDomain(?callable $httpHandler = null): string
{
if (null !== $this->universeDomain) {
return $this->universeDomain;
Expand Down
2 changes: 1 addition & 1 deletion src/Credentials/IAMCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function getUpdateMetadataFunc()
public function updateMetadata(
$metadata,
$unusedAuthUri = null,
callable $httpHandler = null
?callable $httpHandler = null
) {
$metadata_copy = $metadata;
$metadata_copy[self::SELECTOR_KEY] = $this->selector;
Expand Down
4 changes: 2 additions & 2 deletions src/Credentials/ImpersonatedServiceAccountCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private function getImpersonatedServiceAccountNameFromUrl(
* @param callable|null $unusedHttpHandler not used by this credentials type.
* @return string Token issuer email
*/
public function getClientName(callable $unusedHttpHandler = null)
public function getClientName(?callable $unusedHttpHandler = null)
{
return $this->impersonatedServiceAccountName;
}
Expand All @@ -119,7 +119,7 @@ public function getClientName(callable $unusedHttpHandler = null)
* @type string $id_token
* }
*/
public function fetchAuthToken(callable $httpHandler = null)
public function fetchAuthToken(?callable $httpHandler = null)
{
return $this->sourceCredentials->fetchAuthToken($httpHandler);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Credentials/InsecureCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class InsecureCredentials implements FetchAuthTokenInterface
* @param callable $httpHandler
* @return array{access_token:string} A set of auth related metadata
*/
public function fetchAuthToken(callable $httpHandler = null)
public function fetchAuthToken(?callable $httpHandler = null)
{
return $this->token;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Credentials/ServiceAccountCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function useJwtAccessWithScope()
* @type string $token_type
* }
*/
public function fetchAuthToken(callable $httpHandler = null)
public function fetchAuthToken(?callable $httpHandler = null)
{
if ($this->useSelfSignedJwt()) {
$jwtCreds = $this->createJwtAccessCredentials();
Expand Down Expand Up @@ -242,7 +242,7 @@ public function getLastReceivedToken()
* @param callable $httpHandler Not used by this credentials type.
* @return string|null
*/
public function getProjectId(callable $httpHandler = null)
public function getProjectId(?callable $httpHandler = null)
{
return $this->projectId;
}
Expand All @@ -258,7 +258,7 @@ public function getProjectId(callable $httpHandler = null)
public function updateMetadata(
$metadata,
$authUri = null,
callable $httpHandler = null
?callable $httpHandler = null
) {
// scope exists. use oauth implementation
if (!$this->useSelfSignedJwt()) {
Expand Down Expand Up @@ -319,7 +319,7 @@ public function setSub($sub)
* @param callable $httpHandler Not used by this credentials type.
* @return string
*/
public function getClientName(callable $httpHandler = null)
public function getClientName(?callable $httpHandler = null)
{
return $this->auth->getIssuer();
}
Expand Down
Loading
Loading