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.
> And that also hints towards a benefit of adding a numeric hint as well
> (which will accept (and cast to) either an int or a float, exactly how
> is_numeric_string() does internally)... Which is something that may
> want to be considered for this RFC.
+1
--
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT
Lecturer.
+44 (0) 787 668 0256 http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information:
http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h>
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php