Re: Questions regarding DateTimeImmutable
| From: | Levi Morrison | Date: | Sat, 16 Feb 2013 03:04:24 +0000 |
| Subject: | Re: Questions regarding DateTimeImmutable | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-65887@lists.php.net to get a copy of this message | ||
> I think it was done to ease adoption even though it was known to
> violate LSP. To quote Stas, "As for established practice, everybody
> expects DateTime, so IMHO we should leave DateTime as base class even
> though it's not strictly OO-pure."
I can see how easing adoption would be logical, but honestly I don't
think this will help. Just because the outward API *looks* the same,
a DateTimeImmutable is NOT a drop in replacement for DateTime. I
honestly think that having one or the other inheriting from the other
isn't *just* an LSP violation: it's a really big one. It's so big I
don't think there's much worth of having them inherit; I dare say it
would hurt it.
> This way does let users sub in DateTimeImmutable more easily and patch
> over a ton of unintended -- maybe not even fully noted or understood
> -- defects in their apps? I dunno.
Exactly.