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:
1. Only accept DateTimeImmutable.
2. 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