Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98445 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66544 invoked from network); 8 Mar 2017 22:42:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Mar 2017 22:42:38 -0000 Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 74.125.82.170 mail-ot0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:36169] helo=mail-ot0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5B/EC-06022-ED880C85 for ; Wed, 08 Mar 2017 17:42:38 -0500 Received: by mail-ot0-f170.google.com with SMTP id i1so45231750ota.3 for ; Wed, 08 Mar 2017 14:42:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=mFMfwIIpO3Ht9gfVlmQl0uKEAHYSklTTKGbhe2MfRJ0=; b=m5Ie4JV7TLEjU4wH45KmlyO3sH7DnpJkEL3FRi/UAxiPxVY1d6A/JLn8W5TG8+hY1i rQaj7yvLyxSZfw7zl5jr7g4jxL28IhRBaaZ4VAvim8A58XY0Crg6I6MFyCw+4ZQEfaL9 SwtzdRKtMG1vhCZ/FP757RXK+gTKsPge6OnmI= 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:content-transfer-encoding; bh=mFMfwIIpO3Ht9gfVlmQl0uKEAHYSklTTKGbhe2MfRJ0=; b=s5sSBc8L3XC1ty53z7K8+SJwZr0ISopNE+ilcJ6GK32/B93vUQARJBGGbqeoS4v3T2 3dbMhBMKeZDISsyMT36V/4ZPb7g0TDTSM6x0mgtA7RgWZeRF3LKL22hCkjFjOR01u1BH heZCC6Sob+qChXW+IJS8PicKvwUWsGQ5ASHeYkrSCLF7LMdKFq8Uk6g0m3TDaQa3Z/ud D6f9xfx2rImoFffPks48G7R5ShDY4pAKtU8WRvOMVvpi8+60BOR7H69aQrzw4WRkO2Td MYMWvqg6wMsUvrAWb5kLkDb9NKV+WiHPicuA2bgWDaHWOWmulohzYrQhUa2JFwxBKfq1 y4Kw== X-Gm-Message-State: AMke39kGmQFYzjfliHi1V4ZY0H9D89M1aXUAspoXVYMkdW7l4TXs2w+oOYLJahpsVaO+aur2sauZW6JmFVc23g== X-Received: by 10.157.27.154 with SMTP id z26mr5558744otd.181.1489012955309; Wed, 08 Mar 2017 14:42:35 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.242.83 with HTTP; Wed, 8 Mar 2017 14:42:34 -0800 (PST) In-Reply-To: <9E.4A.06022.A0150C85@pb1.pair.com> References: <8B230568-9074-4928-B9C9-F1F138054CD7@gmail.com> <89.A9.06022.54F40C85@pb1.pair.com> <9E.4A.06022.A0150C85@pb1.pair.com> Date: Thu, 9 Mar 2017 00:42:34 +0200 Message-ID: To: Andrea Faulds Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [Discussion] is_string(), string type andobjectsimplementing __toString() From: narf@devilix.net (Andrey Andreev) Hi Andrea, On Wed, Mar 8, 2017 at 8:44 PM, Andrea Faulds wrote: > Fleshgrinder wrote: >> >> On 3/8/2017 7:36 PM, Andrea Faulds wrote: >>> >>> Hi, >>> >>> Andrey Andreev wrote: >>>> >>>> The question is rather "is this value a string?", only with the added >>>> assumption that __toString() objects are treated as "string objects" >>>> and thus fulfill the condition (another reason why I went for an >>>> is_string() parameter). >>> >>> >>> This is a faulty assumption. The presence of __toString() doesn't mean >>> the object is a string, or intended to be used like one. >>> >> >> What is it then in your book? >> > > It means the object can be converted to a string. But such a conversion m= ay > entail a loss of information and not be equivalent to the object itself. = It > might be a =E2=80=9Chuman-readable=E2=80=9D form, for instance. > There will be loss of information most of the time, indeed. That's not the point; broadly speaking, you'd have to alias __toString() to serialize() in order to avoid that. If it has an explicitly declared string representation, I want to have the option to use that easily, without writing boilerplate code to filter-out every other type. Cheers, Andrey.