Description
Hi!
From time to time, I come across the desire to have nullable casts: (?string)$value.
It should work as follows:
$cast = (?string)$value;
$cast = nullableString($value);
function nullableString(mixed $value): ?string
{
if (null === $value) {
return null;
}
return (string)$value;
}
Description
Hi!
From time to time, I come across the desire to have nullable casts:
(?string)$value.It should work as follows: