Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66822 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85990 invoked from network); 26 Mar 2013 19:29:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Mar 2013 19:29:12 -0000 Authentication-Results: pb1.pair.com header.from=mike.php.net@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mike.php.net@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: mike.php.net@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-la0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:36568] helo=mail-la0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 06/DD-16933-607F1515 for ; Tue, 26 Mar 2013 14:29:11 -0500 Received: by mail-la0-f42.google.com with SMTP id fe20so14301849lab.29 for ; Tue, 26 Mar 2013 12:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:sender:date:x-google-sender-auth:message-id :subject:from:to:content-type; bh=HWQ910qy27B4sYATWctlnSCVfYZkbSVA2FTcwyTJVG0=; b=FPfJzp+DTq7Qbxvnq73fhVOTi9SkIBSuK07b/mSseaQGRThiaWTwO+pYbkNnd6AUWc Q4VZbLQwTkRMHvN78PZIrmTlI4BhYnN8fHa3q0JgW0veY7ZG39cVSrUbV4xyyBmdJtNw NSWvmEx062lxVBNCivQL8691yvtWiuzc+P9ijqw152sDHOmiMnOKaF69YGtNjMtXAVyE gE+iRaOq4mRC0GZ6kZdC6TcD8KOa5Hi9RfdGBlP3LjAkWZgZgkCGpmjgiypHWhbZjMm+ z91614TQtRDj8yUTFXU0v+BdA0/hFk6qPN4z9It9w7IIQKTsx9Qz1gIY6WKShbb/2jlE pEXQ== MIME-Version: 1.0 X-Received: by 10.112.28.169 with SMTP id c9mr9012844lbh.84.1364326147569; Tue, 26 Mar 2013 12:29:07 -0700 (PDT) Sender: mike.php.net@gmail.com Received: by 10.114.4.109 with HTTP; Tue, 26 Mar 2013 12:29:07 -0700 (PDT) Date: Tue, 26 Mar 2013 20:29:07 +0100 X-Google-Sender-Auth: NiZ6bkUcBHwejs7NIKX-YGg8oi8 Message-ID: To: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: DateTimeImmutable From: mike@php.net (Michael Wallner) Hi all! 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. 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. 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. 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. 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. The toughtful developer, which already cloned the DateTimes in his methods won't benefit either, because now he's cloning DateTimeImmutables. In my opinion, the only way to "solve" this issue is through documentation, advocation, publication and providing DateTimeImmutable as a sibling to DateTime. 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. -- Regards, Mike