Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98443 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64081 invoked from network); 8 Mar 2017 22:24:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Mar 2017 22:24:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 209.85.218.45 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 209.85.218.45 mail-oi0-f45.google.com Received: from [209.85.218.45] ([209.85.218.45:35484] helo=mail-oi0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/7C-06022-8A480C85 for ; Wed, 08 Mar 2017 17:24:41 -0500 Received: by mail-oi0-f45.google.com with SMTP id 62so27805996oih.2 for ; Wed, 08 Mar 2017 14:24:40 -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; bh=OaJR/kVO8iG76VDngw4/x6YTDk1Q84pE9mfYSf0Kg3A=; b=SbugVvi8nCP51RGyVvCxzj8Ba3y0UH6hWFdkjgffP+qiBnjW6k69yDL26vAtQ3mtoy SxQiPeEbaauJ126iu23UYbs1O8CPr0XV8sauoEboLksxYns6GUTey2wh4juwN9xciBIz TcfgXnsEh8TJURgsE4lHnFhhRiCygcSQ1johA= 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=OaJR/kVO8iG76VDngw4/x6YTDk1Q84pE9mfYSf0Kg3A=; b=dwWbtx3crY85oWG9rOg8iET7G7HQHGIardCextW16cI3wXJWz/Sr7M8yTjhG1E4Jxs VeczEksOWPufvJvH/ha/mAYL+GQWJpyt1di/q07A/o0Je2rEiSGFczXroZNBBh9kyrij MU/EL+aBHht2cJCnsVJ8pJpGJ0ziQ2lu/t8GXWkS7R/sfYvweSVkzOXyvUNzSBZW8aIX jiskSC11InDdKZrFvYKIta+UOqk3GIGpiISR76Nw/MvPDnOyLKgHP+iSTyDrHY4kyL8W 4Vd8Op7jMrZfydFpWqkmOUkBwAhQlyiOjJ4rC3NdFFKQZrKMnE7GKSYPnxjkYbCnbcUU wL0w== X-Gm-Message-State: AMke39kBsCXf1lkXUKpVSACtDbzbuxRk/zp1BnWt0LpHh2Suor66xmpnSrs9dGbxnuv9WyEDqQI2bRGw248N5g== X-Received: by 10.202.236.140 with SMTP id k134mr4605195oih.123.1489011877784; Wed, 08 Mar 2017 14:24:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.242.83 with HTTP; Wed, 8 Mar 2017 14:24:37 -0800 (PST) In-Reply-To: References: Date: Thu, 9 Mar 2017 00:24:37 +0200 Message-ID: To: Rowan Collins Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString() From: narf@devilix.net (Andrey Andreev) Hi again, On Wed, Mar 8, 2017 at 9:39 PM, Rowan Collins wrote: > > I think it comes down to what you're trying to achieve: the language can't > have pseudo-types for every possible combination of types, so if you want to > detect integers as one case, and other things that can be converted to > string as another, just perform your checks in the right order: > > if ( is_int($foo) ) { > // ... > } elseif ( is_stringable($foo) ) { > // ... > } > This is why I was concerned about the discussion becoming too broad - it brings us (or me anyway) back to square 1, if not even out of bounds. I wanted the ability to do "string or string object" checks without multiple function calls, and now the suggested solution doesn't do that. I do agree that we can't have pseudo-types for everything, but can we at least have meaningful ones? How would "stringable" be different to "string", and what's the point of either of them if they accept every other scalar type? We're having this discussion because outside of the so called "strict mode", PHP's string type is just as meaningful as "scalar", which makes it useless IMO. Cheers, Andrey.