Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84001 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59695 invoked from network); 27 Feb 2015 13:44:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2015 13:44:57 -0000 Authentication-Results: pb1.pair.com smtp.mail=j.boggiano@seld.be; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=j.boggiano@seld.be; sender-id=pass Received-SPF: pass (pb1.pair.com: domain seld.be designates 74.125.82.173 as permitted sender) X-PHP-List-Original-Sender: j.boggiano@seld.be X-Host-Fingerprint: 74.125.82.173 mail-we0-f173.google.com Received: from [74.125.82.173] ([74.125.82.173:38759] helo=mail-we0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/EF-32582-7D470F45 for ; Fri, 27 Feb 2015 08:44:56 -0500 Received: by wesw55 with SMTP id w55so20480682wes.5 for ; Fri, 27 Feb 2015 05:44:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=miByFfIKrjGhCo5tuOY/jsHyMZoggNKr07WjW/LEvWc=; b=Jn8ASpS9rh68SDHT73zNYBeHAccFDDEdRKIeWyv0pPFhIzIV+OlOBh5G4vu579yzxn ZbxpYhHDGB5T3orROPnClpydqf8OWRKhfR7djowfwRyAbJWI9AZG02PTJeoCSVOyEmSh jhk6GPZK/+EmIaDws77pcvOq4IrbmbBufdQO1eL1mGmH6hZFeIU3AJrc3CEBebXeO0gB 4C/XUjSXp+xqgCQlllGzJF+mRzOAEV+5tEdmhKZkW8zPX1JAQo8T3csRwQedWCnWTwTf uaPNH/8sTyEkB93TUJzC5mhwVKKX6U1c5zAs6h84oKcooiyG/7lhxwvzoBovriibXixh v4iQ== X-Gm-Message-State: ALoCoQmrlxd8e1uFzmWNWDTq3gpvG3FvFktgd6DB9kGHyNNkaoSolaETDGDcKp8SzDSJUobtI5l9 X-Received: by 10.194.71.98 with SMTP id t2mr28427542wju.72.1425044691457; Fri, 27 Feb 2015 05:44:51 -0800 (PST) Received: from [146.90.233.222] (222.233.90.146.dyn.plus.net. [146.90.233.222]) by mx.google.com with ESMTPSA id cf12sm6056461wjb.10.2015.02.27.05.44.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Feb 2015 05:44:50 -0800 (PST) Message-ID: <54F074D1.8000403@seld.be> Date: Fri, 27 Feb 2015 13:44:49 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Follow-up to STH user experience, this time with actual testing From: j.boggiano@seld.be (Jordi Boggiano) Matthew, Thanks a bunch for going through this and writing such a detailed report. On 27/02/2015 00:29, Matthew Weier O'Phinney wrote: > ### STHv5 > [snip] > #### Analysis > > I did not expect the float value to be coerced, particularly as it had a > fractional part. Yes, I understand that this is how casting _currently_ works in > PHP, and that the patch uses the current casting rules. However, I'd expect that > any float with a fractional value would not be cast to an integer; doing so is > lossy, and can lead to unexpected results. > > The strict_types mode operated how I would expect it, but meant I was forced to > add the declaration to the top of the file. Which leads to this: > > My tests operated differently in strict vs normal mode. That means my code does, > too. Testing both modes would be difficult to do in an automated fashion; > essentially, you're left needing to choose to support one mode or the other. > This goes back to the point I was making earlier this week: I worry that having > two modes will lead to a schism in userland libraries: those that support > strict, and those that do not; there will be little possibility of testing both. I think this last bit is misguided. Your *tests* are running differently depending if they are in strict and weak mode, that is correct, but the code's behavior itself is not changing based on the test suite's strictness. That does not mean your library is tested to run in mode X or Y, it just means your test suite's correctness relies on testing the PHP type hints in this case, and it breaks when you change the way the hints behave. For users the code will work the same no matter if they are in strict or weak mode, but if they are in weak mode they should indeed watch out if they send floats they will be silently truncated as those are the rules of weak mode. > In the end: kudos to everyone who is working on these patches and RFCs. I'm > excited about scalar type hints in PHP 7! I agree with Benjamin's conclusion that having both RFCs combined might be for the best. At the very least lossy float->int should be disabled in the STHv5's weak mode because that's dangerous and unlikely to occur IMO. The other casting changes from STHcoerce I am not sure if they're for the best or not. I am a bit worried we change things arbitrarily based on who has a good argument not to change them, and we might end up with a completely inconsistent set of casting rules. Cheers