val_to_string() public static method

converts all known PHP types into a string representation. Generally would be less verbose with objects and arrays than FUnit::var_export() because it uses json_encode()
public static val_to_string ( mixed $val, integer $maxlen = 50 ) : string
$val mixed the value to get as a string rep
$maxlen integer if > 0, truncate the string rep (default 50)
return string
Example #1
0
 /**
  * @see \FUnit::add_assertion_result()
  */
 public function addAssertionResult($func_name, $func_args, $result, $file, $line, $fail_info, $msg = null, $expected_fail = false)
 {
     \FUnit::debug_out("Adding assertion result for '{$func_name}' to suite '" . $this->getName() . "'");
     $result = $result ? \FUnit::PASS : \FUnit::FAIL;
     $refl_meth = new \ReflectionMethod($func_name);
     $args_strs = array();
     foreach ($refl_meth->getParameters() as $key => $value) {
         $param = $value->name;
         if (array_key_exists($key, $func_args) && $param !== 'msg') {
             $param_val = \FUnit::val_to_string($func_args[$key]);
             $args_strs[] = "\${$param}={$param_val}";
         }
     }
     $this->tests[$this->current_test_name]['assertions'][] = compact('func_name', 'func_args', 'args_strs', 'result', 'msg', 'expected_fail', 'file', 'line', 'fail_info');
 }