Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64263 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24959 invoked from network); 11 Dec 2012 17:19:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2012 17:19:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=inefedor@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=inefedor@gmail.com; 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: inefedor@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-la0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:42053] helo=mail-la0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/4C-54245-41B67C05 for ; Tue, 11 Dec 2012 12:19:17 -0500 Received: by mail-la0-f42.google.com with SMTP id s15so3312775lag.29 for ; Tue, 11 Dec 2012 09:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:to:cc:subject:references:date:mime-version :content-transfer-encoding:from:organization:message-id:in-reply-to :user-agent; bh=71i+ny8hDol3zeZOP4l/XJvqhetlmgONJmgVD6wZ5EE=; b=CwqsWbI+/gFWPJsxN1apZeFofmgeinsWZoLLfhVg6ahCrfttgzfiBZ8Gd1dSy8DXgI acUhsGrBBK7r5rnf1ZCzhWRyOQ3WBFsepoWyiAwnfZ7kG3sCB9a21vvkADkI/tHRB0Sm yC8cgaMsrZ2dNtBtR/gPmSNK4X+Od3hmnVSzt8TxbUCOIEy4vyohIkQctCpYffH87C3W GDNPyt5G8Acr6w8yBHxpHaCeQkfFWdTZFqaAiL++v1e44uiTGjiBAvVhWrJhSrvs/xl2 UKirpXKSm2qkPyXmRxU3miffzawMpFHY3etEoCAVlspR7hTp4WFZUlkfcJRAdk/wxLRQ tV8w== Received: by 10.152.104.240 with SMTP id gh16mr18275541lab.56.1355246354230; Tue, 11 Dec 2012 09:19:14 -0800 (PST) Received: from xn--adm--jpa3a ([128.72.33.141]) by mx.google.com with ESMTPS id hu6sm9578775lab.13.2012.12.11.09.19.12 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 11 Dec 2012 09:19:13 -0800 (PST) Content-Type: text/plain; charset=koi8-r; format=flowed; delsp=yes To: "Marco Pivetta" , "Stas Malyshev" Cc: "internals@lists.php.net" References: <50C69191.5020201@sugarcrm.com> <50C767FD.8070901@sugarcrm.com> Date: Tue, 11 Dec 2012 21:20:15 +0400 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable Organization: home Message-ID: In-Reply-To: <50C767FD.8070901@sugarcrm.com> User-Agent: Opera Mail/12.11 (Win32) Subject: Re: [PHP-DEV] DateTime improvement From: inefedor@gmail.com (=?koi8-r?B?7snLydTB?=) Stas Malyshev =D0=C9=D3=C1=CC(=C1) =D7 =D3=D7=CF= =A3=CD =D0=C9=D3=D8=CD=C5 Tue, 11 Dec = 2012 21:06:05 +0400: > Hi! > >> As Nikita says, from an ORM perspective, an object is always immutabl= e >> (at least with current implementations I know of), and that's because= >> they can simply use the object hashes to identify two different objec= ts. > > Why for ORM Date is even an object? In most databases, date is a basic= > value type, and should be accepted by value, not as a complex object. > So, it should also be identified as the value - for number 1, you do n= ot > need additional identity or hash except it being number 1, same should= > be for dates. Then why do we even need DateTime class? We could stay with functions. I= = think if we want to bring some OOP in php, then we need to do it right w= ay. >> I don't believe (at all) in "if you don't need it mutable, don't use >> modify() oroverride modify()". If the API is there, people will use i= t. >> We tried to implement an immutable DateTime in userland, but it doesn= 't >> work out well... > > Why it doesn't work well and why PHP needs to be changed because of it= ? Because of some DateTime's limitations - you will end up making brand ne= w = DateTime class, reimplementing *all* the features that were implemented = in = DateTime. At first - you can't just extend DateTime, because of = factory-methods - so that way you will need to use decorator, but even = with this approach (pretty shitty approach I must say) there would be = problems with diff() method (if you want to use DateTime's diff, you wil= l = need to implement getDateTime method of your own DateTime class (because= = diff accepts DateTime), so you will end with mutable object again, becau= se = one can just execute $yourDate->getDateTime()->modify(*whatever you = want*)). I think it should be changed (or implemented another one, like someone = said, DateTimeImmutable) because date is atomic value.