-
-
Notifications
You must be signed in to change notification settings - Fork 161
allow method chaining #205
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
base: 11.3.x
Are you sure you want to change the base?
Conversation
|
Hi, Many thanks for this PR. |
|
any updates? |
|
Method chaining is ok, but no fluent interfaces please as discussed in #166 (comment) I'm going to propose a PR against
In |
|
For reference, this is what we've done in
|
I'm confused, those are the same thing. I've read through your other PR and that 12 year old article from Ocramius, and I must be missing something because it makes no sense. You're gonna have to ELI5, because I'm not seeing what the problem is with this incredibly common pattern. |
|
An object that can mutate state is unpredictable as the same call to one of its API can return different results. The The Ideally the next major version should come with all the objects marked as |
|
Hi, Time goes by, and I must admit I totally forgot what I wrote three years ago 😅 I understand that method chaining is common (especially with builders) but in this case, I believe the default values are perfectly fine. I don't see any real issue with calling Thanks again for the proposal and the discussion! |
May I ask you why?
|
|
Mutable vs immutable is a whole separate discussion outside the scope of this PR. These classes are already mutable, and this PR does nothing to change that. Returning With this PR, users can choose to use either: $totp = Totp::generate();
$totp->setPeriod(10);
$totp->setEpoch(10);or $totp = Totp::generate()
->setPeriod(10)
->setEpoch(10);based on their personal preference. |
Major versions with BC Breaks should be minimized. The fact that this PR is zero-risk enhancement doesn't mean much: a BC Break is needed, so it's better to discuss all the BC Breaks that we want to apply to avoid another Major version in a near future. The immutability topic is inside the scope of the PR, because if accepted this very PR becomes invalid. |
|
Agree to disagree. I've proposed a simple change that will allow method chaining (very common pattern). The breaking change is likely non-existent, as it would only apply to users who created their own classes that implement the interface. @Slamdunk if you want to argue for a major shift in this codebase to immutability, I'd suggest you do it in a separate PR as it would likely also include scope outside of this PR. If you were to somehow convince a switch to immutability, it doesn't make this PR invalid, it just means the chaining needs to adjust to immutable chaining. @Spomky can you either merge or close? |
|
#244 is my proposal for a fluent API, ready to be upgraded to |
Target branch: Probably a new major, with the interface change?
Resolves issue NA
Allow users to chain methods when building their OTP.
I believe this breaks BC, and warrants a new Major due to the interface change.