Improves the readability of the collected arrays in the profiler.
This commit is contained in:
parent
7baeaa2fd7
commit
3f297eaa18
@ -25,7 +25,7 @@ class FormDataExtractorTest_SimpleValueExporter extends ValueExporter
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exportValue($value)
|
||||
public function exportValue($value, $depth = 0)
|
||||
{
|
||||
return is_object($value) ? sprintf('object(%s)', get_class($value)) : var_export($value, true);
|
||||
}
|
||||
|
@ -20,22 +20,29 @@ class ValueExporter
|
||||
* Converts a PHP value to a string.
|
||||
*
|
||||
* @param mixed $value The PHP value
|
||||
* @param integer $depth The depth of the value to export
|
||||
*
|
||||
* @return string The string representation of the given value
|
||||
*/
|
||||
public function exportValue($value)
|
||||
public function exportValue($value, $depth = 0)
|
||||
{
|
||||
if (is_object($value)) {
|
||||
return sprintf('Object(%s)', get_class($value));
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$a = array();
|
||||
foreach ($value as $k => $v) {
|
||||
$a[] = sprintf('%s => %s', $k, $this->exportValue($v));
|
||||
if (empty($value)) {
|
||||
return '[]';
|
||||
}
|
||||
|
||||
return sprintf("Array(%s)", implode(', ', $a));
|
||||
$indent = str_repeat(' ', $depth);
|
||||
|
||||
$a = array();
|
||||
foreach ($value as $k => $v) {
|
||||
$a[] = sprintf('%s %s => %s', $indent, $k, $this->exportValue($v, $depth + 1));
|
||||
}
|
||||
|
||||
return sprintf("[\n%s%s\n%s]", $indent, implode(sprintf(", \n%s", $indent), $a), $indent);
|
||||
}
|
||||
|
||||
if (is_resource($value)) {
|
||||
|
Reference in New Issue
Block a user