private static function stringify($value)
    {
        if (is_string($value)) {
            return sprintf('"%s"', preg_replace('/\n/', '\n', $value));
        }

        if (is_bool($value)) {
            return $value ? 'true' : 'false';
        }

        if (is_null($value)) {
            return 'null';
        }

        if (is_array($value)) {
            return sprintf('[%s]', implode(', ', array_map(
                function ($value) {
                    return self::stringify($value);
                },
                $value
            )));
        }

        return (string) $value;
    }
private static function stringify($value)
    {
        if (is_string($value)) {
            return sprintf('"%s"', preg_replace('/\n/', '\n', $value));
        }

        if (is_bool($value)) {
            return $value ? 'true' : 'false';
        }

        if (is_null($value)) {
            return 'null';
        }

        if (is_array($value)) {
            return sprintf('[%s]', implode(', ', array_map(
                function ($value) {
                    return self::stringify($value);
                },
                $value
            )));
        }

        return (string) $value;
    }
private static function stringify ( $ value ) { if ( is_string ( $ value ) ) { return sprintf ( '"%s"' , preg_replace ( '/\n/' , '\n' , $ value ) ) ; } if ( is_bool ( $ value ) ) { return $ value ? 'true' : 'false' ; } if ( is_null ( $ value ) ) { return 'null' ; } if ( is_array ( $ value ) ) { return sprintf ( '[%s]' , implode ( ', ' , array_map ( function ( $ value ) { return self :: stringify ( $ value ) ; } , $ value ) ) ) ; } return ( string ) $ value ; }
Stringify the given value. It can handles strings, booleans, null values and arrays. The other types would be
casted into string.

@param string $value The value to stringify.

@return string The string representation of the given value.
Stringify the given value . It can handles strings booleans null values and arrays . The other types would be casted into string .