Ah nice approach to avoid the infinite loop, but I got a better one:

https://github.com/beberlei/Whitewashing/blob/master/DateTime/DateTime.php

Feel free to take this code, its new-bsd.

btw, I proposed an Immutable DateTime objects patch to the Internals list
1-2 month ago that was rejected for it adding a $immutable = true/false
flag only instead of fixing the underyling problem. Fixing the underlying
problem is too huge a task for my non-existant C skills though :-)

greetings,
Benjamin

On Mon, 31 Jan 2011 14:08:13 +0100, Tobias Schlitt <[email protected]>
wrote:
> Hi,
> 
> I had a quick chat with Derick during PHP Benelux about this patch. He
> suggested to make the DateTime objects in Template immutable. I'm pretty
> much for doing so and would actually desire to change that in PHP
> itself, if it would be possible.
> 
> Making DateTime objects immutable would result in much more sane
> behavior of date_modify(), date_add() and friends, since they would no
> more change the original object, but return a new one which has the
> desired manipulation applied.
> 
> We've an implementation for immutable DateTime lying around, which we
> could just move to Base/ so it's available for others easily, too. Find
> the code attached.
> 
> What do you think?
> 
> Regards,
> Toby

Reply via email to