declare(strict_types=1);
function square(int $n): int {
return $n * $n;
}
echo square(5); // OK
echo square("5"); // TypeError: string is not allowed
/*
run:
25
Fatal error: Uncaught TypeError: square(): Argument #1 ($n) must be of type int, string given
*/