Switched sanitizeParameter() for existing varToString()-method; now always stores a string representation of each parameter
This commit is contained in:
parent
4fe4dfd116
commit
bb0d202250
@ -89,36 +89,44 @@ class DoctrineDataCollector extends DataCollector
|
||||
{
|
||||
foreach ($queries as $i => $query) {
|
||||
foreach ($query['params'] as $j => $param) {
|
||||
$queries[$i]['params'][$j] = $this->sanitizeParameter($param);
|
||||
$queries[$i]['params'][$j] = $this->varToString($param);
|
||||
}
|
||||
}
|
||||
|
||||
return $queries;
|
||||
}
|
||||
|
||||
private function sanitizeParameter($param)
|
||||
private function varToString($var)
|
||||
{
|
||||
if (is_array($param)) {
|
||||
foreach ($param as $key => $value) {
|
||||
$param[$key] = $this->sanitizeParameter($value);
|
||||
if (is_object($var)) {
|
||||
return sprintf('Object(%s)', get_class($var));
|
||||
}
|
||||
|
||||
if (is_array($var)) {
|
||||
$a = array();
|
||||
foreach ($var as $k => $v) {
|
||||
$a[] = sprintf('%s => %s', $k, $this->varToString($v));
|
||||
}
|
||||
|
||||
return $param;
|
||||
return sprintf("Array(%s)", implode(', ', $a));
|
||||
}
|
||||
|
||||
if (is_resource($param)) {
|
||||
return sprintf('Resource(%s)', get_resource_type($param));
|
||||
if (is_resource($var)) {
|
||||
return sprintf('Resource(%s)', get_resource_type($var));
|
||||
}
|
||||
|
||||
if (is_object($param) && $this->isNotSerializable($param)) {
|
||||
return sprintf('Object(%s)', get_class($param));
|
||||
if (null === $var) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
return $param;
|
||||
}
|
||||
if (false === $var) {
|
||||
return 'false';
|
||||
}
|
||||
|
||||
private function isNotSerializable($object)
|
||||
{
|
||||
return $object instanceof \SplFileInfo;
|
||||
if (true === $var) {
|
||||
return 'true';
|
||||
}
|
||||
|
||||
return (string) $var;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
<code>{{ query.sql }}</code>
|
||||
</div>
|
||||
<small>
|
||||
<strong>Parameters</strong>: {{ query.params|yaml_encode }}<br />
|
||||
<strong>Parameters</strong>: {{ query.params }}<br />
|
||||
<strong>Time</strong>: {{ '%0.2f'|format(query.executionMS * 1000) }} ms
|
||||
</small>
|
||||
</li>
|
||||
|
@ -102,10 +102,10 @@ class DoctrineDataCollectorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
return array(
|
||||
array('some value', 'some value'),
|
||||
array(1, 1),
|
||||
array(true, true),
|
||||
array(null, null),
|
||||
array(new \stdClass(), new \stdClass()),
|
||||
array(1, '1'),
|
||||
array(true, 'true'),
|
||||
array(null, 'null'),
|
||||
array(new \stdClass(), 'Object(stdClass)'),
|
||||
array(fopen(__FILE__, 'r'), 'Resource(stream)'),
|
||||
array(new \SplFileInfo(__FILE__), 'Object(SplFileInfo)'),
|
||||
);
|
||||
|
Reference in New Issue
Block a user