Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98462 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45687 invoked from network); 9 Mar 2017 19:55:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Mar 2017 19:55:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 77.244.243.86 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.86 mx105.easyname.com Received: from [77.244.243.86] ([77.244.243.86:37365] helo=mx105.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/12-31244-A43B1C85 for ; Thu, 09 Mar 2017 14:55:54 -0500 Received: from cable-81-173-135-7.netcologne.de ([81.173.135.7] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1cm4A9-0007rm-BH; Thu, 09 Mar 2017 19:55:51 +0000 Reply-To: internals@lists.php.net References: <3b1ab2d7-c572-14a7-da37-d5b7e379326e@fleshgrinder.com> <6ccec0fb-a2b7-8421-87d3-46bd0fa4ddc4@gmail.com> To: Rowan Collins , internals@lists.php.net Message-ID: <1374265b-b874-7b8f-abdb-e5e5c5f1061e@fleshgrinder.com> Date: Thu, 9 Mar 2017 20:55:46 +0100 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: <6ccec0fb-a2b7-8421-87d3-46bd0fa4ddc4@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-DNSBL-PBLSPAMHAUS: YES Subject: Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString() From: php@fleshgrinder.com (Fleshgrinder) On 3/9/2017 8:51 PM, Rowan Collins wrote: > 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, > I also forgot about is_numeric which checks the content of a string. ;) -- Richard "Fleshgrinder" Fussenegger