chore(BigQuery): Clarifying supported date/time format in examples#8545
chore(BigQuery): Clarifying supported date/time format in examples#8545cy-yun merged 1 commit intogoogleapis:mainfrom
Conversation
| * @return LoadJobConfiguration | ||
| */ | ||
| public function columnNameCharacterMap(string $columnNameCharacterMap): self | ||
| public function columnNameCharacterMap(string $columnNameCharacterMap) |
There was a problem hiding this comment.
Question:
I see that you decided to remove the self. Was this causing issues for some reason? We are currently trying to enforce return types on new code (And want to update old code as well) but I want to know the reason why this return type is getting removed :).
Maybe there's something I am missing and need documenting.
There was a problem hiding this comment.
They weren't causing any issues. I added these setters in a recent PR (#8468). I was reviewing this file while correcting the examples on the date/time format and noticed that previously existing setters do not have a return type (I thought PHP implies static return type in this case, but I was misinformed. It wouldn't assume any particular return type). I asked Gemini what return type would be best practice (self vs static) and it answered:
In PHP, self and static are used for type hinting, but they behave differently
with inheritance.
- `self`: Refers to the exact class in which the type hint is written.
- `static`: Refers to the class that is called at runtime. This is known as
"late static binding."
The difference matters when a class is extended. If a method in a parent class
returns self, type-hinting systems will infer the return type as the parent class,
even if the method is called on a child class instance. If it returns static, the
type will be correctly inferred as the child class.
Using static is generally preferred for fluent interfaces in classes that might be
extended, as it allows for better static analysis and autocompletion on child
classes.
I'll fix this PR such that we use static return type for all of the setters.
There was a problem hiding this comment.
Nvm, changing return types is a breaking change. I'll just change the examples
There was a problem hiding this comment.
Thanks!
Yeah we are on our way of typing everything. This codebase is a bit old so not everything is typing, so we really appreciate the return types.
If you don't define a return type, it basically is returning a mixed type to my understanding. Which means that you lose typing and you lose autocomplete on your IDE.
07ac0c1 to
57db482
Compare
57db482 to
84c27ba
Compare
Uh oh!
There was an error while loading. Please reload this page.