-
Notifications
You must be signed in to change notification settings - Fork 116
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
Fix #73 and support immutable dates #75
Conversation
kylekatarnls
commented
Oct 30, 2018
- Allow DateTimeImmutable
- Fix nextOpen() and nextClose() don't return the correct values when called simultaneously #73: do not modify the passed datetime
- Allow multiple calls for nextClose/nextOpen
.gitignore
Outdated
@@ -2,3 +2,4 @@ build | |||
composer.lock | |||
docs | |||
vendor | |||
.idea |
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.
Remove this, it should be in a global gitignore
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.
Cleaned, it will disappear if you re-open the PR.
src/OpeningHours.php
Outdated
@@ -150,13 +151,17 @@ public function isClosed(): bool | |||
return $this->isClosedAt(new DateTime()); | |||
} | |||
|
|||
public function nextOpen(DateTimeInterface $dateTime): DateTime | |||
public function nextOpen(DateTimeInterface $dateTime): DateTimeInterface |
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.
Unfortunately changing the return type is a breaking change.
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.
Nop because your PHP requirement: php: ^7.0
implies that any DateTime
object implements DateTimeInterface
, so unless using reflexion, there is no break, but with reflexion, anything is breaking change.
Closing this as changing the return type is a breaking change. We'll revisit this when creating a new major version of the package. |
@freekmurze Nop because your PHP requirement: So you should not consider it as a breaking change and could safely implement this in the current major version. |
Then you still have the missing |
It is a breaking change. Consider this code:
If you change the return type of class A to
|
Still, this could have been done differently, simply closing this PR rather than asking for modifications (or take it partially to get the bug fixes, or tag it to be merged in next major version) seems very counter-productive to me. I recommend you a more encouraging contributing process for your PRs such as discuss first, propose alternatives, then decide when every participant finished to consider possible solutions. |
Thank you for your work around this. I'm sorry that my comments seems counter-productive to you. Feel free to either rework this PR (in that case I'll reopen it when you push changes) or submit a new PR altogether. |