more reliable stringing

This commit is contained in:
Shish 2023-01-28 18:57:42 +00:00
parent f0ee76e7c7
commit 7e64d1b052

View file

@ -802,8 +802,14 @@ function stringer($s): string
return "[" . implode(", ", $pairs) . "]";
}
}
if (is_null($s)) {
return "null";
}
if (is_string($s)) {
return "\"$s\""; // FIXME: handle escaping quotes
}
return (string)$s;
if (method_exists($s, "__toString")) {
return $s->__toString();
}
return "<Unstringable>";
}