Skip to content

Commit ed0b1e6

Browse files
committed
fix(Core,Spanner): resolve PHP 8.5 deprecation warnings
1 parent b52f3a0 commit ed0b1e6

4 files changed

Lines changed: 19 additions & 13 deletions

File tree

Core/src/LongRunning/LongRunningClientConnection.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ public function __construct(
4545
*/
4646
public function get(array $args): array
4747
{
48-
$operationResponse = $this->gapicClient->resumeOperation($args['name']);
48+
if (isset($args['method'])) {
49+
$operationResponse = $this->gapicClient->resumeOperation($args['name'], $args['method']);
50+
} else {
51+
$operationResponse = $this->gapicClient->resumeOperation($args['name']);
52+
}
4953

5054
return $this->operationResponseToArray($operationResponse);
5155
}
@@ -56,10 +60,11 @@ public function get(array $args): array
5660
*/
5761
public function cancel(array $args): array
5862
{
59-
$operationResponse = $this->gapicClient->resumeOperation(
60-
$args['name'],
61-
$args['method'] ?? null
62-
);
63+
if (isset($args['method'])) {
64+
$operationResponse = $this->gapicClient->resumeOperation($args['name'], $args['method']);
65+
} else {
66+
$operationResponse = $this->gapicClient->resumeOperation($args['name']);
67+
}
6368
$operationResponse->cancel();
6469

6570
return $this->operationResponseToArray($operationResponse);
@@ -71,10 +76,11 @@ public function cancel(array $args): array
7176
*/
7277
public function delete(array $args): array
7378
{
74-
$operationResponse = $this->gapicClient->resumeOperation(
75-
$args['name'],
76-
$args['method'] ?? null
77-
);
79+
if (isset($args['method'])) {
80+
$operationResponse = $this->gapicClient->resumeOperation($args['name'], $args['method']);
81+
} else {
82+
$operationResponse = $this->gapicClient->resumeOperation($args['name']);
83+
}
7884
$operationResponse->cancel();
7985

8086
return $this->operationResponseToArray($operationResponse);

Spanner/src/Admin/Database/V1/Client/DatabaseAdminClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function getOperationsClient()
202202
*/
203203
public function resumeOperation($operationName, $methodName = null)
204204
{
205-
$options = $this->descriptors[$methodName]['longRunning'] ?? [];
205+
$options = isset($methodName) ? ($this->descriptors[$methodName]['longRunning'] ?? []) : [];
206206
$operation = new OperationResponse($operationName, $this->getOperationsClient(), $options);
207207
$operation->reload();
208208
return $operation;

Spanner/src/Admin/Instance/V1/Client/InstanceAdminClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public function getOperationsClient()
203203
*/
204204
public function resumeOperation($operationName, $methodName = null)
205205
{
206-
$options = $this->descriptors[$methodName]['longRunning'] ?? [];
206+
$options = isset($methodName) ? ($this->descriptors[$methodName]['longRunning'] ?? []) : [];
207207
$operation = new OperationResponse($operationName, $this->getOperationsClient(), $options);
208208
$operation->reload();
209209
return $operation;

Spanner/src/ValueMapper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ private function structParam(StructValue|array|null $value, StructType $type): a
561561
}
562562
} elseif ($value instanceof StructValue) {
563563
foreach ($value->values() as $idx => $val) {
564-
$name = (string) $val['name'];
564+
$name = (string) ($val['name'] ?? '');
565565
$valValue = $val['value'];
566566

567567
if (!isset($values[$name])) {
@@ -580,7 +580,7 @@ private function structParam(StructValue|array|null $value, StructType $type): a
580580
$fields = [];
581581
$names = [];
582582
foreach ($typeFields as $typeIndex => $paramType) {
583-
$fieldName = (string) $paramType['name'];
583+
$fieldName = (string) ($paramType['name'] ?? '');
584584

585585
// Count the number of times the field name has been encountered thus far.
586586
// This lets us pick the correct index for duplicate fields.

0 commit comments

Comments
 (0)