示例#1
0
 /**
  * @dataProvider getElements
  */
 public function testListToInlineValues($message, $result, $escape)
 {
     $this->assertEquals($result, list_to_string($message, $escape));
 }
示例#2
0
function universal_to_string($thing, $indent = 0)
{
    if (is_array($thing)) {
        if (is_array_list($thing)) {
            return list_to_string($thing, $indent);
        }
        return dictionary_to_string($thing, $indent);
    }
    if ($thing === null) {
        return 'null';
    }
    if ($thing === false) {
        return 'false';
    }
    if ($thing === true) {
        return 'true';
    }
    if ($thing === 0) {
        return '0';
    }
    if (is_numeric($thing)) {
        return '' . $thing;
    }
    if (is_string($thing)) {
        return '"' . str_replace(array("\n", "\r", "\t", "\""), array("\\n", "\\r", "\\t", "\\\""), $thing) . '"';
    }
    return '<UNDEFINED TO STRING>' . $thing . '</UNDEFINED TO STRING>';
}