diff --git a/src/Generation/ServiceDetails.php b/src/Generation/ServiceDetails.php index 2f4cc1002..13e89d36d 100644 --- a/src/Generation/ServiceDetails.php +++ b/src/Generation/ServiceDetails.php @@ -171,8 +171,10 @@ public function __construct( $this->docLines = $desc->leadingComments; $this->serviceName = "{$package}.{$desc->getName()}"; $this->shortName = $desc->getName(); - $this->defaultHost = ProtoHelpers::getCustomOption($desc, CustomOptions::GOOGLE_API_DEFAULTHOST); - $this->defaultPort = 443; + $defaultHost = ProtoHelpers::getCustomOption($desc, CustomOptions::GOOGLE_API_DEFAULTHOST); + $hostParts = explode(':', $defaultHost ?? '', 2); + $this->defaultHost = $hostParts[0]; + $this->defaultPort = isset($hostParts[1]) ? (int) $hostParts[1] : 443; $this->defaultScopes = Vector::new(explode(',', ProtoHelpers::getCustomOption($desc, CustomOptions::GOOGLE_API_OAUTHSCOPES) ?? '')) ->filter(fn ($x) => $x != '') diff --git a/tests/Unit/ProtoTests/BasicDiregapic/out/src/Client/LibraryClient.php b/tests/Unit/ProtoTests/BasicDiregapic/out/src/Client/LibraryClient.php index e4e6ea15f..62b47f076 100644 --- a/tests/Unit/ProtoTests/BasicDiregapic/out/src/Client/LibraryClient.php +++ b/tests/Unit/ProtoTests/BasicDiregapic/out/src/Client/LibraryClient.php @@ -145,13 +145,13 @@ final class LibraryClient * * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. */ - private const SERVICE_ADDRESS = 'library-example.googleapis.com:1234'; + private const SERVICE_ADDRESS = 'library-example.googleapis.com'; /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'library-example.UNIVERSE_DOMAIN:1234'; + private const SERVICE_ADDRESS_TEMPLATE = 'library-example.UNIVERSE_DOMAIN'; /** The default port of the service. */ - private const DEFAULT_SERVICE_PORT = 443; + private const DEFAULT_SERVICE_PORT = 1234; /** The name of the code generator, to be included in the agent header. */ private const CODEGEN_NAME = 'gapic'; @@ -592,7 +592,7 @@ public static function parseName(string $formattedName, ?string $template = null * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'library-example.googleapis.com:1234:443'. + * as ":". Default 'library-example.googleapis.com:1234'. * @type FetchAuthTokenInterface|CredentialsWrapper $credentials * This option should only be used with a pre-constructed * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that diff --git a/tests/Unit/ProtoTests/DeprecatedService/out/samples/DeprecatedServiceClient/fast_fibonacci.php b/tests/Unit/ProtoTests/DeprecatedService/out/samples/DeprecatedServiceClient/fast_fibonacci.php index 4f8aab8b2..b2a098c16 100644 --- a/tests/Unit/ProtoTests/DeprecatedService/out/samples/DeprecatedServiceClient/fast_fibonacci.php +++ b/tests/Unit/ProtoTests/DeprecatedService/out/samples/DeprecatedServiceClient/fast_fibonacci.php @@ -22,7 +22,7 @@ require_once __DIR__ . '/../../../vendor/autoload.php'; -// [START localhost:7469_generated_DeprecatedService_FastFibonacci_sync] +// [START localhost_generated_DeprecatedService_FastFibonacci_sync] use Google\ApiCore\ApiException; use Testing\Deprecated\Client\DeprecatedServiceClient; use Testing\Deprecated\FibonacciRequest; @@ -52,4 +52,4 @@ function fast_fibonacci_sample(): void printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); } } -// [END localhost:7469_generated_DeprecatedService_FastFibonacci_sync] +// [END localhost_generated_DeprecatedService_FastFibonacci_sync] diff --git a/tests/Unit/ProtoTests/DeprecatedService/out/samples/DeprecatedServiceClient/slow_fibonacci.php b/tests/Unit/ProtoTests/DeprecatedService/out/samples/DeprecatedServiceClient/slow_fibonacci.php index 732f21101..b7080f31d 100644 --- a/tests/Unit/ProtoTests/DeprecatedService/out/samples/DeprecatedServiceClient/slow_fibonacci.php +++ b/tests/Unit/ProtoTests/DeprecatedService/out/samples/DeprecatedServiceClient/slow_fibonacci.php @@ -22,7 +22,7 @@ require_once __DIR__ . '/../../../vendor/autoload.php'; -// [START localhost:7469_generated_DeprecatedService_SlowFibonacci_sync] +// [START localhost_generated_DeprecatedService_SlowFibonacci_sync] use Google\ApiCore\ApiException; use Testing\Deprecated\Client\DeprecatedServiceClient; use Testing\Deprecated\FibonacciRequest; @@ -52,4 +52,4 @@ function slow_fibonacci_sample(): void printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); } } -// [END localhost:7469_generated_DeprecatedService_SlowFibonacci_sync] +// [END localhost_generated_DeprecatedService_SlowFibonacci_sync] diff --git a/tests/Unit/ProtoTests/DeprecatedService/out/src/Client/DeprecatedServiceClient.php b/tests/Unit/ProtoTests/DeprecatedService/out/src/Client/DeprecatedServiceClient.php index a061e7699..123fe2527 100644 --- a/tests/Unit/ProtoTests/DeprecatedService/out/src/Client/DeprecatedServiceClient.php +++ b/tests/Unit/ProtoTests/DeprecatedService/out/src/Client/DeprecatedServiceClient.php @@ -56,10 +56,10 @@ final class DeprecatedServiceClient private const SERVICE_NAME = 'testing.deprecated_service.DeprecatedService'; /** The default address of the service. */ - private const SERVICE_ADDRESS = 'localhost:7469'; + private const SERVICE_ADDRESS = 'localhost'; /** The default port of the service. */ - private const DEFAULT_SERVICE_PORT = 443; + private const DEFAULT_SERVICE_PORT = 7469; /** The name of the code generator, to be included in the agent header. */ private const CODEGEN_NAME = 'gapic'; @@ -100,7 +100,7 @@ private static function getClientDefaults() * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'localhost:7469:443'. + * as ":". Default 'localhost:7469'. * @type FetchAuthTokenInterface|CredentialsWrapper $credentials * This option should only be used with a pre-constructed * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that