Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66828 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59727 invoked from network); 27 Mar 2013 12:18:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Mar 2013 12:18:22 -0000 Authentication-Results: pb1.pair.com header.from=lars@strojny.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=lars@strojny.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain strojny.net from 46.4.40.248 cause and error) X-PHP-List-Original-Sender: lars@strojny.net X-Host-Fingerprint: 46.4.40.248 milch.schokokeks.org Received: from [46.4.40.248] ([46.4.40.248:57129] helo=milch.schokokeks.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B0/A4-30100-C83E2515 for ; Wed, 27 Mar 2013 07:18:21 -0500 Received: from [192.168.1.130] (p5099f5c8.dip0.t-ipconnect.de [::ffff:80.153.245.200]) (AUTH: PLAIN lars@schokokeks.org, TLS: TLSv1/SSLv3,128bits,AES128-SHA) by milch.schokokeks.org with ESMTPSA; Wed, 27 Mar 2013 13:18:17 +0100 id 0000000000000024.000000005152E389.00006053 Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) In-Reply-To: Date: Wed, 27 Mar 2013 13:18:16 +0100 Cc: Michael Wallner , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Ferenc Kovacs X-Mailer: Apple Mail (2.1499) Subject: Re: [PHP-DEV] DateTimeImmutable From: lars@strojny.net (Lars Strojny) Not really, as an interface guarantees behavior, which is not possible = for DateTimeImmutable and DateTime. Am 27.03.2013 um 09:03 schrieb Ferenc Kovacs : > 2013.03.26. 20:29, "Michael Wallner" ezt =EDrta: >>=20 >> Hi all! >>=20 >> I am concerned by the introduction of DateTimeImmutable extending >> DateTime, and despite not being the talking guy, I'll try to outline >> the reasons why I and obviously a lot of other people think so. >>=20 >> I can understand the frustration with a DateTime that should not have >> been modifiable in the first place and the wish to improve upon = things >> and to lead users to the proper way. But, this is not the right way. >>=20 >> If interoperability was in mind, it will not be given, because every >> single API which has been written in the last seven years and has >> DateTime in it's signature is potentially broken. The code may and >> should be able to expect a modifiable instance of DateTime, which is >> no longer guaranteed. >>=20 >> The argument, that it was implemented this way, so that method >> signatures do not have to be changed, is weak, because every method >> has to be reviewed, and a method signature change would actually be >> the right thing to accept a DateTimeImmutable, because it does not = act >> like a DateTime. >>=20 >> It will lead to lots of boilerplate typechecking code with instanceof >> because it actually is not the same type. DateTimeImmutable extending >> DateTime will instantly create BC issues, which we will suffer from a >> long time. >>=20 >> The toughtful developer, which already cloned the DateTimes in his >> methods won't benefit either, because now he's cloning >> DateTimeImmutables. >>=20 >> In my opinion, the only way to "solve" this issue is through >> documentation, advocation, publication and providing = DateTimeImmutable >> as a sibling to DateTime. >>=20 >> DateTime is here, and we cannot go back in time, but we might >> deprecate DateTime* and introduce a date namespace in PHP-next to >> clean up this front, but this already goes beyond the issue with >> DateTimeImmutable. >>=20 >>=20 >> -- >> Regards, >> Mike >>=20 >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >>=20 >=20 > would it make sense to introduce an interface wich both DateTime and > DateTimeImmutable implements? > that way you can typehint for both if you know that both classes are = fine > for you.