> You don't need to know if the instance is immutable or not, since the current 
> DateTime instances also return themselves for method chaining. So any code 
> that looks like:
>
> $d = $d->modify("+1 hour");
>
> would work no matter mutable/immutable. This is still a bit strange though. 
> But still any DateTimeValue would extend DateTime. So when you typehint
> for a "DateTime", you still don't know if you get the one or the other and 
> you would have to resort to the previous code example anyways.

I do need to know if the instance is immutable.  I have plenty of
class methods that modify the DateTime instance and some don't return
the DateTime instance back.  If you want to make sure the object is
immutable, you typehint for a DateTimeValue object.  From an OO
perspective, it makes much more sense to extend the class and add this
functionality than to change the inner workings of the existing class.

-- 
Herman Radtke
[email protected] | http://hermanradtke.com

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to