Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98461 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44212 invoked from network); 9 Mar 2017 19:51:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Mar 2017 19:51:28 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.51 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.51 mail-wm0-f51.google.com Received: from [74.125.82.51] ([74.125.82.51:35253] helo=mail-wm0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9D/B1-31244-F32B1C85 for ; Thu, 09 Mar 2017 14:51:28 -0500 Received: by mail-wm0-f51.google.com with SMTP id v186so147434452wmd.0 for ; Thu, 09 Mar 2017 11:51:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=LeycIVRfrjNTI7L0zcE3qeJ0IbKJ6/BtZ8EysZmo01c=; b=olmD9hXognKNua5ZXItNlr1y0kPAPDn6WCOnwNemQYCO5ot96LXgDT9Szx9kC4z/HR DVcl5pmR5Bnd1x03FGgRGruoXTU28VISesZ9UHgmDy0VARdU7/26dnADm+4RoWRd3VeK byuVrVJ8EVNkAeCFTWYFBsKGkt3BEGQTWOB4KpakhgMvfiKq5mc01GS25Gze1xp4lBx+ 1uSca0PK3Z+x65TP9IrDQDvQAjpel90SIHE6HlsQOGcdZaHcPqiJ3bcB8AASFjkcYR/H cffsqQinKSA4oLta1ht5WsUMJLuz9FUvVop8qEYLE9fU+eUte6LNZcEp7C63GpXQ1qec 4g4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=LeycIVRfrjNTI7L0zcE3qeJ0IbKJ6/BtZ8EysZmo01c=; b=N9HAiJWX8l4XJRMRypN6xxX3FeXhlURl5rnLN8FWZTHToSgRXysGvEAPK267FCYR4F RcJODJp6dzlPpz5q+67jiFwl81BXXWbzgbhDIM8La8YjYG+jvye7Ikziv7z9QLKVaMDV HPPHcBofZXkoL4PJ7N4eoxkg2VrKtRgJ8jMCDARmn9q+3qz/3po5gulmVMY0J8FBSc3h v++bOMORBKguMQ6X1h1ehiuN13nlre4rlKxK0RGO0qvSY7jkbLiZvC8vMPxo2k83LCG5 BJcgfq8lKNFnRtCJmljYF0QFRvMv/CFpRqnj4UmafgnQK1IECvvSUSh7MsUaGE7qQffm 2AIw== X-Gm-Message-State: AMke39m9XjU7cEWRU7NKMOzEbatMwA9krdypIXXgss0XeGfQQJHWFcj/2DEWEx033zv3ow== X-Received: by 10.28.155.9 with SMTP id d9mr28570093wme.114.1489089084893; Thu, 09 Mar 2017 11:51:24 -0800 (PST) Received: from ?IPv6:2a00:23c4:4bd2:6e00:5c6c:ae0f:824f:8159? ([2a00:23c4:4bd2:6e00:5c6c:ae0f:824f:8159]) by smtp.googlemail.com with ESMTPSA id o26sm9409367wro.44.2017.03.09.11.51.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 11:51:23 -0800 (PST) To: internals@lists.php.net References: <3b1ab2d7-c572-14a7-da37-d5b7e379326e@fleshgrinder.com> Message-ID: <6ccec0fb-a2b7-8421-87d3-46bd0fa4ddc4@gmail.com> Date: Thu, 9 Mar 2017 19:51:23 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <3b1ab2d7-c572-14a7-da37-d5b7e379326e@fleshgrinder.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString() From: rowan.collins@gmail.com (Rowan Collins) On 09/03/2017 17:37, Fleshgrinder wrote: > On 3/9/2017 3:18 AM, Stanislav Malyshev wrote: > >> I don't think it's right approach. is_* functions check the current type >> of the value, not whether it can be converted to another type. If we >> need ones that express the latter, we should have different functions. >> >> Also, as already noted, having __toString doesn't mean it returns >> something useful. >> > This is not true at all: > > 1. is_dir > 2. is_executable > 3. is_file > 4. is_finite > 5. is_infinite > 6. is_link > 7. is_nan > 8. is_readable > 9. is_resource (checks the resource's type too) > 10. is_uploaded_file > 11. is_writable I think a good example is "is_callable", which evaluates not the *type* of the value, but the *possible behaviour*. You could think of Closure::fromCallable($foo) as "cast $foo to Closure", in which case is_callable($foo) is "can $foo be cast to Closure?" (at least, in it's default behaviour). This is then much more similar to defining is_stringable($foo) to return true for everything that can be cast to string. Regards, -- Rowan Collins [IMSoP]