Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84342 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45980 invoked from network); 5 Mar 2015 13:45:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2015 13:45:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=dennis@birkholz.biz; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=dennis@birkholz.biz; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain birkholz.biz does not designate 144.76.185.252 as permitted sender) X-PHP-List-Original-Sender: dennis@birkholz.biz X-Host-Fingerprint: 144.76.185.252 mx01.nexxes.net Received: from [144.76.185.252] ([144.76.185.252:52624] helo=mx01.nexxes.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D7/F0-40418-D0E58F45 for ; Thu, 05 Mar 2015 08:45:50 -0500 Received: from [137.226.183.192] (ip3192.saw.rwth-aachen.de [137.226.183.192]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: db220660-p0g-1@packages.nexxes.net) by mx01.nexxes.net (Postfix) with ESMTPSA id 1926448246C; Thu, 5 Mar 2015 14:45:47 +0100 (CET) Message-ID: <54F85E0A.8020400@birkholz.biz> Date: Thu, 05 Mar 2015 14:45:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Trevor Suarez , PHP internals References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [PR] DateTime::createFromImmutable() method From: dennis@birkholz.biz (Dennis Birkholz) 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 >