- Output for 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
- int(1) foo got 1 NULL foo got 42
<?php
function bar(?int $i = null) {
var_dump($i);
if (intval($i)) {
foo($i);
} else {
foo();
}
}
function foo(int $i = 42) {
echo "foo got $i\n";
}
bar(1);
bar();