Skip to content

Commit af0a0e7

Browse files
authored
fix: remove implicit null, add php 8.4 (#599)
1 parent 13bbe8a commit af0a0e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+442
-431
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: [ "8.0", "8.1", "8.2", "8.3" ]
14+
php: [ "8.0", "8.1", "8.2", "8.3", "8.4" ]
1515
extensions: [""]
1616
tools: [""]
1717
composerflags: [""]

src/ApiException.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ApiException extends Exception
6161
public function __construct(
6262
string $message,
6363
int $code,
64-
string $status = null,
64+
?string $status = null,
6565
array $optionalArgs = []
6666
) {
6767
$optionalArgs += [
@@ -162,8 +162,8 @@ public static function createFromStdClass(stdClass $status)
162162
public static function createFromApiResponse(
163163
$basicMessage,
164164
$rpcCode,
165-
array $metadata = null,
166-
Exception $previous = null
165+
?array $metadata = null,
166+
?Exception $previous = null
167167
) {
168168
return self::create(
169169
$basicMessage,
@@ -186,8 +186,8 @@ public static function createFromApiResponse(
186186
public static function createFromRestApiResponse(
187187
$basicMessage,
188188
$rpcCode,
189-
array $metadata = null,
190-
Exception $previous = null
189+
?array $metadata = null,
190+
?Exception $previous = null
191191
) {
192192
return self::create(
193193
$basicMessage,
@@ -243,7 +243,7 @@ private static function create(
243243
int $rpcCode,
244244
$metadata,
245245
array $decodedMetadata,
246-
Exception $previous = null
246+
?Exception $previous = null
247247
) {
248248
$containsErrorInfo = self::containsErrorInfo($decodedMetadata);
249249
$rpcStatus = ApiStatus::statusFromRpcCode($rpcCode);

src/ApiKeyHeaderCredentials.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ApiKeyHeaderCredentials implements HeaderCredentialsInterface, GetQuotaPro
4747
* @param string|null $quotaProject The quota project associated with the API key.
4848
* @throws ValidationException
4949
*/
50-
public function __construct(string $apiKey, string $quotaProject = null)
50+
public function __construct(string $apiKey, ?string $quotaProject = null)
5151
{
5252
if (empty($apiKey)) {
5353
throw new ValidationException('API key cannot be empty');

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
@@ -75,7 +75,7 @@ class CredentialsWrapper implements HeaderCredentialsInterface, ProjectIdProvide
7575
*/
7676
public function __construct(
7777
FetchAuthTokenInterface $credentialsFetcher,
78-
callable $authHttpHandler = null,
78+
?callable $authHttpHandler = null,
7979
string $universeDomain = GetUniverseDomainInterface::DEFAULT_UNIVERSE_DOMAIN
8080
) {
8181
$this->credentialsFetcher = $credentialsFetcher;
@@ -200,7 +200,7 @@ public function getQuotaProject(): ?string
200200
return null;
201201
}
202202

203-
public function getProjectId(callable $httpHandler = null): ?string
203+
public function getProjectId(?callable $httpHandler = null): ?string
204204
{
205205
// Ensure that FetchAuthTokenCache does not throw an exception
206206
if ($this->credentialsFetcher instanceof FetchAuthTokenCache
@@ -317,12 +317,12 @@ private function shouldCheckUniverseDomain(): bool
317317
* @throws ValidationException
318318
*/
319319
private static function buildApplicationDefaultCredentials(
320-
array $scopes = null,
321-
callable $authHttpHandler = null,
322-
array $authCacheOptions = null,
323-
CacheItemPoolInterface $authCache = null,
320+
?array $scopes = null,
321+
?callable $authHttpHandler = null,
322+
?array $authCacheOptions = null,
323+
?CacheItemPoolInterface $authCache = null,
324324
$quotaProject = null,
325-
array $defaultScopes = null
325+
?array $defaultScopes = null
326326
) {
327327
try {
328328
return ApplicationDefaultCredentials::getCredentials(

src/GapicClientTrait.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ private function createTransport(
337337
string $apiEndpoint,
338338
$transport,
339339
$transportConfig,
340-
callable $clientCertSource = null,
340+
?callable $clientCertSource = null,
341341
bool $hasEmulator = false
342342
) {
343343
if (!is_string($transport)) {
@@ -536,7 +536,7 @@ private function startAsyncCall(
536536
*/
537537
private function startApiCall(
538538
string $methodName,
539-
Message $request = null,
539+
?Message $request = null,
540540
array $optionalArgs = []
541541
) {
542542
$methodDescriptors = $this->validateCallConfig($methodName);
@@ -598,9 +598,9 @@ private function startCall(
598598
string $methodName,
599599
string $decodeType,
600600
array $optionalArgs = [],
601-
Message $request = null,
601+
?Message $request = null,
602602
int $callType = Call::UNARY_CALL,
603-
string $interfaceName = null
603+
?string $interfaceName = null
604604
) {
605605
$optionalArgs = $this->configureCallOptions($optionalArgs);
606606
$callStack = $this->createCallStack(
@@ -752,8 +752,8 @@ private function startOperationsCall(
752752
array $optionalArgs,
753753
Message $request,
754754
$client,
755-
string $interfaceName = null,
756-
string $operationClass = null
755+
?string $interfaceName = null,
756+
?string $operationClass = null
757757
) {
758758
$optionalArgs = $this->configureCallOptions($optionalArgs);
759759
$callStack = $this->createCallStack(
@@ -808,7 +808,7 @@ private function getPagedListResponse(
808808
array $optionalArgs,
809809
string $decodeType,
810810
Message $request,
811-
string $interfaceName = null
811+
?string $interfaceName = null
812812
) {
813813
return $this->getPagedListResponseAsync(
814814
$methodName,
@@ -833,7 +833,7 @@ private function getPagedListResponseAsync(
833833
array $optionalArgs,
834834
string $decodeType,
835835
Message $request,
836-
string $interfaceName = null
836+
?string $interfaceName = null
837837
) {
838838
$optionalArgs = $this->configureCallOptions($optionalArgs);
839839
$callStack = $this->createCallStack(
@@ -864,7 +864,7 @@ private function getPagedListResponseAsync(
864864
*
865865
* @return string
866866
*/
867-
private function buildMethod(string $interfaceName = null, string $methodName = null)
867+
private function buildMethod(?string $interfaceName = null, ?string $methodName = null)
868868
{
869869
return sprintf(
870870
'%s/%s',
@@ -879,7 +879,7 @@ private function buildMethod(string $interfaceName = null, string $methodName =
879879
*
880880
* @return array
881881
*/
882-
private function buildRequestParamsHeader(array $headerParams, Message $request = null)
882+
private function buildRequestParamsHeader(array $headerParams, ?Message $request = null)
883883
{
884884
$headers = [];
885885

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ 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) {
237-
if ($result) {
236+
function (?Message $result = null, $getter = null) {
237+
if ($result && $getter) {
238238
return $result->$getter();
239239
}
240240
},

src/ResourceHelperTrait.php

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

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

0 commit comments

Comments
 (0)