public static function stringify($value, $depth = 1)
{
if ($depth >= self::$maxDepthStringify) {
return self::$maxReplacementStringify;
}
if (is_array($value)) {
return static::stringifyArray($value, $depth);
}
if (is_object($value)) {
return static::stringifyObject($value, $depth);
}
if (is_resource($value)) {
return sprintf('`[resource] (%s)`', get_resource_type($value));
}
if (is_float($value)) {
if (is_infinite($value)) {
return ($value > 0 ? '' : '-') . 'INF';
}
if (is_nan($value)) {
return 'NaN';
}
}
return @json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) ?: $value;
}