Skip to content

Commit e400e24

Browse files
authored
fix: add PHP 8.4 compatibility to last release compatible with PHP 7.4 (#600)
1 parent 54a863e commit e400e24

19 files changed

+45
-45
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
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
extensions: [""]
1616
tools: [""]
1717
composerflags: [""]
@@ -74,5 +74,5 @@ jobs:
7474
- name: Run Script
7575
run: |
7676
composer install
77-
composer global require phpstan/phpstan
77+
composer global require phpstan/phpstan:^1.0
7878
~/.composer/vendor/bin/phpstan analyse

src/ApiException.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ApiException extends Exception
6262
public function __construct(
6363
string $message,
6464
int $code,
65-
string $status = null,
65+
?string $status = null,
6666
array $optionalArgs = []
6767
) {
6868
$optionalArgs += [
@@ -163,8 +163,8 @@ public static function createFromStdClass(stdClass $status)
163163
public static function createFromApiResponse(
164164
$basicMessage,
165165
$rpcCode,
166-
array $metadata = null,
167-
Exception $previous = null
166+
?array $metadata = null,
167+
?Exception $previous = null
168168
) {
169169
return self::create(
170170
$basicMessage,
@@ -187,8 +187,8 @@ public static function createFromApiResponse(
187187
public static function createFromRestApiResponse(
188188
$basicMessage,
189189
$rpcCode,
190-
array $metadata = null,
191-
Exception $previous = null
190+
?array $metadata = null,
191+
?Exception $previous = null
192192
) {
193193
return self::create(
194194
$basicMessage,
@@ -244,7 +244,7 @@ private static function create(
244244
int $rpcCode,
245245
$metadata,
246246
array $decodedMetadata,
247-
Exception $previous = null
247+
?Exception $previous = null
248248
) {
249249
$containsErrorInfo = self::containsErrorInfo($decodedMetadata);
250250
$rpcStatus = ApiStatus::statusFromRpcCode($rpcCode);

src/Call.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Call
6161
*/
6262
public function __construct(
6363
string $method,
64-
string $decodeType = null,
64+
?string $decodeType = null,
6565
$message = null,
6666
$descriptor = [],
6767
int $callType = Call::UNARY_CALL

src/CredentialsWrapper.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class CredentialsWrapper implements ProjectIdProviderInterface
7777
*/
7878
public function __construct(
7979
FetchAuthTokenInterface $credentialsFetcher,
80-
callable $authHttpHandler = null,
80+
?callable $authHttpHandler = null,
8181
string $universeDomain = GetUniverseDomainInterface::DEFAULT_UNIVERSE_DOMAIN
8282
) {
8383
$this->credentialsFetcher = $credentialsFetcher;
@@ -203,7 +203,7 @@ public function getQuotaProject()
203203
return null;
204204
}
205205

206-
public function getProjectId(callable $httpHandler = null): ?string
206+
public function getProjectId(?callable $httpHandler = null): ?string
207207
{
208208
// Ensure that FetchAuthTokenCache does not throw an exception
209209
if ($this->credentialsFetcher instanceof FetchAuthTokenCache
@@ -313,12 +313,12 @@ private static function buildHttpHandlerFactory()
313313
* @throws ValidationException
314314
*/
315315
private static function buildApplicationDefaultCredentials(
316-
array $scopes = null,
317-
callable $authHttpHandler = null,
318-
array $authCacheOptions = null,
319-
CacheItemPoolInterface $authCache = null,
316+
?array $scopes = null,
317+
?callable $authHttpHandler = null,
318+
?array $authCacheOptions = null,
319+
?CacheItemPoolInterface $authCache = null,
320320
$quotaProject = null,
321-
array $defaultScopes = null
321+
?array $defaultScopes = null
322322
) {
323323
try {
324324
return ApplicationDefaultCredentials::getCredentials(

src/GapicClientTrait.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ private function createTransport(
315315
string $apiEndpoint,
316316
$transport,
317317
$transportConfig,
318-
callable $clientCertSource = null
318+
?callable $clientCertSource = null
319319
) {
320320
if (!is_string($transport)) {
321321
throw new ValidationException(
@@ -511,7 +511,7 @@ private function startAsyncCall(
511511
*/
512512
private function startApiCall(
513513
string $methodName,
514-
Message $request = null,
514+
?Message $request = null,
515515
array $optionalArgs = []
516516
) {
517517
$methodDescriptors =$this->validateCallConfig($methodName);
@@ -573,9 +573,9 @@ private function startCall(
573573
string $methodName,
574574
string $decodeType,
575575
array $optionalArgs = [],
576-
Message $request = null,
576+
?Message $request = null,
577577
int $callType = Call::UNARY_CALL,
578-
string $interfaceName = null
578+
?string $interfaceName = null
579579
) {
580580
$optionalArgs = $this->configureCallOptions($optionalArgs);
581581
$callStack = $this->createCallStack(
@@ -713,8 +713,8 @@ private function startOperationsCall(
713713
array $optionalArgs,
714714
Message $request,
715715
$client,
716-
string $interfaceName = null,
717-
string $operationClass = null
716+
?string $interfaceName = null,
717+
?string $operationClass = null
718718
) {
719719
$optionalArgs = $this->configureCallOptions($optionalArgs);
720720
$callStack = $this->createCallStack(
@@ -769,7 +769,7 @@ private function getPagedListResponse(
769769
array $optionalArgs,
770770
string $decodeType,
771771
Message $request,
772-
string $interfaceName = null
772+
?string $interfaceName = null
773773
) {
774774
return $this->getPagedListResponseAsync(
775775
$methodName,
@@ -794,7 +794,7 @@ private function getPagedListResponseAsync(
794794
array $optionalArgs,
795795
string $decodeType,
796796
Message $request,
797-
string $interfaceName = null
797+
?string $interfaceName = null
798798
) {
799799
$optionalArgs = $this->configureCallOptions($optionalArgs);
800800
$callStack = $this->createCallStack(
@@ -825,7 +825,7 @@ private function getPagedListResponseAsync(
825825
*
826826
* @return string
827827
*/
828-
private function buildMethod(string $interfaceName = null, string $methodName = null)
828+
private function buildMethod(?string $interfaceName = null, ?string $methodName = null)
829829
{
830830
return sprintf(
831831
'%s/%s',
@@ -840,7 +840,7 @@ private function buildMethod(string $interfaceName = null, string $methodName =
840840
*
841841
* @return array
842842
*/
843-
private function buildRequestParamsHeader(array $headerParams, Message $request = null)
843+
private function buildRequestParamsHeader(array $headerParams, ?Message $request = null)
844844
{
845845
$headers = [];
846846

src/Page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function getNextPageToken()
110110
* @throws ApiException if the call to fetch the next page fails.
111111
* @return Page
112112
*/
113-
public function getNextPage(int $pageSize = null)
113+
public function getNextPage(?int $pageSize = null)
114114
{
115115
if (!$this->hasNextPage()) {
116116
throw new ValidationException(

src/PathTemplate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class PathTemplate implements ResourceTemplateInterface
5454
* @param string $path A path template string
5555
* @throws ValidationException When $path cannot be parsed into a valid PathTemplate
5656
*/
57-
public function __construct(string $path = null)
57+
public function __construct(?string $path = null)
5858
{
5959
if (empty($path)) {
6060
throw new ValidationException('Cannot construct PathTemplate from empty string');

src/RequestBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private function buildBindings(array $placeholders, Message $message)
233233
foreach ($placeholders as $placeholder => $metadata) {
234234
$value = array_reduce(
235235
$metadata['getters'],
236-
function (Message $result = null, $getter) {
236+
function (?Message $result = null, $getter = null) {
237237
if ($result) {
238238
return $result->$getter();
239239
}

src/ResourceHelperTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private static function getPathTemplate(string $key)
8484
return self::$templateMap[$key] ?? null;
8585
}
8686

87-
private static function parseFormattedName(string $formattedName, string $template = null): array
87+
private static function parseFormattedName(string $formattedName, ?string $template = null): array
8888
{
8989
if (is_null(self::$templateMap)) {
9090
self::registerPathTemplates();

src/ResourceTemplate/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Parser
4848
* @return array
4949
* @throws ValidationException
5050
*/
51-
public static function parseSegments(string $path = null)
51+
public static function parseSegments(?string $path = null)
5252
{
5353
if (empty($path)) {
5454
throw new ValidationException("Cannot parse empty path");

0 commit comments

Comments
 (0)