in src/legacy_fixme/coercions.php [502:516]
function string_cast_for_basic_switch(
mixed $value,
?arraykey $first_case,
)[]: string {
if ($value is string) return $value;
if ($value is null) return '';
// check for 0ish or true
if (($value is num && !$value) || ($value is bool && $value)) {
return ($first_case as ?string) ?? SWITCH_STRING_SENTINEL;
}
if ($value is \StringishObject && !($value is \ConstCollection<_>)) {
return (string)($value as dynamic); // this will throw
}
return SWITCH_STRING_SENTINEL;
}