declare(strict_types=1);
function half(int $n): float {
return $n / 2;
}
echo half(10); // OK
echo half(3.14); // TypeError: float passed to int parameter
/*
run:
5
Fatal error: Uncaught TypeError: half(): Argument #1 ($n) must be of type int, float given,
*/