@@ -19,12 +19,12 @@ class ValueExporter
1919 /**
2020 * Converts a PHP value to a string.
2121 *
22- * @param mixed $value The PHP value
23- * @param integer $depth The depth of the value to export
22+ * @param mixed $value The PHP value
23+ * @param integer $depth The depth of the value to export (only for internal usage)
2424 *
2525 * @return string The string representation of the given value
2626 */
27- public function exportValue ($ value , $ depth = 0 )
27+ public function exportValue ($ value , $ depth = 1 , $ deep = false )
2828 {
2929 if (is_object ($ value )) {
3030 return sprintf ('Object(%s) ' , get_class ($ value ));
@@ -39,10 +39,17 @@ public function exportValue($value, $depth = 0)
3939
4040 $ a = array ();
4141 foreach ($ value as $ k => $ v ) {
42- $ a [] = sprintf ('%s %s => %s ' , $ indent , $ k , $ this ->exportValue ($ v , $ depth + 1 ));
42+ if (is_array ($ v )) {
43+ $ deep = true ;
44+ }
45+ $ a [] = sprintf ('%s => %s ' , $ k , $ this ->exportValue ($ v , $ depth + 1 , $ deep ));
4346 }
4447
45- return sprintf ("[ \n%s%s \n%s] " , $ indent , implode (sprintf (", \n%s " , $ indent ), $ a ), $ indent );
48+ if ($ deep ) {
49+ return sprintf ("[ \n%s%s \n%s] " , $ indent , implode (sprintf (", \n%s " , $ indent ), $ a ), str_repeat (' ' , $ depth - 1 ));
50+ }
51+
52+ return sprintf ("[%s] " , implode (', ' , $ a ));
4653 }
4754
4855 if (is_resource ($ value )) {
0 commit comments