RE: [PHP-DEV] RE: [VOTE][RFC] Coercive Scalar Type Hints

From: Date: Wed, 11 Mar 2015 20:50:05 +0000
Subject: RE: [PHP-DEV] RE: [VOTE][RFC] Coercive Scalar Type Hints
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-84575@lists.php.net to get a copy of this message
> -----Original Message----- > From: Derick Rethans [mailto:derick@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. Zeev

« previous php.internals (#84575) next »