Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fe367bf
chore(gax): upgrade to google/longrunning:v1, remove deprecated class…
bshaffer Jun 16, 2026
f39e3cd
add new ApiEndpoint trait
bshaffer Jun 16, 2026
1b318b6
chore(gax): upgrade to google/longrunning:v1, remove deprecated class…
bshaffer Jun 16, 2026
a350fbb
add new ApiEndpoint trait
bshaffer Jun 16, 2026
dc3368c
drop v1-surface operations client, backwards compatibility mode
bshaffer Jun 23, 2026
ed0e050
Remove legacy headers
bshaffer Jul 6, 2026
5089a35
Merge branch 'gax-v2' of github.com:googleapis/google-cloud-php into …
bshaffer Jul 6, 2026
8b0ceb2
Merge branch 'main' into gax-v2
bshaffer Aug 27, 2026
2fe41af
Merge remote-tracking branch 'origin/main' into gax-v2
bshaffer Sep 28, 2026
88b24fd
chore!(gax): remove remaining v1 deprecations, add client interfaces,…
bshaffer Sep 28, 2026
3971026
docs(gax): add MIGRATING.md for v2
bshaffer Sep 28, 2026
274772e
fix(gax): fix PagedListResponse::getIterator return type, unused impo…
bshaffer Sep 28, 2026
1bb7d91
feat(Gax): preserve client options and add strict types across remain…
bshaffer Sep 29, 2026
2b795eb
fix(Core): extend Message in OperationResponseTraitTest Response stub
bshaffer Sep 29, 2026
0d4dc83
chore(Gax): remove Gax/tests/Testing from phpcs-ruleset.xml
bshaffer Sep 30, 2026
6fbf2db
Merge remote-tracking branch 'origin/main' into gax-v2
bshaffer Oct 1, 2026
cc8c410
Merge branch 'gax-v2-credentials-interface' into gax-v2
bshaffer Oct 1, 2026
7e10dff
Merge branch 'gax-v2-credentials-interface' into gax-v2
bshaffer Oct 1, 2026
8f5c73d
Merge branch 'gax-v2-credentials-interface' into gax-v2
bshaffer Oct 1, 2026
16baeb8
Merge branch 'gax-v2-credentials-interface' into gax-v2
bshaffer Oct 5, 2026
87e8680
Merge branch 'gax-v2-credentials-interface' into gax-v2
bshaffer Nov 12, 2026
d1cfb48
Merge branch 'gax-v2-credentials-interface' into gax-v2
bshaffer Nov 12, 2026
8263e99
Merge branch 'gax-v2-credentials-interface' into gax-v2
bshaffer Nov 13, 2026
f27fa47
docs(Gax): update MIGRATING.md with KnownTypes and getHeaderCredentials
bshaffer Nov 13, 2026
8b2f1a7
chore(Gax): typehint OperationResponse::getLastProtoResponse(): ?Message
bshaffer Nov 13, 2026
135c34f
Merge branch 'gax-v2-credentials-interface' into gax-v2
bshaffer Nov 16, 2026
e5f3a59
chore(Gax): graduate client interfaces by removing @experimental and …
bshaffer Nov 16, 2026
7ee8a40
Merge branch 'gax-v2-credentials-interface' into gax-v2
bshaffer Nov 18, 2026
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
4 changes: 2 additions & 2 deletions Core/tests/Unit/LongRunning/OperationResponseTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function getValue()
}
}

class Response
class Response extends \Google\Protobuf\Internal\Message
{
public $metadataType;
public $metadata;
Expand Down Expand Up @@ -219,7 +219,7 @@ public function getError()
return $this->error;
}

public function serializeToJsonString()
public function serializeToJsonString($options = 0)
{
$result = [
'done' => true,
Expand Down
56 changes: 56 additions & 0 deletions Gax/MIGRATING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Migrating Google API Core (GAX) from V1 to V2

## How to upgrade

Update your `google/gax` dependency to `^2.0`:

```json
{
"require": {
"google/gax": "^2.0"
}
}
```

## Breaking Changes

### Removed Classes, Interfaces, and Traits

- **`Google\ApiCore\GPBType` and `Google\ApiCore\GPBLabel`**: Removed. Use `Google\Protobuf\Internal\GPBType` and `Google\Protobuf\Internal\GPBLabel` instead.
- **`Google\ApiCore\KnownTypes::GRPC_TYPES` and `Google\ApiCore\KnownTypes::JSON_TYPES`**: Removed.
- **`Google\ApiCore\ServiceAddressTrait`**: Replaced by `Google\ApiCore\ApiEndpointTrait` (`self::normalizeServiceAddress()` is now `self::normalizeApiEndpoint()`).
- **`Google\ApiCore\Transport\Grpc\UnaryInterceptorInterface`**: Removed. Extend `Grpc\Interceptor` directly instead.
- **`Google\ApiCore\Testing\MockGrpcTransport`**: Moved to the internal test suite (`Google\ApiCore\Tests\Testing\MockGrpcTransport`) and is no longer distributed with the package.

### Removed Dependencies

- **`google/grpc-gcp`**: Removed along with the `gcpApiConfigPath` client option, `ClientOptionsTrait::initGrpcGcpConfig()`, and `Grpc\Gcp\GCPServerStreamCall` handling in `ServerStreamingCallWrapper`.

### Removed Options

- **`gcpApiConfigPath` client option**: Removed along with `google/grpc-gcp`.
- **`operationsClientClass` client option**: Removed. Pass a pre-constructed client via the `operationsClient` option instead.
- **`CallOptions::setTransportSpecificOptions()`**: Removed. Use `CallOptions::setTransportOptions()` instead.

### Removed Methods and Legacy V1 Client Surface Support

- **`CredentialsWrapper::getBearerString()`**: Removed. Use `CredentialsWrapper::getAuthorizationHeaderCallback()` instead.
- **`ClientOptionsTrait::initGrpcGcpConfig()`**: Removed.
- **`HttpUnaryTransportTrait::startServerStreamingCall()`**: Removed (along with the `unsupportedServerStreamingCall` trait alias on `RestTransport`).
- **V1 GAPIC surface backwards-compatibility mode**:
- Removed `GapicClientTrait::$backwardsCompatibilityMode` and `GapicClientTrait::isBackwardsCompatibilityMode()`.
- Removed the `User-Agent: gcloud-php-legacy/*` and `gcloud-php-new/*` headers previously added in `GapicClientTrait`.
- Default long-running operations client in `GapicClientTrait` and `OperationResponse` now uses the V2 surface `Google\LongRunning\Client\OperationsClient` instead of `Google\LongRunning\OperationsClient`, and `OperationResponse` requires operation request classes implementing `::build()`.

### Credentials Hierarchy Changes

- **`Google\ApiCore\InsecureCredentialsWrapper`** now implements `Google\ApiCore\HeaderCredentialsInterface` directly and no longer extends `Google\ApiCore\CredentialsWrapper`.
- **`Google\ApiCore\HeaderCredentialsInterface`** now extends `Google\Auth\GetQuotaProjectInterface`.
- **`GapicClientTrait::getCredentialsWrapper()`** has been replaced by `GapicClientTrait::getHeaderCredentials()`, returning `HeaderCredentialsInterface` instead of `CredentialsWrapper` (and `ClientOptionsTrait::createCredentialsWrapper()` has been renamed to `ClientOptionsTrait::createHeaderCredentials()`).
- **`ResumableUploadClient::__construct()`** and **`CredentialsWrapperMiddleware::__construct()`** now accept `HeaderCredentialsInterface` instead of `CredentialsWrapper`.

### Strict Types and Method Signatures

- Added `declare(strict_types=1)` across all `Google\ApiCore` files.
- Added native parameter, property, and return type declarations across all `Google\ApiCore` classes, interfaces (`TransportInterface`, `MiddlewareInterface`, `ResourceTemplateInterface`, `ServerStreamingCallInterface`, `ResumableUploadTransportInterface`, `HeaderCredentialsInterface`), and traits.
- **`PathTemplate::__construct(string $path)`** now requires a non-null `string`.
8 changes: 5 additions & 3 deletions Gax/src/AgentHeader.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/*
* Copyright 2016 Google LLC
* All rights reserved.
Expand Down Expand Up @@ -59,7 +61,7 @@ class AgentHeader
* }
* @return array Agent header array
*/
public static function buildAgentHeader(array $headerInfo)
public static function buildAgentHeader(array $headerInfo): array
{
$metricsHeaders = [];

Expand Down Expand Up @@ -118,13 +120,13 @@ public static function buildAgentHeader(array $headerInfo)
* @return string the gapic version
* @throws \ReflectionException
*/
public static function readGapicVersionFromFile(string $callingClass)
public static function readGapicVersionFromFile(string $callingClass): string
{
$callingClassFile = (new \ReflectionClass($callingClass))->getFileName();
$versionFile = substr(
$callingClassFile,
0,
strrpos($callingClassFile, DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR)
strrpos($callingClassFile, DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR) ?: 0
) . DIRECTORY_SEPARATOR . 'VERSION';

return Version::readVersionFile($versionFile);
Expand Down
54 changes: 28 additions & 26 deletions Gax/src/ApiException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/*
* Copyright 2016 Google LLC
* All rights reserved.
Expand Down Expand Up @@ -42,10 +44,10 @@
*/
class ApiException extends Exception
{
private $status;
private $metadata;
private $basicMessage;
private $decodedMetadataErrorInfo;
private ?string $status;
private mixed $metadata;
private ?string $basicMessage;
private ?array $decodedMetadataErrorInfo = null;
private array $protobufErrors;

/**
Expand Down Expand Up @@ -81,7 +83,7 @@ public function __construct(
$this->protobufErrors = $protobufErrors;
}

public function getStatus()
public function getStatus(): ?string
{
return $this->status;
}
Expand All @@ -96,7 +98,7 @@ public function getStatus()
* @type array|null $errorInfoMetadata
* }
*/
private static function decodeMetadataErrorInfo(array $metadata)
private static function decodeMetadataErrorInfo(array $metadata): array
{
$details = [];
// ApiExceptions created from RPC status have metadata that is an array of objects.
Expand All @@ -117,7 +119,7 @@ private static function decodeMetadataErrorInfo(array $metadata)
* Returns the `reason` in ErrorInfo for an exception, or null if there is no ErrorInfo.
* @return string|null $reason
*/
public function getReason()
public function getReason(): ?string
{
return ($this->decodedMetadataErrorInfo) ? $this->decodedMetadataErrorInfo['reason'] : null;
}
Expand All @@ -126,7 +128,7 @@ public function getReason()
* Returns the `domain` in ErrorInfo for an exception, or null if there is no ErrorInfo.
* @return string|null $domain
*/
public function getDomain()
public function getDomain(): ?string
{
return ($this->decodedMetadataErrorInfo) ? $this->decodedMetadataErrorInfo['domain'] : null;
}
Expand All @@ -135,7 +137,7 @@ public function getDomain()
* Returns the `metadata` in ErrorInfo for an exception, or null if there is no ErrorInfo.
* @return array|null $errorInfoMetadata
*/
public function getErrorInfoMetadata()
public function getErrorInfoMetadata(): ?array
{
return ($this->decodedMetadataErrorInfo) ? $this->decodedMetadataErrorInfo['errorInfoMetadata'] : null;
}
Expand All @@ -153,7 +155,7 @@ public function getErrorDetails(): array
* @param stdClass $status
* @return ApiException
*/
public static function createFromStdClass(stdClass $status)
public static function createFromStdClass(stdClass $status): self
{
$metadata = property_exists($status, 'metadata') ? $status->metadata : null;
$errors = [];
Expand All @@ -171,15 +173,15 @@ public static function createFromStdClass(stdClass $status)
* @param string $basicMessage
* @param int $rpcCode
* @param array|null $metadata
* @param Exception $previous
* @param Exception|null $previous
* @return ApiException
*/
public static function createFromApiResponse(
$basicMessage,
$rpcCode,
string $basicMessage,
int $rpcCode,
?array $metadata = null,
?Exception $previous = null
) {
): self {
$errors = [];
return self::create(
$basicMessage,
Expand All @@ -197,15 +199,15 @@ public static function createFromApiResponse(
* @param string $basicMessage
* @param int $rpcCode
* @param array|null $metadata
* @param Exception $previous
* @param Exception|null $previous
* @return ApiException
*/
public static function createFromRestApiResponse(
$basicMessage,
$rpcCode,
string $basicMessage,
int $rpcCode,
?array $metadata = null,
?Exception $previous = null
) {
): self {
return self::create(
$basicMessage,
$rpcCode,
Expand All @@ -226,7 +228,7 @@ public static function createFromRestApiResponse(
* @type array $errorInfoMetadata
* }
*/
private static function containsErrorInfo(array $decodedMetadata)
private static function containsErrorInfo(array $decodedMetadata): array
{
if (empty($decodedMetadata)) {
return [];
Expand Down Expand Up @@ -260,11 +262,11 @@ private static function containsErrorInfo(array $decodedMetadata)
private static function create(
string $basicMessage,
int $rpcCode,
$metadata,
mixed $metadata,
array $decodedMetadata,
?array $protobufErrors = null,
?Exception $previous = null
) {
): self {
$containsErrorInfo = self::containsErrorInfo($decodedMetadata);
$rpcStatus = ApiStatus::statusFromRpcCode($rpcCode);
$messageData = [
Expand Down Expand Up @@ -334,7 +336,7 @@ private static function decodeMetadataToProtobufErrors(array $metadata): array
* @param Status $status
* @return ApiException
*/
public static function createFromRpcStatus(Status $status)
public static function createFromRpcStatus(Status $status): self
{
return self::create(
$status->getMessage(),
Expand All @@ -354,7 +356,7 @@ public static function createFromRpcStatus(Status $status)
* @return ApiException
* @throws ValidationException
*/
public static function createFromRequestException(RequestException $ex, bool $isStream = false)
public static function createFromRequestException(RequestException $ex, bool $isStream = false): self
{
// Guzzle 7 carries the response on RequestException, Guzzle 8 only on
// its ResponseException subclass, hence the method_exists() check.
Expand Down Expand Up @@ -385,15 +387,15 @@ public static function createFromRequestException(RequestException $ex, bool $is
/**
* @return null|string
*/
public function getBasicMessage()
public function getBasicMessage(): ?string
{
return $this->basicMessage;
}

/**
* @return mixed[]
* @return mixed[]|null
*/
public function getMetadata()
public function getMetadata(): mixed
{
return $this->metadata;
}
Expand Down
2 changes: 2 additions & 0 deletions Gax/src/ApiKeyHeaderCredentials.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/*
* Copyright 2024 Google LLC
* All rights reserved.
Expand Down
2 changes: 2 additions & 0 deletions Gax/src/ApiStatus.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/*
* Copyright 2017 Google LLC
* All rights reserved.
Expand Down
14 changes: 8 additions & 6 deletions Gax/src/ArrayTrait.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/*
* Copyright 2018 Google LLC
* All rights reserved.
Expand Down Expand Up @@ -48,7 +50,7 @@ trait ArrayTrait
* @return mixed|null
* @throws \InvalidArgumentException
*/
private function pluck(string $key, array &$arr, bool $isRequired = true)
private function pluck(string $key, array &$arr, bool $isRequired = true): mixed
{
if (!array_key_exists($key, $arr)) {
if ($isRequired) {
Expand All @@ -72,7 +74,7 @@ private function pluck(string $key, array &$arr, bool $isRequired = true)
* @param array $arr
* @return array
*/
private function pluckArray(array $keys, array &$arr)
private function pluckArray(array $keys, array &$arr): array
{
$values = [];

Expand All @@ -91,7 +93,7 @@ private function pluckArray(array $keys, array &$arr)
* @param array $arr
* @return bool
*/
private function isAssoc(array $arr)
private function isAssoc(array $arr): bool
{
return array_keys($arr) !== range(0, count($arr) - 1);
}
Expand All @@ -102,7 +104,7 @@ private function isAssoc(array $arr)
* @param array $arr
* @return array
*/
private function arrayFilterRemoveNull(array $arr)
private function arrayFilterRemoveNull(array $arr): array
{
return array_filter($arr, function ($element) {
if (!is_null($element)) {
Expand All @@ -120,7 +122,7 @@ private function arrayFilterRemoveNull(array $arr)
* @param array $arr
* @return array
*/
private function subsetArray(array $keys, array $arr)
private function subsetArray(array $keys, array $arr): array
{
return array_intersect_key(
$arr,
Expand All @@ -139,7 +141,7 @@ private function subsetArray(array $keys, array $arr)
* @param array $array2
* @return array
*/
private function arrayMergeRecursive(array $array1, array $array2)
private function arrayMergeRecursive(array $array1, array $array2): array
{
foreach ($array2 as $key => $value) {
if (array_key_exists($key, $array1) && is_array($array1[$key]) && is_array($value)) {
Expand Down
Loading
Loading