-
Notifications
You must be signed in to change notification settings - Fork 10
Fix and improve type annotations. #43
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
Conversation
| * @template U | ||
| * | ||
| * @param U $optb | ||
| * @return T|U | ||
| */ | ||
| abstract public function unwrapOr($optb); | ||
|
|
||
| /** | ||
| * Returns the contained value or computes it from a callable. | ||
| * | ||
| * @param callable(): T $op | ||
| * @return T | ||
| * @template U | ||
| * | ||
| * @param callable(): U $op | ||
| * @return T|U |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will make it behave differently from the Rust implementation. It looks like the these methods there return the same type of value as contained in the Option itself. Here are the docs for reference. So I think this should be as it was before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imho it doesn't have to slavishly like Rust, this makes it more flexible. Rust has much better language level constructs to handle Options/Results, so a bit of leeway is, I think, acceptable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this reasoning FWIW, the goal of the lib is to deliver value to the PHP language.
|
Unfortunately some of the CI is a bit dusty. Let's ignore that failed job. |
prewk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
Please do the result one as well, and I'll make a release afterwards. |
Here it is prewk/result#43 |
As discussed in #42
If this is fine I can submit an analogous PR for prewk/result.