Marco Pivetta wrote on 21/07/2015 13:29:
Then make DateTime and DateTimeImmutable only interact with DateTime and
DateTimeImmutable (or child classes), but don't rely on the interface if
you're not actually respecting it internally in first place, no?

What exactly are you suggesting? That DateTimeInterface shouldn't exist at all?

It's useful to be able to check if a given variable is an instance of either DateTime or DateTimeImmutable, and an Interface is an obvious way to do this, regardless of what else can be done with that interface.

As you can see here: http://3v4l.org/SU1Xq this was definitely a bug in early 5.5.x releases (the error is a frankly baffling "Fatal error: DateTime::diff() must be derived from DateTimeImmutable::diff"), so the change in behaviour in a point release seems justified. HHVM apparently still allows the implementation, then fatals when you try to diff against it.

So, userland implementations of the interface have never worked; it might be nice to add the ability in, but in answer to the original question, yes, there's a reason behind this limitation.

Regards,
--
Rowan Collins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to