Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98439 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50651 invoked from network); 8 Mar 2017 18:50:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Mar 2017 18:50:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.179 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.128.179 mail-wr0-f179.google.com Received: from [209.85.128.179] ([209.85.128.179:35883] helo=mail-wr0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5C/AA-06022-36250C85 for ; Wed, 08 Mar 2017 13:50:12 -0500 Received: by mail-wr0-f179.google.com with SMTP id u108so29758291wrb.3 for ; Wed, 08 Mar 2017 10: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=tNc8Jz3IOXjNWrjl9VDSzgMi2BM8qLDYkDs6wZAlmvQ=; b=TxV3cOXe+VUdaLt306+MzayNUsdoOabwPIwTpXTgPQ6YwI6JvgoDWamTQcPbwQn4df j/qHgaGtXSU5k5YSzPOmbfKBm78ZOCq+o9vqCvqt9ZLTePQJIbMPzvC7NHrS+mYkz9FG 2iykEKuvpqjYhMfJTzB0nveZ2qqJj9UKopgAZgguoqLiWc4fOUztpQWy+YHbmo4ih4iy IsKy8VYqy6gvX5krZTF5Bb0UobrYjJJS/XZMM5NUzwB72xiWO7A97f7Uhl0HXO9ovJth ZiNi4EOgU8vFckcTCHyK2W39ywebYWLUaVhf5qbd98O+r9uC3r4If/muC024IK51v8QJ SRIg== 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=tNc8Jz3IOXjNWrjl9VDSzgMi2BM8qLDYkDs6wZAlmvQ=; b=NhHEp0Q7bNtbFlEgWeJotcOpRudWK0lETjhsHioS+St94i2pfMSksxol2RyH3L9Cmo bswosGX/VjlyWVrKXYYg+/Ai4mrOS8US1ddMnV8UX/JOGsRdgNhXabnz/cYjiUHlpO7b Vfix9aNmB31V/VK6NQ3/T5aKH5k3IbTXi1wq9+IsgHxNrqr6J1M9NrT27UjszXXcfjQp XVpK4aeOCQDMgPl4k3qhXeLaldrASMB33g0o2xJ3r1qbOerskb8IXlga1nn8s+nvYXk7 KQmExay8mAvZDAumpuQl/zkkXOvU9anWO+D0MtRjEwukvieJSO/ybRJGCEGdfrZ8S5cl IzVA== X-Gm-Message-State: AMke39mkGNClTWpL1BgB8YX8cU4Vsha6B/9fSoo/YthPQ01+4B9Hnmv4EyC3tHez2aqlj5eTiQtDlgSk7j17ow== X-Received: by 10.223.176.143 with SMTP id i15mr7146321wra.136.1488999008348; Wed, 08 Mar 2017 10:50:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.170.216 with HTTP; Wed, 8 Mar 2017 10:50:07 -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: Wed, 8 Mar 2017 19:50:07 +0100 Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: multipart/alternative; boundary=001a1141b6a0f6ae50054a3c9833 Subject: Re: [PHP-DEV] [Discussion] is_string(), string type andobjectsimplementing __toString() From: nikita.ppv@gmail.com (Nikita Popov) --001a1141b6a0f6ae50054a3c9833 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, Mar 8, 2017 at 7: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 > may 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= . > To give an example: Exceptions implement __toString(), which contains the exception message, location information and backtrace. Of course, exceptions are rather different from strings and treating an exceptions as a string is usually incorrect. Nikita --001a1141b6a0f6ae50054a3c9833--