Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63794 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60534 invoked from network); 9 Nov 2012 13:27:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Nov 2012 13:27:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=sebastian.krebs.berlin@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.170 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 209.85.215.170 mail-ea0-f170.google.com Received: from [209.85.215.170] ([209.85.215.170:34918] helo=mail-ea0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 42/00-60301-BC40D905 for ; Fri, 09 Nov 2012 08:27:39 -0500 Received: by mail-ea0-f170.google.com with SMTP id a13so1592808eaa.29 for ; Fri, 09 Nov 2012 05:27:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:x-google-sender-delegation:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type; bh=oiid10f4J5xO6rydMsEuR1aO3SrG32vackzy9UuPv+k=; b=gJw/CchBCoih0YBh2ihuSNC98UZqCcEg1psCuja2hfBo5oFulpKryR29+nYDtnWHOO fv6rjUdLRJkElsj7y7NCUfRCsFZIMCKgWOgla3fGqUCoz//MR9a8foQl4ECrG4fnU8ds KSMVs4lOe3h5/vHEPbSWVW9hgpuXqr3f6VyTvQ1c6fE+Ss4zEgxUHS5PFAu8Q4P0DjLM uxyPq8kUfWoSuP4RYTfRPbjKMIIafZcYYaoX8WNPxckYqe8FhxoGAwwYaHJ3Pi+8fMYy Rno3GNoC8IGSYDp0tUnIuifLNbVI1Uc6r2eeMK9ORMiFttd3+zeoU6A1IIQR1bE0rjd0 ftag== MIME-Version: 1.0 Received: by 10.14.182.9 with SMTP id n9mr37794471eem.24.1352467656264; Fri, 09 Nov 2012 05:27:36 -0800 (PST) Sender: sebastian.krebs.berlin@gmail.com X-Google-Sender-Delegation: sebastian.krebs.berlin@gmail.com Received: by 10.14.207.67 with HTTP; Fri, 9 Nov 2012 05:27:36 -0800 (PST) In-Reply-To: <4ED7146272E04A47B986ED49E771E347BB1318FD7E@Ikarus.ameusgmbh.intern> References: <4ED7146272E04A47B986ED49E771E347BB1318FD7E@Ikarus.ameusgmbh.intern> Date: Fri, 9 Nov 2012 14:27:36 +0100 X-Google-Sender-Auth: Q0jKJ68hy1m8UnfgA_oprAwMlEk Message-ID: To: PHP internals list Content-Type: multipart/alternative; boundary=047d7b34388438ce1604ce0fea7a Subject: Re: [PHP-DEV] Object comparison From: krebs.seb@gmail.com (Sebastian Krebs) --047d7b34388438ce1604ce0fea7a Content-Type: text/plain; charset=ISO-8859-1 Hi, Maybe it goes way to far, but there is a PECL-extension [1], that allows to overload every(?) operator. However, it seems to be unmaintained for 6 years now and will probably not work anymore, but it may be usable as a starting point. Python provides this too [2] Regards, Sebastian [1] http://pecl.php.net/package/operator [2] http://docs.python.org/2/reference/datamodel.html#special-method-names 2012/11/9 Christian Stoller > I would like to place a suggestion for comparing objects (I hope it is no > problem, because this does not have anything to do with Sara's question - > but it came to my mind when I read her mail). It would be a great feature > if objects could be compared to other objects with ">", "<" and the other > operators, like it is suggested in RFC https://wiki.php.net/rfc/comparable > The DateTime class offers this feature - it would be nice if this could be > made usable for userland classes/objects, too. > > Best regards > > Christian Stoller > > > -----Original Message----- > From: php@golemon.com [mailto:php@golemon.com] On Behalf Of Sara Golemon > Sent: Friday, November 09, 2012 1:07 AM > To: PHP internals > Subject: [PHP-DEV] Object comparison > > 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. > > -Sara > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- github.com/KingCrunch --047d7b34388438ce1604ce0fea7a--