Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67345 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85716 invoked from network); 7 May 2013 18:39:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 May 2013 18:39:45 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.180 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.180 mail-ob0-f180.google.com Received: from [209.85.214.180] ([209.85.214.180:32966] helo=mail-ob0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 40/92-06696-7F949815 for ; Tue, 07 May 2013 14:39:43 -0400 Received: by mail-ob0-f180.google.com with SMTP id uk5so895661obc.11 for ; Tue, 07 May 2013 11:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=pHbz3TrjGrWO1wOlKGM0wHDa4rSETajC2lX5Sg4k3T4=; b=kqyJC1N+rurUV1eqj/2iSW5kASC2hUPYjzCmqg81/+vZTBOgHvdInE8bTGedy+z4Nw WEkBCIUiK8gEO6KryMsshc5APcqRcpX+fqNmWKKhbItYEJ5xeMepX2sfCK7DyTLkv/in rqCC4nSNsuwRHkVRyB9Ow6FKvavKFmdO9TKi9vFBOMq4SVc088FfSDboNkqKfjOarAtj XnF8lvAHbVvE/nbEX17q5Li3PzIdX4JvFa6Hlg2wU/Pzsvk9lmIyuUWS7ieum8UwHi37 rW1DCyRlPHjyzJjAQUYqdUgouQId/9A+enck3fsSIZoS+0/gBOc9uizo6rIfo6qL+5TI kFXQ== MIME-Version: 1.0 X-Received: by 10.182.250.132 with SMTP id zc4mr920623obc.71.1367951861027; Tue, 07 May 2013 11:37:41 -0700 (PDT) Received: by 10.182.49.136 with HTTP; Tue, 7 May 2013 11:37:40 -0700 (PDT) In-Reply-To: <1367681473.95445.YahooMailNeo@web120904.mail.ne1.yahoo.com> References: <1367681473.95445.YahooMailNeo@web120904.mail.ne1.yahoo.com> Date: Tue, 7 May 2013 20:37:40 +0200 Message-ID: To: Oleku Konko Cc: "php-internals@lists.php.net" , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e01536b5cbf19a504dc251cfb Subject: Re: [PHP-DEV] Scalar Type Casting Magic Methods From: nikita.ppv@gmail.com (Nikita Popov) --089e01536b5cbf19a504dc251cfb Content-Type: text/plain; charset=ISO-8859-1 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 --089e01536b5cbf19a504dc251cfb--