Hi Trevor,

I had no look to the code as I am no C or internals guru.
I just wanted to add that I would prefer a generic
DateTimeInterface::createFromInstance(DateTimeInterface $copyFrom)
method, so you do not need to distinguish between DateTime and
DateTimeImmutable when creating a new instance. That should have be done
for the DateTimeImmutable, too. Otherwise you have to do the following:

function doSomethingWithNewDate(\DateTimeInterface $date) {
        if ($date instanceof \DateTimeImmutable) {
                $newDate = \DateTime::createFromImmutable($date);
        } else {
                $newDate = clone $date;
        }
}

But if you want to create a new instance from a date, it should not
matter if the source date is mutable or immutable.

Thanks
Dennis

Am 05.03.2015 um 08:50 schrieb Trevor Suarez:
> Good morning internals!
> 
> I would like to propose a small addition be made to the DateTime class.
> 
> https://github.com/php/php-src/pull/1145
> 
> This is my first contribution to PHP's core, beyond documentation edits.
> I'm not sure on the formalities that need to be taken for something like
> this to be considered as an addition, or if an email like this is even
> appropriate, so I'd absolutely welcome any guidance here.
> 
> I just saw a possible opportunity for an addition and thought it would be
> fun to try and contribute to PHP. :)
> 
> I'm not a C programmer by any means, so please forgive me if I've made any
> "noob" mistakes here, haha.
> 
> Thank you all for your time and consideration!
> 
> 
> - Trevor
> 

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

Reply via email to