Skip to content
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

The clock class should only return instances of DateTimeInterface #3

Open
thkoch2001 opened this issue Dec 15, 2014 · 0 comments
Open
Assignees

Comments

@thkoch2001
Copy link

Although DateTimeInterface is only available from PHP 5.5 we should already declare the return values as such:
http://php.net/manual/de/class.datetimeinterface.php

All methods that now return a DateTime instance should instead call a method that prepares the return value:

  • If the given value already is an instance of DateTimeImmutable than return it.
  • Otherwise return a copy of the given DateTime instance

This is necessary to avoid other code to mess up our internal DateTime instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants