Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98433 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37489 invoked from network); 8 Mar 2017 16:50:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Mar 2017 16:50:12 -0000 Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.44 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 209.85.218.44 mail-oi0-f44.google.com Received: from [209.85.218.44] ([209.85.218.44:36614] helo=mail-oi0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E0/68-06022-34630C85 for ; Wed, 08 Mar 2017 11:50:12 -0500 Received: by mail-oi0-f44.google.com with SMTP id 126so22228388oig.3 for ; Wed, 08 Mar 2017 08:50:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=A0xHaW+Bj3t6CNjLQWARY/q0KBAqcJ83zioLq3/SfJU=; b=ApWqt8/6XnqJKiNbv6HW7RUU7otjHqw+0/CQCMNrrnFKcwxDO9kSx6L4ZnRZ6Nd911 rGM1T+TMwHe8pBlcPLcpBVXxFqsaIArtS7sfyk/S5gx5JBkyP3GKzSP9kW7RoP0LfBce OyXveyIuVT0Xrutj5KpAMF8gmbg9DngmRp0S8dY0iVqf8gxWZiQUKkX8NO7ie/LBAy8n YQDhiNzssCGu7mp3ECkiuKpncVvo8CssJ+uFq5AngAIKVB4kq9rC05a3u9XYJMrROZ3Q 5TcSVQSztxxdo/2jcfJovx1K+mpVcEOzRuNUMFwIDF6uuZs+4KH+07v2NPqPNKEOAvcX eVXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=A0xHaW+Bj3t6CNjLQWARY/q0KBAqcJ83zioLq3/SfJU=; b=H5ExcOqHXsjOo1dfLfHDTAzJ0INoCZ1QHpkXzTDRsNif23K+x20CLb88fRNCK+Ux4Y S0DgXD3/G+w1ZZ8Vrqx6ueEAen91aPNx7ApO0LGCv/yTXzoO6MZaFu9o59z6cFfYgWpL 7Z95oSITvmeCWgpk2b0njVWQrpJ0WLTEnNT+huO8dV9gAWciQAseENNF7hL8WNaPxZuJ Lroo83eoy0w47oiJe+apv0r81zAs1u9LC/Ck1dODnmfXOTG3d7CFl6EAeGD6dBZhfMFw v/cYKQidsA4H7NlQdtxgxXdWJMZY88ow9R4YElX502FSFthaF52BT2HZ4HASKkkz3qjo r60g== X-Gm-Message-State: AMke39nACQ2MRVX48zWQ0+13rGto9CHiF3gt1aqfioRqqNkkCZKqoDEXDw4vijcZmgeb71tuRSuqinz1I8rLFQ== X-Received: by 10.202.73.84 with SMTP id w81mr4406144oia.100.1488991808635; Wed, 08 Mar 2017 08:50:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.11.227 with HTTP; Wed, 8 Mar 2017 08:50:08 -0800 (PST) In-Reply-To: <996dc359-cbc1-1c76-dacc-f748d0941aa6@fleshgrinder.com> References: <996dc359-cbc1-1c76-dacc-f748d0941aa6@fleshgrinder.com> Date: Wed, 8 Mar 2017 09:50:08 -0700 Message-ID: To: "internals@lists.php.net" Cc: Andrey Andreev Content-Type: multipart/alternative; boundary=001a113db09ad3cbc2054a3aeb07 Subject: Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString() From: derokorian@gmail.com (Ryan Pallas) --001a113db09ad3cbc2054a3aeb07 Content-Type: text/plain; charset=UTF-8 On Wed, Mar 8, 2017 at 8:51 AM, Fleshgrinder wrote: > Hey! :) > > The reference is actually not a problem for a Stringable because you > would get the "Only variables can be passed by reference" error with an > object if `strict_types` is enabled. > > Simply because the object **MUST** be converted into a string. The > object itself does not satisfy the constraint, but the object clearly > states that it can be converted into a string at any point. > This is the part I disagree with. The object clearly states that it can be turned into a string when you are done using it as a object. If it gets turned into a string, you can no longer use it as a object. There is a difference between changing an int to string and an object to string, in that afterwards the int->string can continue to be treated as an int afterwards, thanks to loose typing (otherwise it wouldn't have become a string in the first place). However with an object->string afterwards it can ONLY be treated as a string, it can no longer be treated as an object. Meaning $int = 3; foo(3); var_dump(++$int); // 4, success, no errors $obj = new Foo('a'); foo($obj); var_dump($obj->method()); // Fatal error: call to member function method on string. To me, this doesn't make sense. > > Not doing so would violate what `strict_types` actually promise us. ;) > > -- > Richard "Fleshgrinder" Fussenegger > --001a113db09ad3cbc2054a3aeb07--