Пример #1
0
        if (dump_r::$json_pretty) {
            $type->disp = json_encode($json, JSON_PRETTY_PRINT);
        }
        // maybe set subtype as JSON [] or JSON {}, will screw up classname
        $type->subtype = 'JSON';
        $type->children = (array) $json;
        // dont show length of objects, only arrays
        $type->length = $input[0] == '[' ? count($type->children) : null;
        return true;
    }
    return false;
}, 'is_json');
dump_r::hook_string(function ($input, $type) {
    if (strlen($input) > 5 && preg_match('#[:/-]#', $input) && ($ts = strtotime($input)) !== false) {
        $type->subtype = 'datetime';
        $type->length = dump_r_lib::rel_date($ts);
        return true;
    }
    return false;
}, 'is_datetime');
/* example of adding extra info to streams and more still to files
dump_r::hook_resource(function($input, $type) {
	if ($type->subtype == 'stream') {
		$meta = stream_get_meta_data($input);
		$type->children = array(
			'meta_data' => (object)$meta
		);

		if ($meta['wrapper_type'] == 'plainfile')
			$type->children['stat'] = (object)stat($meta['uri']);

		return true;		// skip any remaining hook_resource checks