Undefined
in package
A unit enum representing an undefined value.
It is inhabited by exactly one case: undefined.
Conceptually, undefined indicates the absence
of a value. This is useful in cases where null is a valid value, and you
need to distinguish between "no value provided" and "value explicitly set
to null".
The Undefined::undefined case is also aliased as the constant undefined for convenience.
You can use this as a default value to safely check that no valid value was provided:
$value = config('some_key', undefined);
This is useful in cases where null is a valid value, and you need to
distinguish between "no value provided" and "value explicitly set to null".
You can also use the Undefined enum as a type hint:
function example(string|null|Undefined $param = undefined): void }
Table of Contents
Cases
- undefined
- Represents an undefined value.
Cases
undefined
Represents an undefined value.
This can be used to explicitly indicate that a variable or parameter may
be undefined, differentiating it from null or other values.
You can use this as a default value to safely check that no valid value was provided:
$value = config('some_key', undefined);
This is useful in cases where null is a valid value, and you need to
distinguish between "no value provided" and "value explicitly set to null".
This constant maps to the singleton case of the Undefined enum, so
you can use the Undefined enum as a type hint:
function example(string|null|Undefined $param = undefined): void }