Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28237 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28849 invoked by uid 1010); 5 Mar 2007 11:51:44 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 28834 invoked from network); 5 Mar 2007 11:51:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2007 11:51:44 -0000 Authentication-Results: pb1.pair.com header.from=rquadling@googlemail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=rquadling@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 64.233.182.185 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@googlemail.com X-Host-Fingerprint: 64.233.182.185 nf-out-0910.google.com Linux 2.4/2.6 Received: from [64.233.182.185] ([64.233.182.185:53609] helo=nf-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8C/32-16561-D440CE54 for ; Mon, 05 Mar 2007 06:51:42 -0500 Received: by nf-out-0910.google.com with SMTP id l35so2229265nfa for ; Mon, 05 Mar 2007 03:51:39 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=googlemail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=R3bOKjQqfhZc8mVwcOb3/IdIFxh/QJrecpbWepj9EqDTmGGq9tSYAFVxBAIkGPg5cku+PpecMW12T7EMzDjji4fDZepDw9QQ7zUGrsy2gT6pL1uSZWE99IQCHaswNaacbg+S1ZBik+yjxq/yewEvtahsQqC4fXkw2lfEJ1uXrFw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=beta; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=APu6T/DyuYKPyFfJ/reYE0x3fJQdUJDyxwATFqMbj6ruNVD0hSmn3jkrOH82bbNji1CUXidyrYmV4mqotftGmL089byN/uJycZWPQX7ziBdLrMlKYYHsjT9jMjPaZPWHjiWo3bSYrXWBE6w6KC6XFegMFv9mk5yy/+4JahLHe0Y= Received: by 10.78.122.11 with SMTP id u11mr607461huc.1173095496963; Mon, 05 Mar 2007 03:51:36 -0800 (PST) Received: by 10.78.48.5 with HTTP; Mon, 5 Mar 2007 03:51:36 -0800 (PST) Message-ID: <10845a340703050351l4728ad63kdee9bcc20e38a155@mail.gmail.com> Date: Mon, 5 Mar 2007 11:51:36 +0000 Reply-To: RQuadling@GoogleMail.com To: "PHP Internals" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: Subject: Re: [PHP-DEV] DateTime object equality From: rquadling@googlemail.com ("Richard Quadling") It would be interesting to know what other internal classes falsely pass this non-identity comparison. Then two new documentation entities could be used to say that non-identity comparison is or is not possible with this class. In my installation, I have 95 built in classes (with no extensions added), or 106 with the extensions I use normally. I managed to get upto 198 built in classes (by adding ALL the extensions I could get working). I suppose the step after this would be to make the built in classes operate so that non-identity comparison operated based upon the USER's perception of what should happen. On 04/03/07, Hans Lellelid wrote: > Hi all, > > DateTime equality (not identity) appears to be broken. I've created a > ticket for this issue (http://bugs.php.net/bug.php?id=40691), which > keeps getting marked as bogus by Ilia. This may be a more appropriate > issue to raise on list, as I seem to be having both a very hard time > making my point about the inconsistency of the behavior and a very hard > time being convinced that this is not a bug (at *least* a documentation > problem, if nothing else) :) > > The basic problem is that a [non-identity] comparison (==) of *any* > DateTime object with any other DateTime object will return TRUE. Now, I > admit that I know little about the underlying layer, but as a developer > the DateTime object has a very clear set of properties (namely > date/time, maybe time zone) that I would expect would be compared by a > == equality check. > > $d1 = new DateTime("2001-01-01"); > $d2 = new DateTime("2007-02-28"); > var_export($d1 == $d2); // Ouputs: TRUE > > > This always-return-TRUE behavior is extremely counter-intuitive. It > also appears to be very exceptional in the PHP core classes. > Admittedly, I haven't looked through SPL, but the Exception object > provides a perfect example for what I would expect (based on the text in > the PHP manual about object comparison): > > $a = new Exception("foo"); > $b = new Exception("bar"); > $c = new Exception("foo"); > > var_export($a == $b); // Outputs: FALSE > var_export($a == $c); // Outputs: TRUE > > Obviously stdClass and user-defined classes exhibit this same behavior > of testing the object properties -- just as I'd expect from the > description in the manual. > > Is this DateTime comparison behavior actually intended to be different > from everything else? If there's some reason that DateTime object > properties cannot be compared to each other, wouldn't it be more > appropriate for them to always return FALSE ? > > Thanks, > Hans > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"