Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91083 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10973 invoked from network); 5 Feb 2016 12:08:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2016 12:08:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=mike.php.net@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=mike.php.net@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.51 as permitted sender) X-PHP-List-Original-Sender: mike.php.net@gmail.com X-Host-Fingerprint: 74.125.82.51 mail-wm0-f51.google.com Received: from [74.125.82.51] ([74.125.82.51:37978] helo=mail-wm0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B8/50-07203-EC094B65 for ; Fri, 05 Feb 2016 07:08:47 -0500 Received: by mail-wm0-f51.google.com with SMTP id p63so24130410wmp.1 for ; Fri, 05 Feb 2016 04:08:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=RA2TZ2ai0U8h7YVrV1lu0qT7+rnwXhP+EsHcwwV4t5w=; b=JlGfkPniTfDizUrSjhaOtyB4vPTaQBnmN8zRNLbzB2jQyTChlmU6Qsz+NkxF5X04Uy +hCcXuhMT0S786B1l9cbIpbputNzWqks1kDS7Z7ejGvd6w0tRfcASsVUlzWTl4WQO4Sr Rzn04G/UiBGgsoX0RH1o2vxu6RlS9/Ti6tZqAOZJ90cVfkPU/oOh591Ci8+YpWogElrh KTMZW7mwFFG3k3VTfH3sEYRiAcge2Asa1/pkgFgnyltbGehCFrJe0EhQcY+4Rq4BgBmw Do16MQNwFex84f/jJJQ3qFahXKkWy/qfcgzsuor0OoCHNAfHXwLh6rwRG0i7xw6PPABT kwXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:content-type:mime-version:subject:from :in-reply-to:date:cc:message-id:references:to; bh=RA2TZ2ai0U8h7YVrV1lu0qT7+rnwXhP+EsHcwwV4t5w=; b=GAHiN7KF0V0lqpExirWVBWHBCCo4wVy3Hyb2P+CYBvyn2OgGJrVKUEKnQsN2ff//i9 0y1ls8A1Z3QNAlO/SO7ThCrRcRgEL1lARMbb4vorQKdUjuIXGTS7ngoFGw+wdPZnBt6P RMh1uUdjJ10pAGutRtI1W5RLFL+SZZGTQXNuvx8ZrlIOVBmlg7j4tbprSfQVB4XnV4OG Ey5Uh4jNXCAnu5AMFzNw6nOKi0D5pXFfP9mihiyf86HNKDwOwwylS0a1VmHvrESKqPpL N4+03fLKKyNenvik4NwJTGTeC+aST4O4T1yK79rZG6zmxB7Z2XbNuQABTBzsK5isOmCY o9bw== X-Gm-Message-State: AG10YOSXljTXeWkSKHmxluwxmCtKPIFUFJf7oBG8QL36M92PrFRgBld1u2CvwKp2SZkDjQ== X-Received: by 10.194.240.42 with SMTP id vx10mr13631419wjc.38.1454674122910; Fri, 05 Feb 2016 04:08:42 -0800 (PST) Received: from lepisma.bemi (89-104-28-113.customer.bnet.at. [89.104.28.113]) by smtp.gmail.com with ESMTPSA id w144sm19455224wmd.8.2016.02.05.04.08.41 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 05 Feb 2016 04:08:42 -0800 (PST) Sender: Michael Wallner Content-Type: multipart/alternative; boundary="Apple-Mail=_0D43EB6F-03CF-4BA0-B406-E42B26EF6F6D" Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) In-Reply-To: Date: Fri, 5 Feb 2016 13:08:41 +0100 Cc: internals@lists.php.net Message-ID: <0EC3D394-F475-42EF-B5DA-2393A88E1797@php.net> References: <55.70.56702.FD2E7A65@pb1.pair.com> To: Andrea Faulds X-Mailer: Apple Mail (2.2104) Subject: Re: [PHP-DEV] [RFC] Warn about invalid strings in arithmetic (moving backtodiscussion) From: mike@php.net (Michael Wallner) --Apple-Mail=_0D43EB6F-03CF-4BA0-B406-E42B26EF6F6D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 > On 05 02 2016, at 11:49, Andrea Faulds wrote: >=20 > Hi again, >=20 > Andrea Faulds wrote: >> There is one unresolved issue with the current patch that the RFC >> doesn't address, so I'll ask about it here. >>=20 >> As part of supporting exponent notation in all remaining integer >> operations (casts, operators), I would like to have intval() support = it, >> to match the `(int)` cast. >>=20 >> For strings, intval() doesn't use the normal zval-to-long conversion >> functions (zval_get_long/convert_to_long), but instead uses strtol >> directly. This is so it can support multiple bases, e.g. intval("10", >> 12) results in 12. >>=20 >> In order for intval() to support exponent notation, I'd have to = change >> it to now call zval_get_long, but that function doesn't support >> non-decimal bases, nor does is_numeric_string_ex, which underlies it. >>=20 >> So, we'd either have to make intval() only support exponent notation = for >> base 10, an unfortunate inconsistency, or we could not touch = intval(), >> but then intval($a, 10) would no longer act the same as (int)$a. >>=20 >> I'm leaning towards the first choice, but I'd like to hear what the >> mailing list thinks. Either way we have a new inconsistency. But = then, >> intval() has unfortunate behaviour with its base parameter anyway, in >> that ignores the base for non-string input. That means that = intval(123, >> 8) and intval("123", 8) aren't equivalent, a violation of weak = typing. >>=20 >> Anyway, please tell me your thoughts. >=20 > There hasn't been any response to this so far on the mailing list, = unfortunately. In discussions I've had elsewhere, making it apply to = intval() but only for base 10 has seemed to make sense. Both ways result = in inconsistency. >=20 > So, I've updated the RFC to clarify that it does apply to intval(), = but only where $base is 10, and also to clarify that settype() should be = affected. To be honest, I had not even memorised intval() supports a base, but = that we have base_convert(). I=92d opt for dropping base convert support from intval(), but that=92s = obviously not possible, because PHP-7.1 is the target for this RFC. Cheers, Mike --Apple-Mail=_0D43EB6F-03CF-4BA0-B406-E42B26EF6F6D--