i have this code:
<?php
declare(strict_types=1);
# test_1 with bool
function test_1(bool $bool) {
return $bool ? 'Yes' : 'No';
}
# test_2 with boolean
function test_2(boolean $bool) {
return $bool ? 'Yes' : 'No';
}
$value = false;
# Why does this work ...
echo test_1($value) . "<br>";
# ... but this doesn't?
echo test_2($value) . "<br>";
?>
Strict types seem to work with bool but not with boolean.
php.net says:
Aliases for the above scalar types are not supported. Instead, they are treated as class or interface names. For example, using boolean as a parameter or return type will require an argument or return value that is an instanceof the class or interface boolean, rather than of type bool
But somehow i don't get it. Can anyone explain that to me please?