Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75490 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34667 invoked from network); 14 Jul 2014 17:06:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2014 17:06:24 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.182 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.214.182 mail-ob0-f182.google.com Received: from [209.85.214.182] ([209.85.214.182:65128] helo=mail-ob0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D1/09-25444-F0E04C35 for ; Mon, 14 Jul 2014 13:06:23 -0400 Received: by mail-ob0-f182.google.com with SMTP id wm4so4478701obc.13 for ; Mon, 14 Jul 2014 10:06:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=rPnrba4zTBjDeQCz/8Lm4fMKtSgvhihz/oIfPsobmEY=; b=CYQz3M1pixNG0JZSEM2PIUe1xHa9tNdD8Wo8L0U3Bw2cySRFQwIn67PrK/yyfBDErv s8T2iuf2pnWRnZuK9dobifSU2jDyJFCG271JiT95h0QPPNMPF1NSRopfA3qEi4LuW4ad rmrNZJR88Mgv5SVhBEIpejlxrZ9hCMTdkJ78MmTQ2DmZrQvxjSj+WKe8cPCPKq7qldbu XXMDNRpumGt3WEOgJ4WQ8NUouzqmyovPsMofPpPNNaLhBmKBunc0SynGTcSV83SnWsFb VjlP4aixgxBr9U2Wdng3U/hKJcgqyPRQhMLUBaBli/vQOFPeuOMKplnWcfWut/WjOG1S an0w== MIME-Version: 1.0 X-Received: by 10.182.224.163 with SMTP id rd3mr19200211obc.41.1405357580170; Mon, 14 Jul 2014 10:06:20 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.76.77.100 with HTTP; Mon, 14 Jul 2014 10:06:19 -0700 (PDT) In-Reply-To: <20140714170149.GE27743@phcomp.co.uk> References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> <53C3F70A.7010706@gmail.com> <3aa29e080d70c843713e19a952dfbad6@mail.gmail.com> <20140714170149.GE27743@phcomp.co.uk> Date: Mon, 14 Jul 2014 11:06:19 -0600 X-Google-Sender-Auth: B9hPQd4tLW2mRNLxW7IqCpDUr9Q Message-ID: To: internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: levim@php.net (Levi Morrison) On Mon, Jul 14, 2014 at 11:01 AM, Alain Williams wrote: > On Mon, Jul 14, 2014 at 12:25:22PM -0400, Anthony Ferrara wrote: > >> IMHO, strict hints are dangerous in the context of PHP because PHP's >> types can change in unpredictable ways. A variable that was an integer >> can turn into a float through seemingly integer operations. Example: >> $a / $b * $b will result in a float unless $b divides $a (even though >> for sane values of $a and $b, it will be exactly representable as an >> int). > > But if you have: > > function foo(int $a) { > ... > $a = 3 / 2; > } > > What do you expect $a to contain ? I would suggest integer 1. I would expect the same result as 3.0 / 2.0, as would most every new programmer.