Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add union type to support the ClientOptions class in the client constructor #725

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Hectorhammett
Copy link
Contributor

No description provided.

@Hectorhammett Hectorhammett requested review from a team as code owners August 26, 2024 22:07
Copy link
Contributor

@bshaffer bshaffer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick review!

src/Generation/GapicClientV2Generator.php Outdated Show resolved Hide resolved
src/Utils/Type.php Outdated Show resolved Hide resolved
src/Utils/Type.php Outdated Show resolved Hide resolved
src/Utils/ResolvedType.php Outdated Show resolved Hide resolved
src/Utils/ResolvedType.php Outdated Show resolved Hide resolved
@@ -72,6 +72,7 @@ private function generateImpl(): PhpFile
{
// TODO(vNext): Remove the forced addition of these `use` clauses.
$this->ctx->type(Type::fromName(\Google\ApiCore\PathTemplate::class));
$this->ctx->type(Type::fromName(\Google\ApiCore\Options\ClientOptions::class));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably go in private function construct(), to keep it together with the function it goes with below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see what you mean, my thought was to match 1 to 1 how does this gets placed in the generated file. For example, due finding Google\ApiCore\PathTemplate on the generated file, I was able to determine how this gets added.

Still, I am not completely opposed to moving it to another place.

Copy link
Contributor

@bshaffer bshaffer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When these changes roll out, we'll need to pin to whatever minimum version of GAX supports the new method signatures in GapicClientTrait::buildLCientOptions (in google-cloud-php)

@@ -333,7 +334,7 @@ public static function parseName(string $formattedName, string $template = null)
*
* @throws ValidationException
*/
public function __construct(array $options = [])
public function __construct(array|ClientOptions $options = [])
{
$clientOptions = $this->buildClientOptions($options);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As buildClientOptions doesn't support ClientOptions, we'll need to update this in GAX (this is somewhat handled in googleapis/gax-php#580, but should probably be separated from the changes to make the properties public).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants