RE: [PHP-DEV] What do we need strict scalar type hints for?

From: Date: Thu, 05 Feb 2015 08:58:14 +0000
Subject: RE: [PHP-DEV] What do we need strict scalar type hints for?
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-81880@lists.php.net to get a copy of this message
> De : Stanislav Malyshev [mailto:smalyshev@gmail.com] > > Adding another concept, not changing the existing ones. And really, > > it's just simplifying what is already present via is_<typename>() > > runtime checks, making our lives a little bit easier. > > There's a very big difference between allowing to check types (and then > do whatever you wish) and having functions throw fatal errors if types > do not match. +1. Checking IS_<type> at the C level after implicit conversions and checking this at the PHP level are very different. IMHO, the key point is the concept of 'type'. Strict typing considers a one-to-one correspondence between PHP types and zval types, which is nonsense. At the PHP level, any value returning true through is_numeric() IS a 'number', and it must remain so. Any such value with a null decimal part is an 'integer' (not the result of 'is_int()') and so on. As long as we don't agree on 'smart' high-level types and the corresponding matching rules against zval type and value, we won't agree on anything. This is what I am currently defining in the upcoming DbC RFC. Hopefully, a first version will be released tomorrow, depending on Yasuo's and Dmitry's opinion. Cheers François

« previous php.internals (#81880) next »