Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98425 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20911 invoked from network); 8 Mar 2017 14:29:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Mar 2017 14:29:45 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.68 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.68 mail-wm0-f68.google.com Received: from [74.125.82.68] ([74.125.82.68:35299] helo=mail-wm0-f68.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0B/65-06022-95510C85 for ; Wed, 08 Mar 2017 09:29:45 -0500 Received: by mail-wm0-f68.google.com with SMTP id z63so6349340wmg.2 for ; Wed, 08 Mar 2017 06:29:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:from:message-id; bh=eEbl5xOJFWP3/xrOq4zGGMSrOLDPzJLQc8I/ufLwUik=; b=Im9N8boLeNt9xWCnYa8Gha8R6VeCz7q3C3xsBUi5ZXZ9OjubX85NFF0n2qN9vppJTX 0RF0twkRxdcpA0tcOrXfEXRj2EtEps/qQVEkwttm9lGq3Quqp7jjmDITKDa2rGd7AvJQ X+FVg1ENP0N8c6NsbA1MZDdx2BWHJVQcfFXRoCNEECzepZJ7KudSgRIGhjL++qjwa4aU SVMIJJjx2Yk5lZ2OcuHBA6Vhtn74CkltGNyrR4DVgwBNdvbF3TkkJXadu7feVqUe1ys2 9H0WNqPa0T9DPflzflSNObPYnF+tykjAdit5fZoLV5gP2N5zEE4LYdJrG239laJRVxMd gOow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:from:message-id; bh=eEbl5xOJFWP3/xrOq4zGGMSrOLDPzJLQc8I/ufLwUik=; b=S1fIsf/HnxJ0eP2ludEGk05ENlUZIzkmB1H7m0cDVZlT0n8BopvtOUpaVJ7T3KhAI6 H/jqCZqspAUvDcSdbe8iuSiBttZXME0ZzgmSq/SxGPIhc3Sy/KaLEVaPqmdp71k07hsK qO79VjlfShzEiVy7zl4vdYU8pRgHsGTQLTyF2yYhXB/KWb6vVPB7Mg0zauAyIpFrxZNb F1A2ezrnfNQ5tZOi+j5e37VpJUvHIn3uhGsGVA/K19UhJ4av9+Q1IRqpd7T80G/pNg27 iUgttCinnSpRkCGvOha8ydbRFc5yqQCF8tmCyk9cVrcg3JqpfJSk8ogZcIRCCxy42tyE Jrrg== X-Gm-Message-State: AMke39m/yRQAq+sAT5OZ9GuUet3/KZRZBwKMDnbX0Sy3CSVUnYBtYBoffRP5CIIMulZQeg== X-Received: by 10.28.227.213 with SMTP id a204mr5515010wmh.120.1488983382629; Wed, 08 Mar 2017 06:29:42 -0800 (PST) Received: from [10.92.58.125] (94.197.120.56.threembb.co.uk. [94.197.120.56]) by smtp.gmail.com with ESMTPSA id x18sm22122855wmd.14.2017.03.08.06.29.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Mar 2017 06:29:41 -0800 (PST) Date: Wed, 08 Mar 2017 14:29:37 +0000 User-Agent: K-9 Mail for Android In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: internals@lists.php.net,Andrey Andreev Message-ID: <8B230568-9074-4928-B9C9-F1F138054CD7@gmail.com> Subject: Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString() From: rowan.collins@gmail.com (Rowan Collins) Hi Andrey, I think this is an interesting area to explore, but do think the scope nee= ds to be widened slightly=2E On 8 March 2017 12:25:54 GMT+00:00, Andrey Andreev wr= ote: >I ultimately wouldn't care if it's a separate function and did in fact >think of an is_stringable() function, but wasn't happy with the naming >- who's to say that e=2Eg=2E integers aren't stringable? Bar >horribly-verbose names like >"string_or_objects_implementing__toString", I don't think there's a >way to avoid that ambiguity=2E :/ >If we want a "stringable" type though Sometimes, the fact that you can't think of a good name for a function is = a clue that the function isn't solving a well-defined problem=2E In this case, why *wouldn't* the function return true for integers? If the= question the function is asking is "can this value be cast to string?" the= n the answer for any integer should be "yes"=2E If the question is "will it= pass a strict type check as a string", then the answer for objects would a= lways be "no"=2E Am I missing a situation where casting an object would be = safe, but casting an integer wouldn't? My own thought, mentioned somewhere in the long debate about scalar type h= ints, was to have a "can be cast to" function, which basically predicts if = a *weak* type hint would accept the value without errors or warnings=2E Thi= s would work for stringable objects, but also for numeric strings, etc=2E Regards, --=20 Rowan Collins [IMSoP]