Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110351 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 51742 invoked from network); 3 Jun 2020 13:48:10 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jun 2020 13:48:10 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 032D61804CE for ; Wed, 3 Jun 2020 05:30:21 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, MALFORMED_FREEMAIL,MISSING_HEADERS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 3 Jun 2020 05:30:20 -0700 (PDT) Received: by mail-wr1-f52.google.com with SMTP id y17so2143788wrn.11 for ; Wed, 03 Jun 2020 05:30:20 -0700 (PDT) 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:cc:from:message-id; bh=wKy+JNC+m9z1Gmpxzeu3qpIm8W53c+jR/VOCAPpB9AE=; b=JHVJiuZe6jWtqlHiMZjtmRJgMNB4zXjm9Uv/wmDrKotlShgRdUaZY+UC+xhB75/d6X XcwkEFeD1o3/8Bql/khQ/Q1uhgEN+eLXavyvk1qD3Py19ixhFXrLM8d+inedIWRqY7Bi gRXu7u3KxrSS6uBzqIrBIF8rnvnEXCHRe3aDkEJEqZuFX2NNcq+a1LqL8eN7WRCdiZaP QHLjPnm/zcuFCIihicKjooQdcV+E8o5ek3/oj0WxCgQqSQ4HtVXxrylKIB/BzxBR24G7 wntr1c28LtxqVPjLv0uckEQGg20nY0aek52MRpwtn9HGhHdlAPEXhbaap/AaOOT0mkaQ +Qpw== 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:cc:from:message-id; bh=wKy+JNC+m9z1Gmpxzeu3qpIm8W53c+jR/VOCAPpB9AE=; b=C0KzCIhKvO8XYJvRoK8VPjepGzH/Hml1+WHlB3NrL5g4bnKyQgFvn0CpenPsBenl7y 0u4/BULJzltD9/1g14DDV10KELEcfru8u2ZjhG0B8wy53x5Rqtr0Js23a0IP9WKPZcFX 9t7l5dA9vPL51huJD/tO0lZs69GpeVBF6Uqm231KibExmaTbqGhrGVysUaYxk+NVgxhF Vg3s0yZFqLDCK9ZgODRDMoW/Z3cIcPx9mPu0LZ4uHOHPOp5ojollD97+MqFT2qGu9W0R QCAPQWrM7nJWN8eBppQ2MNKFGexOhTz3ycoe4ejVmR+2O+ZGduLFfWFX8ph/e8y+BU3L sE0A== X-Gm-Message-State: AOAM531+zLC2LCcU4MDGT43Db9J8pXpZRUnrhXwXn7TvCDhA4vkegz89 /1xQPUgnGtv+EJ6IKGIfNp2QD1B/ X-Google-Smtp-Source: ABdhPJyuCD4eEKnCbQG5V1xCY6fZQR2gzf+2EzpcMSXP5Yv3+a86m+zkJyJLyjOZCqm4xJUIi6XK5A== X-Received: by 2002:adf:d851:: with SMTP id k17mr30235306wrl.30.1591187417293; Wed, 03 Jun 2020 05:30:17 -0700 (PDT) Received: from [192.168.0.12] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.gmail.com with ESMTPSA id z25sm2708903wmf.10.2020.06.03.05.30.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jun 2020 05:30:16 -0700 (PDT) Date: Wed, 03 Jun 2020 13:30:16 +0100 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 CC: PHP internals Message-ID: <69992337-7A48-4E2E-9C6E-F07897847EAF@gmail.com> Subject: Re: [PHP-DEV] Numeric Type From: rowan.collins@gmail.com (Rowan Tommins) On 3 June 2020 09:50:23 BST, Deleu wrote: > `is_numeric` has been with PHP for >so long that I don't think we would ever be able to have a `numeric` >type-hint that doesn't align with it, which imho means we either have it = or >we don't, a 3rd option where a possible type-hint that is inconsistent wi= th >the function seems worse than not having it=2E I agree, but my conclusion is that the best answer is "don't have it" - I = don't think the use cases are common enough to deserve a language feature r= ather than just using the existing function=2E >My point is that I don't look at the language validation to protect my co= de >against unexpected values and I can setup validation to deal with that=2E If it's not to protect against unexpected values, then what is it for? >What complicates things is that I want to avoid having a force-cast >which is not safe for my usage because I want to preserve `null` Yes, the combination of strict cast and nullable cast would sometimes be u= seful, although the syntax might get messy - (int?!)$foo looks horrible=2E Since we already have ?int though, this doesn't seem a strong reason to ad= d ?numeric meaning almost the same thing=2E > while not having to disable strict_types It feels a bit like you want to "have your cake and eat it" here - if you = want a loose check and aren't worried about a few unusual values getting th= rough, why are you running in strict_types mode in the first place? Regards, --=20 Rowan Tommins [IMSoP]