Zeev, On Wed, Mar 11, 2015 at 4:50 PM, Zeev Suraski <z...@zend.com> wrote: >> -----Original Message----- >> From: Derick Rethans [mailto:der...@php.net] >> Sent: Wednesday, March 11, 2015 10:37 PM >> To: Zeev Suraski >> Cc: Anthony Ferrara; internals@lists.php.net >> Subject: RE: [PHP-DEV] RE: [VOTE][RFC] Coercive Scalar Type Hints >> >> > You're right, sorry. Reverse it then: >> > function bar(int $x) >> > $foo = 1.0; >> > bar($foo); // will definitely fail in strict mode >> >> And it should fail, as logically it is the same as: >> >> $foo = 1.901 - 0.709 - 0.192; >> bar($foo); >> >> which is only 1, if you look at it with a small enough precision. > > I'm not sure what you're trying to say. The two pieces are indeed > identical from all points of view - static analysis, how it would behave > in strict type hinting, weak type hinting or coercive type hinting.
I think Derick's point is more that: http://3v4l.org/b4S8d var_dump($foo); gives float(1) while it is != 1 (even loose). So debugging is weird, since it looks like it should work (hey, it says float(1), why isn't it passing for an int?). In strict mode, it's an error because it's a float. So it's not quite identical. Since logically it should work under your rules, but it doesn't work. And there's nothing to the user that implies or confirms that it shouldn't work. Anthony -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php