Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12693 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87393 invoked by uid 1010); 10 Sep 2004 03:27:33 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 87279 invoked from network); 10 Sep 2004 03:27:32 -0000 Received: from unknown (HELO mail.zend.com) (80.74.107.235) by pb1.pair.com with SMTP; 10 Sep 2004 03:27:32 -0000 Received: (qmail 27028 invoked from network); 10 Sep 2004 03:27:30 -0000 Received: from localhost (HELO AndiNotebook.zend.com) (127.0.0.1) by localhost with SMTP; 10 Sep 2004 03:27:30 -0000 Message-ID: <5.1.0.14.2.20040909202648.02f67930@127.0.0.1> X-Sender: andi@127.0.0.1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Thu, 09 Sep 2004 20:27:23 -0700 To: Curt Zirzow ,internals@lists.php.net In-Reply-To: <20040910034521.GI58353@bagend.shire> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] casting php5 objects From: andi@zend.com (Andi Gutmans) References: <20040910034521.GI58353@bagend.shire> Please check the archives to see why we don't support object casts to integers/doubles. Hint: The object id is not unique. Andi At 03:45 AM 9/10/2004 +0000, Curt Zirzow wrote: >In reference to bug #29029 (http://bugs.php.net/29029): > >Current casting object behaviour: > int - not able to cast > dobule - notice thrown, returns 1.0 > null - will return null > bool - returns 1 (from result of double) > string - user __toString() if applicable or 'Object' > >Beyond the ridiculous idea of adding a __toInt(), __toDouble().. >etc. What about the idea that casting int so that it returns the >id of the object, and the double value returns the int casted as a >double value. So: > > $o1 = new stdClass(); > $o2 = new stdClass(); > $o3 = new stdClass(); > > var_dump((int) $o1); /* 1 */ > var_dump((double) $o2); /* 2.0 */ > var_dump((int) $o3); /* 3 */ > >Otherwise, I'll just move this over as a documentation problem. > > >Curt >-- >First, let me assure you that this is not one of those shady pyramid schemes >you've been hearing about. No, sir. Our model is the trapezoid! > >-- >PHP Internals - PHP Runtime Development Mailing List >To unsubscribe, visit: http://www.php.net/unsub.php