The error has nothing to do with float or double. Since the hinting type only works with an array or object, PHP considers the "float" to be a class. Do not use type hints for primitive scalar types. PHP is an untyped language. It doesnβt make sense.
For further use of my point, you can try this example,
function testFloat(integer $f) { return $f; } echo testFloat(1);
You get a similar error,
Catchable fatal error: Argument 1 passed to testFloat() must be an instance of integer, integer given, called in /private/tmp/test.php on line 8 and defined in /private/tmp/test.php on line 3
Zz coder
source share