mirror of
https://github.com/friendica/friendica
synced 2025-04-26 10:30:11 +00:00
Add support for toString/Serializable
This commit is contained in:
parent
5a9e9cc41b
commit
9627af924a
4 changed files with 93 additions and 4 deletions
|
@ -214,6 +214,17 @@ class ConfigFileTransformer
|
|||
case "NULL":
|
||||
return "null";
|
||||
case "object":
|
||||
if (method_exists($value, '__toString')) {
|
||||
return sprintf('\'%s\'', $value);
|
||||
} elseif ($value instanceof \Serializable) {
|
||||
try {
|
||||
return $value->serialize();
|
||||
} catch (\Exception $e) {
|
||||
throw new \InvalidArgumentException(sprintf('Cannot serialize %s.', gettype($value)), $e);
|
||||
}
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf('%s is an object without stringify.', gettype($value)));
|
||||
}
|
||||
case "resource":
|
||||
case "resource (closed)":
|
||||
throw new \InvalidArgumentException(sprintf('%s in configs are not supported yet.', gettype($value)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue