Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67369 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67587 invoked from network); 8 May 2013 05:38:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 May 2013 05:38:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre@pcservice.co.za; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre@pcservice.co.za; sender-id=pass Received-SPF: pass (pb1.pair.com: domain pcservice.co.za designates 67.18.137.84 as permitted sender) X-PHP-List-Original-Sender: pierre@pcservice.co.za X-Host-Fingerprint: 67.18.137.84 gateway12.websitewelcome.com Linux 2.6 Received: from [67.18.137.84] ([67.18.137.84:44628] helo=gateway12.websitewelcome.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9D/21-06696-AB4E9815 for ; Wed, 08 May 2013 01:38:05 -0400 Received: by gateway12.websitewelcome.com (Postfix, from userid 5007) id 52410EE4E7186; Wed, 8 May 2013 00:38:00 -0500 (CDT) Received: from vinacomin.websitewelcome.com (vinacomin.websitewelcome.com [50.97.101.199]) by gateway12.websitewelcome.com (Postfix) with ESMTP id 42C47EE4E7162 for ; Wed, 8 May 2013 00:38:00 -0500 (CDT) Received: from [209.85.128.45] (port=38003 helo=mail-qe0-f45.google.com) by vinacomin.websitewelcome.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.80) (envelope-from ) id 1UZx4i-0007in-4B; Wed, 08 May 2013 00:38:00 -0500 Received: by mail-qe0-f45.google.com with SMTP id a11so861988qen.32 for ; Tue, 07 May 2013 22:37:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:reply-to:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=l2+EiJhGQZI+x99PW37Ok3bcKtlWluu7lFcFSxBqn/E=; b=Up/rwnbaAcvUco0CL3XKCSCR2icHH18AWgwWiWs0vwk9Qq2P2A3JJqgsMwfWedkxl2 H2oee2Lb2xcsHxhTTWWAON5xpbkYo/TjXFq6o7nSW1eEDzTrQ17hHhu+5nw1FmCuGRyL zhA7bTthz7UsFDKU8gRloFRQQ3rw/YjKN2tv+RKOD3Lx5ARDbjX/8iqmmH2PX4/v8PV1 Kcw/rrABzZyZcQ4mUadINCbPQMgxKqihcPPMFaad6fazvtu9Qrpu6ERHPPAVp7sjw4ao IYcT2AOoKfSqVV77XFF3kgjcKOiJuW3TEU3Spk+vnfogYuHEEeZ2jcHS7+rEw3kvI/Mz bntA== MIME-Version: 1.0 X-Received: by 10.224.203.194 with SMTP id fj2mr3847303qab.35.1367991479293; Tue, 07 May 2013 22:37:59 -0700 (PDT) Reply-To: pierre@pcservice.co.za Received: by 10.49.131.161 with HTTP; Tue, 7 May 2013 22:37:59 -0700 (PDT) Received: by 10.49.131.161 with HTTP; Tue, 7 May 2013 22:37:59 -0700 (PDT) In-Reply-To: References: <1367681473.95445.YahooMailNeo@web120904.mail.ne1.yahoo.com> Date: Wed, 8 May 2013 07:37:59 +0200 Message-ID: To: Nikita Popov Cc: PHP Development , Oleku Konko , "php-internals@lists.php.net" Content-Type: multipart/alternative; boundary=20cf300512be2e1def04dc2e56e6 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vinacomin.websitewelcome.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - pcservice.co.za X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (mail-qe0-f45.google.com) [209.85.128.45]:38003 X-Source-Auth: pierre@pcservice.co.za X-Email-Count: 3 X-Source-Cap: cGNzZXJ2aWM7cGllcnJlO3ZpbmFjb21pbi53ZWJzaXRld2VsY29tZS5jb20= Subject: Re: [PHP-DEV] Scalar Type Casting Magic Methods From: pierre@pcservice.co.za (Pierre du Plessis) --20cf300512be2e1def04dc2e56e6 Content-Type: text/plain; charset=ISO-8859-1 The __toArray can be useful if you want to perform array functions on the object (E.G array_filter), otherwise I think it would be very useful if the array functions can accept an object implementing ArrayAccess as well instead of just an array On May 7, 2013 8:40 PM, "Nikita Popov" wrote: > On Sat, May 4, 2013 at 5:31 PM, Oleku Konko wrote: > > > Quick Observations : > > > > I had this issue ( > > http://stackoverflow.com/questions/16375331/increment-on-tostring ) and > > it kept me thinking why no error was returned, then i stumble up this > RFC : > > https://wiki.php.net/rfc/object_cast_to_types > > > > The patch is basic , simple and working and it should > > be seriously considered in 5.5. I want to believe if > > https://github.com/php/php-src/pull/334 can make it to PHP 5.5 then we > > should give object_cast_to_types the same opportunity except they are > > string objections why it should not be so > > > > I don't think that this would be particularly useful and as such I don't > think we need it. The idea of doing some meaningful operation when writing > $obj + 1 is nice, but only if you have actual operator overloading and can > compute the result of that expression yourself. If you don't have this > possibility and only get to cast $a to an integer/float, then the whole > thing becomes rather useless. The only thing it could be used for are thin > wrappers around integers/floats and I don't see why one would want to do > such a thing (especially as you get back a number and *not* a wrapper > object). > > Thus, __toScalar(), __toInt(), __toFloat() seem pretty useless. The only > thing that might have some merit is __toArray(). But there again, I'm not > really sure what it gives us. After all we already have Traversable and > ArrayAccess, so we can already make an object behave pretty much like an > array. > > Nikita > --20cf300512be2e1def04dc2e56e6--