Index: branches/5.2.x/core/units/helpers/json_helper.php =================================================================== diff -u -N -r14244 -r14628 --- branches/5.2.x/core/units/helpers/json_helper.php (.../json_helper.php) (revision 14244) +++ branches/5.2.x/core/units/helpers/json_helper.php (.../json_helper.php) (revision 14628) @@ -1,6 +1,6 @@ getType($data); - switch ($type) { + switch ( $type ) { case 'object': - $data = '{'.$this->processData($data, $type).'}'; + $data = '{' . $this->processData($data, $type) . '}'; break; case 'array': - $data = '['.$this->processData($data, $type).']'; + $data = '[' . $this->processData($data, $type) . ']'; break; default: - if (is_int($data) || is_float($data)) { + if ( is_int($data) || is_float($data) ) { $data = (string)$data; - } elseif (is_string($data)) { - $data = '"'.$this->escape($data).'"'; - } elseif (is_bool($data)) { + } + elseif ( is_string($data) ) { + $data = '"' . $this->escape($data) . '"'; + } + elseif ( is_bool($data) ) { $data = $data ? 'true' : 'false'; - } else { + } + else { $data = 'null'; } } + return $data; } /** * Enter description here... * - * @param unknown_type $input - * @param unknown_type $type - * @return unknown + * @param Array $data + * @param string $type + * @return string */ function processData($data, $type) { - $output = Array(); + $output = Array (); // If data is an object - it should be converted as a key => value pair - if ($type == 'object'){ - foreach($data as $key => $value) { - $output[] = '"'.$key.'": '.$this->encode($value); + if ( $type == 'object' ) { + foreach ($data as $key => $value) { + $output[] = '"' . $key . '": ' . $this->encode($value); } - } else { - foreach($data as $key => $value) { + } + else { + foreach ($data as $value) { $output[] = $this->encode($value); } } - return implode(',', $output);; + + return implode(',', $output); } /** * Function determines type of variable * - * @param unknown_type $data - * @return unknown + * @param mixed $data + * @return string */ function getType(&$data) {