Intentionally?
It is an issue for static analysers...
With kind regards / Mit freundlichen Grüßen / S přátelským pozdravem,
Michael Voříšek
ČVUT FEL
Relevant: https://chat.stackoverflow.com/transcript/11?m=50929139
I also think it would be nice to have modify method in the interface
as at the moment the interface seems pretty useless. I was told this
would be BC and we are not going to change it now.
On Tue, 1 Dec 2020 at 15:35, Michael Voříšek - ČVUT FEL
vorismi3@fel.cvut.cz wrote:
Intentionally?
It is an issue for static analysers...
With kind regards / Mit freundlichen Grüßen / S přátelským pozdravem,
Michael Voříšek
ČVUT FEL
On Tue, Dec 1, 2020 at 4:35 PM Michael Voříšek - ČVUT FEL <
vorismi3@fel.cvut.cz> wrote:
Intentionally?
It is an issue for static analysers...
With kind regards / Mit freundlichen Grüßen / S přátelským pozdravem,
Michael Voříšek
ČVUT FEL
Yes, this is intentional. The DateTimeInterface interface (has absolutely
nothing to do with stubs -- this is the same in PHP 7) only includes the
methods that are present in both DateTime and DateTimeImmuatable with the
same behavior.
DateTime::modify() and DateTimeImmutable::modify(), while having the same
signature, do completely different things. One performs an in-place
modification, while the other doesn't.
You should be doing one of two things:
- Only accept DateTimeImmutable.
- Accept DateTimeInterface and then use
DateTimeImmutable::createFromInterface() to convert it into a
DateTimeImmutable.
Working on a plain DateTimeInterface only makes sense if you are using the
read-only methods, which are the ones that are part of the
DateTimeInterface interface.
Regards,
Nikita