Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63795 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63039 invoked from network); 9 Nov 2012 13:52:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Nov 2012 13:52:44 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.170 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.210.170 mail-ia0-f170.google.com Received: from [209.85.210.170] ([209.85.210.170:64848] helo=mail-ia0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B3/60-60301-AAA0D905 for ; Fri, 09 Nov 2012 08:52:43 -0500 Received: by mail-ia0-f170.google.com with SMTP id e16so3139984iaa.29 for ; Fri, 09 Nov 2012 05:52:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/mIrZjANfkcjSXfmpt3Fhw9+ctE9mw9D232JPSHjDGw=; b=dNUI8DkkSmK7IHuNjRatA7IU2F1CecYQnR64aLdMHR+cGONDSnGN4+JgJKzVQNItJ7 KQvdiMAbGFeN2KM3WUDu+SjCbOBNrqhsXb9UCTOLS7bfZJaM1g5dfZu9yPSjeO+FbFTJ C9hZuVAC0+l1GYNiQvWDKc39CPXoWB4LnoLMo8YVT9rWmr/0yOC+jIKvN85P5BuN4Wgi ssHDlJ9toME22ggrkfKrNVAGHZBvQ/6WZ2UorP7E1mThr8cTk82AXfQrANTtJNNGsNyu H6RIYrUqM97mqeLLW6En8P9nmaSMPwNgzbxbpR2R6r663uXITrLGGw+BHbHS52pnngZh 2sgA== MIME-Version: 1.0 Received: by 10.50.157.162 with SMTP id wn2mr1378468igb.27.1352469159514; Fri, 09 Nov 2012 05:52:39 -0800 (PST) Received: by 10.64.33.143 with HTTP; Fri, 9 Nov 2012 05:52:39 -0800 (PST) In-Reply-To: References: Date: Fri, 9 Nov 2012 14:52:39 +0100 Message-ID: To: Sara Golemon Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Object comparison From: pierre.php@gmail.com (Pierre Joye) hi! On Fri, Nov 9, 2012 at 1:07 AM, Sara Golemon wrote: > From: http://php.net/manual/en/language.operators.comparison.php > > An object compared to anything which is not a bool, null, or object > should result in the object appearing to be greater than the other > operand. For example: > > $a = new stdClass(); > $b = new stdClass(); > > var_dump(null < $a); > var_dump(false < $a); > var_dump(true == $a); > var_dump($a == $b); > var_dump(0 < $a); > var_dump(1 < $a); // false > var_dump(2 < $a); // false > var_dump("foo" < $a); > var_dump("2" < $a); > var_dump(tmpfile() < $a); > > Based on docs, I expect all nine of these to yield true, however in > practice, the two marked "false" come out as false because the RHS > object is converted to an integer (1), contrary to the docs. > > Doc bug? Or code bug? I'm inclined to call it a code bug, but wanted > others' thoughts. As stated by other before, comparing scalars and objects sound wrong in the 1st place. But I have seen way too many weird codes relying on weird things :). That's why I would not be in favor of changing anything in this area as some code out there may rely on that (have the feeling that object comparison has been like that since 5.0). Cheers, -- Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org