more reliable stringing
This commit is contained in:
parent
f0ee76e7c7
commit
7e64d1b052
1 changed files with 7 additions and 1 deletions
|
@ -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>";
|
||||
}
|
||||
|
|
Reference in a new issue