Re: Questions regarding DateTimeImmutable
| From: | Derick Rethans | Date: | Wed, 27 Mar 2013 11:37:10 +0000 |
| Subject: | Re: Questions regarding DateTimeImmutable | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-66827@lists.php.net to get a copy of this message | ||
On Wed, 27 Mar 2013, Lester Caine wrote:
> Levi Morrison wrote:
> > While I personally think DateTime should have been immutable from the
> > beginning, I don't think it's in PHP's best interest to try to fix
> > this particular problem by introducing DateTimeImmutable.
>
> There seems to be some strange assumption that a DateTime value is fixed in
> some way? There have been various statements about 'should have been immutable
> from the beginning', and while I can see that some uses of it are read only,
> much of my own use is in building calendar arrays where one is adding months,
> days or hours to select the next set of matches. If this should always have
> been 'immutable' then how would one handle all the situations where one does
> need to update the value?
The updated value is still returned, it's just that the original object
you call (f.e.) ->modify() on is not.
cheers,
Derick