TIL that returning false
works if you declare return type int:
function foo() : int {
return false;
}
var_dump(foo());
the result:
int(0)
but returning NULL
from an int function throws an exception:
function foo() : int {
return null;
}
var_dump(foo());
the result:
PHP Fatal error: Uncaught TypeError: Return value of foo() must be of the type integer, null returned in /tmp/a.php:3
Stack trace:
#0 /tmp/a.php(5): foo()
#1 {main}
thrown in /tmp/a.php on line 3