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 support for to use a object with a union type #580

Open
wants to merge 3 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 30, 2024 21:40
@@ -61,37 +61,37 @@ class ClientOptions implements ArrayAccess
{
use OptionsTrait;

private ?string $apiEndpoint;
public ?string $apiEndpoint;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a highly opinionated change. My believe is that the options objects should be mostly structural and have easy of use for the user and the developers.

If you are in need or wanting to use this object, using an IDE and start typing $options-> should give a quick auto completion that helps the user understand the different options. We should document these values if we decided to continue with this philosophy.

Due this being highly opinionated though, I am willing to return this to private.

Copy link
Contributor

Choose a reason for hiding this comment

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

The only concern I have here is that if there's some logic being done in the setters (which is the case for a few of these), it would be lost in setting these manually, which may lead to some confusing behavior.

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.

One thing I think we should look into is how to make our reference documentation look better

The first 5 methods in https://googleapis.github.io/gax-php/main/Google/ApiCore/Options/ClientOptions.html are not helpful, the top code example does not really show how to use the class, and the first method that is useful (__construct) is a completely unformatted mess.

I'm not sure what impact it would have making the options public, and if that would help or hurt, but we should look into that also.


// The constructor of ClientOptions construct creates a `TransportOptions`.
// We call `toArray` on it and nested items that uses the `optionsTrait` to keep
// the same behaviour as if it was just an array.
Copy link
Contributor

Choose a reason for hiding this comment

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

We could also make toArray call toArray on those items.... it would be a breaking change, so I think it's a bad idea. It's a shame we didn't do that before! Maybe in a 2.0 version...

@@ -61,37 +61,37 @@ class ClientOptions implements ArrayAccess
{
use OptionsTrait;

private ?string $apiEndpoint;
public ?string $apiEndpoint;
Copy link
Contributor

Choose a reason for hiding this comment

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

The only concern I have here is that if there's some logic being done in the setters (which is the case for a few of these), it would be lost in setting these manually, which may lead to some confusing behavior.

@bshaffer
Copy link
Contributor

bshaffer commented Sep 20, 2024

@Hectorhammett
One thought on this - if we are unhappy with the ClientOptions interface, as we haven't exposed this class directly for use (nothing in our libraries accept OR return this class), if we want to make a change to it, now's the time.

I would suggest, just for safety, that we mark any changing methods as @deprecated for a month or so before doing this, just to be safe. But if we want to turn these into POPOs (which I think is a great idea), now's the time.

EDIT: Honorable mention here is to also move $quotaProject outside the credentials wrapper

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