Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105168 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 1483 invoked from network); 9 Apr 2019 14:00:14 -0000 Received: from unknown (HELO xdebug.org) (82.113.146.227) by pb1.pair.com with SMTP; 9 Apr 2019 14:00:14 -0000 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id A76C210C5CD; Tue, 9 Apr 2019 11:57:05 +0100 (BST) Date: Tue, 9 Apr 2019 11:57:05 +0100 (BST) X-X-Sender: derick@singlemalt.home.derickrethans.nl To: Nikita Popov cc: Andrea Faulds , PHP internals In-Reply-To: Message-ID: References: <40683e93-f8e9-5a8c-9646-31c73c99396f@fischer.name> <5ca53eb4.1c69fb81.e223b.922eSMTPIN_ADDED_MISSING@mx.google.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1827521720-1554807425=:11325" Subject: Re: [PHP-DEV] [RFC] Permit trailing whitespace in numeric strings From: derick@php.net (Derick Rethans) --8323329-1827521720-1554807425=:11325 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Tue, 9 Apr 2019, Nikita Popov wrote: > On Thu, Apr 4, 2019 at 1:16 AM Andrea Faulds wrote: >=20 > > I'm kinda unsure how to go forward because of these points. I would lik= e > > to see improved comparisons, and I would like to see the end of the > > =E2=80=9Cnon-well-formed=E2=80=9D numeric string, and I think this whit= espace RFC could > > be helpful to both. But I can't see the future, I don't know whether > > people will vote for removing leading or permitting traiing whitespace > > and whether or not they will be influenced by or this will influence > > opinion on the further improvements. =C2=AF\_(=E3=83=84)_/=C2=AF > > > > I'm torn between: > > > > * Vote on allowing trailing whitespace > > * Vote on disallowing leading whitespace > > * Vote on which of those two approaches to go for > > * Trying to bundle everything together and voting on it as a package. > > > > I'm probably thinking too strategically. > > >=20 > Given the response on the mailing list (and also other places like Reddit= ), > it seems like people feel pretty strongly that it's better to drop suppor= t > for leading whitespace than add support for trailing whitespace. If we do > this, I think we should couple this change with the removal of "non > well-formed numeric strings", because they are so closely related (one > change would forbid leading whitespace and the other trailing characters)= =2E >=20 > One possible course of action would be: >=20 > a) In PHP 7.4 throw a deprecation warning in is_numeric_string if there i= s > leading whitespace (always). > b) In PHP 7.4 throw a deprecation warning in is_numeric_string if there a= re > trailing characters in mode 1 (mode -1 already throws a notice and 0 > already treats as non-numeric). > b) In PHP 8.0 treat leading whitespace as non-numeric (always). > c) In PHP 8.0 treat trailing characters as non-numeric (always), and > remove the non well-formed distinction (mode -1). >=20 > Notably this also affects (int) behavior in that (int) " 42" will be 0 > and (int) "42xyz" will be 0. >=20 > A less aggressive alternative would be: >=20 > a) In PHP 7.4 throw a deprecation warning in is_numeric_string if there i= s > leading whitespace (unless mode is 1). > b) In PHP 8.0 treat leading whitespace as non-numeric (unless mode is 1). > c) In PHP 8.0 treat leading characters as non-numeric (unless mode is 1). > Remove non well-formed distinction (mode -1). >=20 > This would keep the behavior of (int) as-is and only affect implement > numeric string checks. >=20 > This discussion how mostly been around the implicit cases, what do people > think about the desired behavior of (int)? I think there should be no difference in behaviour between implicit and=20 explicit cases. cheers, Derick --=20 https://derickrethans.nl | https://xdebug.org | https://dram.io Like Xdebug? Consider a donation: https://xdebug.org/donate.php, or become my Patron: https://www.patreon.com/derickr twitter: @derickr and @xdebug --8323329-1827521720-1554807425=:11325--