No Hidden Nullable¶
<?php
function foo(string $a = null) {}
const A = null;
function bar(string $a = A) {}
foo(); // Deprecated
bar(); // Fatal error
?>
A hidden nullable is a, now deprecated, PHP features where typed parameters with a default value of null are automatically nullable.
Well, that is true only if PHP can spot the null at compilation time: when the null is hidden (sic) in a constant, then it is not recognized, and it leads to a Fatal Error.
This is due to PHP postponing the evaluation of the constant to execution phase.
See Also¶
Hidden and not so hidden [Try me]
PHP Features¶
Last updated: 14 July 2026