Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65901 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98201 invoked from network); 17 Feb 2013 16:22:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Feb 2013 16:22:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=kontakt@beberlei.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=kontakt@beberlei.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain beberlei.de from 209.85.212.176 cause and error) X-PHP-List-Original-Sender: kontakt@beberlei.de X-Host-Fingerprint: 209.85.212.176 mail-wi0-f176.google.com Received: from [209.85.212.176] ([209.85.212.176:42794] helo=mail-wi0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7B/B0-28778-6A301215 for ; Sun, 17 Feb 2013 11:21:59 -0500 Received: by mail-wi0-f176.google.com with SMTP id hm14so2670656wib.15 for ; Sun, 17 Feb 2013 08:21:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:x-originating-ip:in-reply-to:references :date:message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=O7Um9VZ1bLXpQiPBkcOGoXM5Z1XP8SjdocQ407k+3s8=; b=VLjmwkMm7z6xz6wIuOhgsN/TcmJhq3dL7c8UZrLE231ZbTf5CefMeERrXizNyCXFS8 MbEtM+Re4hw5+KqPGButhbbfhF5sWksbMxWPtZkRUe684BlkweFr4BdTstiQJSdbvHxN jC5BT4lf9nsP7UjilNipg0x7t3Kff9/huVNmjphQI1NcHZd8OxOba7zA4inkY1jK05CA ZURoYYn3zXLx4tu3zyxLZxTlQDsbDUyhVZBWmTTiTBWu8vya8gscyjKGJoXaRcU+MeyJ lCeofA/3jQxgrcrfMRhd9lRgVAzasp7tnYeQpXXsQ5Ifnn8YfdB4+zq2zcMoWqgoC/Q9 ViyQ== MIME-Version: 1.0 X-Received: by 10.180.73.238 with SMTP id o14mr12334537wiv.32.1361118115552; Sun, 17 Feb 2013 08:21:55 -0800 (PST) Received: by 10.194.5.233 with HTTP; Sun, 17 Feb 2013 08:21:55 -0800 (PST) X-Originating-IP: [77.13.217.108] In-Reply-To: <51201696.6080604@sugarcrm.com> References: <51201696.6080604@sugarcrm.com> Date: Sun, 17 Feb 2013 17:21:55 +0100 Message-ID: To: Stas Malyshev Cc: Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary=f46d043c80dac65d2e04d5ee0197 X-Gm-Message-State: ALoCoQn4JdvSVI8WcPyQv3cLUbPpvXWBHTeT2eqSFZtY/iTfCPmv7v43C/s4OSlvOOI7njrJgQmi Subject: Re: [PHP-DEV] Questions regarding DateTimeImmutable From: kontakt@beberlei.de (Benjamin Eberlei) --f46d043c80dac65d2e04d5ee0197 Content-Type: text/plain; charset=ISO-8859-1 Hey, would it be possible for DateTime and DateTimeImmutable to not extend each other at all and be two seperate classes? greetings, Benjamin On Sun, Feb 17, 2013 at 12:30 AM, Stas Malyshev wrote: > Hi! > > > a) The DateTimeImmutable class extends the DateTime class. Why was this > > done this way? Both classes are incompatible (as in the inheritance > > They're not really "incompatible". Functions that do not modify dates > would work just fine. So it's "not 100% compatible", which is not the > same as incompatible. Of course, we could instead create > DateTimeBaseAbstractClass, but IMHO rewriting all your code to support > it wouldn't be worth the trouble for 99.9% of the code, so what would > end up happening that nobody could use DateTimeImmutable with any > existing code that expects DateTime. I personally don't see much point > in DateTimeImmutable anyway (immutable data structures are very > important for concurrent programs but for PHP I don't see much benefit) > but if people need it, fine. But ask yourself a question - do you really > want to rewrite every library that accepts DateTime as an argument in > order to use DateTimeImmutable? > > > b) The DateTimeImmutable class is (method-wise) an exact copy of > DateTime. > > This makes for some rather weird method names for an immutable object. > E.g. > > there is DateTimeImmutable::modify, which to me seems quite > contradictory. > > There are also a lot of methods of the DateTimeImmutable::setTime form, > > which also seems rather odd and confusing (how can I set something on an > > immutable object?) > > I don't see how it's so hard to grasp - it sets time and returns the > modified object. I can't believe you genuinely don't understand how it > works. I have a feeling this "confusing" argument in getting somewhat > stale: PHP users - especially those that want to use specially designed > classes that are useable only in context of design of non-trivial > complexity - have sufficient brain capacity to understand what setTime > could do. And if they absolutely can't, they can to the unthinkable - > read the manual. > So I can see the LSP argument - but "confusing" argument really doesn't > seem to apply here. > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --f46d043c80dac65d2e04d5ee0197--