Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76083 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87692 invoked from network); 25 Jul 2014 01:17:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jul 2014 01:17:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:60964] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D8/B7-55539-C00B1D35 for ; Thu, 24 Jul 2014 21:17:00 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 05D3AB00085 for ; Thu, 24 Jul 2014 21:17:03 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id yOUnWuXbYE-8 for ; Thu, 24 Jul 2014 21:17:02 -0400 (EDT) Received: from [192.168.0.15] (unknown [90.210.122.167]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 5B201B0007B for ; Thu, 24 Jul 2014 21:17:01 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> Date: Fri, 25 Jul 2014 02:16:58 +0100 Content-Transfer-Encoding: quoted-printable Message-ID: References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> To: PHP internals X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: ajf@ajf.me (Andrea Faulds) On 13 Jul 2014, at 02:57, Andrea Faulds wrote: > The RFC is here: = https://wiki.php.net/rfc/scalar_type_hinting_with_cast >=20 > A pull request is here: https://github.com/php/php-src/pull/717 I just updated the patch and RFC to include overflow safety for the = integer type hint. This means that the following code is an error: function foo(int $a) {} foo(=918493284029384029384028409304249230894=92); This is actually a level of safety you couldn=92t get with any other = proposal. If you explicitly cast with (int) it will silently = saturate/cap the integer (data is lost), and zend_parse_parameters will = silently saturate or truncate (depending on the function). This is consistent with passing a float. Were I to do the following, it = was already an error in the proposal: function foo(int $a) {} foo(8493284029384029384028409304249230894.0); -- Andrea Faulds http://ajf.me/