Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80459 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85904 invoked from network); 14 Jan 2015 13:04:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jan 2015 13:04:21 -0000 Authentication-Results: pb1.pair.com header.from=thomas@nunninger.info; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=thomas@nunninger.info; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nunninger.info from 87.106.55.207 cause and error) X-PHP-List-Original-Sender: thomas@nunninger.info X-Host-Fingerprint: 87.106.55.207 mail.nunninger.info Linux 2.6 Received: from [87.106.55.207] ([87.106.55.207:55817] helo=mail.nunninger.info) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BA/10-19120-35966B45 for ; Wed, 14 Jan 2015 08:04:20 -0500 Received: from pd95c6425.dip0.t-ipconnect.de ([217.92.100.37] helo=[192.168.178.30]) by mail.nunninger.info with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1YBNcE-0003G3-Fb; Wed, 14 Jan 2015 13:04:10 +0000 Message-ID: <54B66945.2070000@nunninger.info> Date: Wed, 14 Jan 2015 14:04:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Andrea Faulds CC: PHP Internals List References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> <4E2073DE-0951-498C-97BB-DDAC094F11FA@ajf.me> <54B6402B.1020401@nunninger.info> <77C73BB0-C124-47EC-81AB-ADDE6DAB1C60@ajf.me> In-Reply-To: <77C73BB0-C124-47EC-81AB-ADDE6DAB1C60@ajf.me> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -0.3 (/) X-Spam-Several-Recipients: Yes Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: thomas@nunninger.info (Thomas Nunninger) Hi Andrea, On 01/14/2015 11:20 AM, Andrea Faulds wrote: > Hi Thomas, > >> On 14 Jan 2015, at 10:08, Thomas Nunninger wrote: >> >> ---------------- >> $i = 1; >> $a = myFunc( $i ); >> >> declare(strict_typehints=TRUE); >> >> function myFunc( float $f ) >> { >> return otherFunc( $f ); >> } >> >> function otherFunc( float $f ) >> { >> ... >> } >> ---------------- >> >> As author of strict code I need to replace >> >> return otherFunc( $f ); >> >> by >> >> return otherFunc( (float) $f ); >> >> >> I'm not sure >> >> - if this is what a strict coder wants and >> >> - if you find an acceptable way to test your strict code if it works with non-strict code. > > I don’t understand, I’m sorry. > > If you are using declare(strict_typehints=TRUE); then all calls in a file are “strict”. If you are not, all calls in a file are “weak”. Sorry, if my mail was not clear. My point was: If I write a library in strict mode and someone else is using it from his non-strict mode, he can pass an integer to myFunc() without an error. If I use this integer in my library and hand it over to otherFunc() (in my library) this will fail as integer is not accepted for float. Or did I misunderstood the RFC and there is a casting of the integer to a float when calling myFunc()? Regards Thomas