Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113080 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 61148 invoked from network); 4 Feb 2021 18:22:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Feb 2021 18:22:51 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D545E1804DD for ; Thu, 4 Feb 2021 10:06:37 -0800 (PST) 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.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (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 ; Thu, 4 Feb 2021 10:06:37 -0800 (PST) Received: by mail-oi1-f172.google.com with SMTP id m13so4622020oig.8 for ; Thu, 04 Feb 2021 10:06:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=a61V0BkRKe67g8wWcBWBUpnniHhsGOCYKs30qj6vOcU=; b=RqyaH9zhZvEhGjfnxwlqa8OZfLwyefFK1bWjsn35Pvj8nRClVWQvyaTFSxpCAG92/7 5nnnCVAOLZrnY0d9mTNbRJ/m6Sjeh3yxaA9ezYH9qEkBO/cwg8UF7vfO+/dcb+hpiDWo OJkWLglxtFruRZGqvc4e/+gFrZgmmd8GcKzNCtRu/cnpAqqo7Zxt5Fvum1ZgCXB61ftZ LSB/g9PyIli+AFyvAdBtE9MbzzO6KYdjEpa6m5Q2ypnppft+2eZKkJTpmfry4hduNdgk gIz+1p9L8FLPZloNiHec3byBs5bdoYGijApfiCWuoNfp6h5X/tlC6RhJSxNEbJdRw3Pp Ul7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=a61V0BkRKe67g8wWcBWBUpnniHhsGOCYKs30qj6vOcU=; b=sGoBnoiSI3XSxHVuVpI/fK6EPlXvqH4nlrcTCg49uWixpBkXeldhYVd3mPLzsgGDuu s2YeK58Ux0SPraDM53VZdXlDfRJEBuCGREdbxd6Qwnvb/yCToI8A5njP5xrBah2bTI5n VA/4I0lykCsJRASSDrHxAdzxG4OO1Io5NaGq3Z8+GRg+bD/qe6NFV3eoZ40IIBt9cJa9 uA6cJuPxuLyjRpAdaWkdBKeUP3sneH3leQH+Ts8s7P/2lGoEOrfr5s3KQIyPTNMvtXr5 SgWJfVoeIGOdh8FSt798KlhwEwBMWniExMQ03WtiJI1JuscfH/dQGWbUtzzkAXP2PMgq 0ZfQ== X-Gm-Message-State: AOAM530WMp8jAk+aEXyfDh68okvdBQrB1HHmUdr77MdiYsCBtrrdyzg2 8WLVhlYF24jizk/SB3HEu3b5D7fxM+yItBgm9SXQ6H2bH+w= X-Google-Smtp-Source: ABdhPJzOvmRm4XzgyG6Nh9Fo42bae4EzTdJgPNPSCzLwRLfcBvh8ti7vEg/r2lojBHLDv1rufMqVfIWUKifn49U3iTI= X-Received: by 2002:a54:4185:: with SMTP id 5mr483066oiy.7.1612461994606; Thu, 04 Feb 2021 10:06:34 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 4 Feb 2021 18:06:24 +0000 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="00000000000067034a05ba86907d" Subject: Re: [PHP-DEV] [RFC] Warning for implicit float to int conversions From: davidgebler@gmail.com (David Gebler) --00000000000067034a05ba86907d Content-Type: text/plain; charset="UTF-8" If this were to be done, my gut feeling is a notice would be preferable to a warning, particularly as there must be many scripts which would suddenly start churning out warnings for this proposed change which might/probably ignore lower error levels and emitting a warning for a previously common script behaviour is quite a significant backwards incompatible change. The bit which makes me more nervous about the proposed change is your rationale that implicit float to int conversion dropping the fractional portion means there is "no way to know if the data provided is erroneous". I get the idea behind your proposal, but equally I'm not convinced this is comparable to numeric vs non-numeric or malformed/partially numeric strings. There isn't any value of the string "foobar" which makes sense as an integer. But there is a value for a float which makes sense as an integer; the integral part. In the float 3.81232 the integral portion 3 is completely unambiguous. It's not like it would make just as much sense to interpret it as any other arbitrary integer value. So in these cases, via coercion you're just straightforwardly giving a valid, unambiguous integer to something which expects an integer. I'd question why should that raise a warning or TypeError. In favour of the proposal are a couple of the other issues you mentioned which mean this would make PHP a bit more consistent all-round...but I'm not entirely persuaded at this point. -Dave On Thu, Feb 4, 2021 at 4:05 PM G. P. B. wrote: > Greetings internal, > > I'm proposing a new RFC which would warn when an implicit conversion > from float to int occurs. > > The draft is currently located on GitHub: > https://github.com/Girgias/float-int-warning/ > for ease of commenting/providing changes to it. > > The official discussion phase wouldn't start before I convert it to docwiki > and > post it on the wiki, something I'm planning to do next week. > > Any feedback is appreciated. > > Best regards, > > George P. Banyard > --00000000000067034a05ba86907d--