-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Clock] Add $modifier argument to the now() helper #51365
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
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.
Should we add a testcase?
489183a
to
498af55
Compare
Test case added, thanks for the review. |
I am not convinced that a function named |
I agree with @xabbuh |
|
498af55
to
39dcf4d
Compare
PR updated: it now leverages symfony/polyfill#440 so that we throw a
Yes, this reads perfectly fine
I don't see any issue with that personally. This is trivial to understand to me.
It doesn't to me, especially considering the fact this misses proper error handling. Also considering this is supposed to replace Please reconsider :) |
I still like the modifier and the reading, while I understand the concerns, I would go with this PR 👍🏻 |
39dcf4d
to
92ff2b2
Compare
I'm wondering whether the change to MockClock should really be bundled in the same PR (and so in the same commit in the final history). This would hide entirely the behavior change in MockClock even for people reading the full git history and not just the changelog (which filters out minor changes). |
I won't block but I think it's not worth it |
I think that explicitly calling a modify method is a much more obvious way to get a modified date from now. |
92ff2b2
to
ba7d002
Compare
PR updated with error handling moved to #51412
there are two major differences with
|
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 is a nice and concise syntax.
Developers can still call now()->modify('+10 minutes)
it they prefer.
I like that we can pass the timezone as modifier.
ba7d002
to
1a616c1
Compare
With this change, one can replace all
new \DateTimeImmutable($foo)
bynow($foo)
.