-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] added withers to Cookie class #35215
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
I'm kinda against having a fluent interface as it doesn't really make sense to have a fluent here (it's not a builder...) Adding a mutable state why not, and maybe keep it immutable (returning a new instance with the property set correctly) would be even better IMO. (Hence my 😕 / 👎 reaction) |
@Taluu Maybe Sorry for my bad english but what's the difference between this PR and |
You made it fluent (returning |
Oh, I got you :-) I don't mind changing the PR so setters would become something like: public function setName(string $name): self
{
// ...validating $name...
$clone = clone $this;
$clone->name = $name;
return $clone;
} But I personally prefer |
Even better : make withers ( Or remove the return and make it mutable. |
I updated the PR with withers keeping the Cookie immutable. Appreciate it if you take a look. |
I need this ! but sad to have to wait for 5.2.0 release to get mutable cookie :/ |
d7bc008
to
c6e60e4
Compare
Thanks for your explanations @ns3777k, I missed that some attributes should remain nullable. |
Thanks for clarification! @nicolas-grekas I'm gonna move the withers up. |
Thank you @ns3777k. |
I was quite descriptive in the issue :-)
The main idea is to get the interface for changing a cookie to avoid every unneeded argument in the constructor.
Current:
This PR:
Every
wither
returns a copy of current cookie with requested setting set. Cookie class remains immutable.