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

Typehint to DateTimeImmutable instead of DateTimeInterface #6

Open
Roshyo opened this issue Jan 25, 2022 · 2 comments
Open

Typehint to DateTimeImmutable instead of DateTimeInterface #6

Roshyo opened this issue Jan 25, 2022 · 2 comments

Comments

@Roshyo
Copy link

Roshyo commented Jan 25, 2022

For some (obscure) reasons, the DateTimeInterface is missing some methods, such as add() modify(). And since the current implementation is only returning DateTimeImmutable, I think we should typehint it to that, so StaticAnalysis tools will stop complaining.

@stof
Copy link

stof commented Jun 27, 2022

the reason is not obscure actually: DateTime::add and DateTimeImmutable::add cannot be used in the same way transparently (with DateTime::add, the current object is mutated, so your code might be ignoring the return value)

@Roshyo
Copy link
Author

Roshyo commented Jun 29, 2022

Ha okay, I understand why now. Thanks for the clarification ❤️

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