3 ms·
> The old datetime's method modifies the object in place[-1], if you replace the old with the new it's not going to work anymore. Of course it would be impossi
by shawnz 12y ago
> The old datetime's method modifies the object in place[-1], if you replace the old with the new it's not going to work anymore.
Of course it would be impossible to make the APIs exactly the same, because the two classes have different behaviour. But shouldn't they at least strive to make the APIs as similar as possible?
- masklinn 12y ago> But shouldn't they at least strive to make the APIs as similar as possible? No, not when the behavior is completely dissimilar and the method name is highly misleading.
- shawnz 12y agoThe behaviour is not completely dissimilar. The only difference between the two methods is what is done with the result. In fact, every method in that class parallels one from the other class in exactly that way, and that behaviour is described clearly on the documentation page for the class: > This class behaves the same as DateTime except it never modifies itself but returns a new object instead. http://www.php.net/manual/en/class.datetimeimmutable.php http://www.php.net/manual/en/class.datetimeimmutable.php