Re: Questions regarding DateTimeImmutable
| From: | Sebastian Bergmann | Date: | Sat, 16 Feb 2013 08:28:17 +0000 |
| Subject: | Re: Questions regarding DateTimeImmutable | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-65888@lists.php.net to get a copy of this message | ||
Am 15.02.2013 21:49, schrieb Nikita Popov:
> a) The DateTimeImmutable class extends the DateTime class. Why was this
> done this way? Both classes are incompatible (as in the inheritance
> violates LSP). E.g. if you hint against DateTime, then passing in
> DateTimeImmutable will not work (as the behavior is different). The same
> also applies the other way around (DateTime extending DateTimeImmutable).
> Imho a mutable and an immutable variant of a class can't reasonably extend
> from one another, so I'm not sure why this was done.
I raised the same question to Derick and he said that it had to be done
this way because of BC issues. The way it is implemented right now makes
no sense to me at all. Thank you, Nikita, for bringing this to the
attention of this list.
--
Sebastian Bergmann Co-Founder and Principal Consultant
http://sebastian-bergmann.de/
http://thePHP.cc/