Merge branch '2.0' into 2.1
* 2.0: fixed stringification of array objects in RequestDataCollector (closes #5295) Fixing config normalisation example in docblock Conflicts: src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
This commit is contained in:
commit
237629ad64
|
@ -89,14 +89,14 @@ class Processor
|
|||
*
|
||||
* Here is an example.
|
||||
*
|
||||
* The configuration is XML:
|
||||
* The configuration in XML:
|
||||
*
|
||||
* <twig:extension id="twig.extension.foo" />
|
||||
* <twig:extension id="twig.extension.bar" />
|
||||
* <twig:extension>twig.extension.foo</twig:extension>
|
||||
* <twig:extension>twig.extension.bar</twig:extension>
|
||||
*
|
||||
* And the same configuration in YAML:
|
||||
*
|
||||
* twig.extensions: ['twig.extension.foo', 'twig.extension.bar']
|
||||
* extensions: ['twig.extension.foo', 'twig.extension.bar']
|
||||
*
|
||||
* @param array $config A config array
|
||||
* @param string $key The key to normalize
|
||||
|
|
|
@ -31,4 +31,45 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
|
|||
{
|
||||
$this->data = unserialize($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a PHP variable to a string.
|
||||
*
|
||||
* @param mixed $var A PHP variable
|
||||
*
|
||||
* @return string The string representation of the variable
|
||||
*/
|
||||
protected function varToString($var)
|
||||
{
|
||||
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 sprintf("Array(%s)", implode(', ', $a));
|
||||
}
|
||||
|
||||
if (is_resource($var)) {
|
||||
return sprintf('Resource(%s)', get_resource_type($var));
|
||||
}
|
||||
|
||||
if (null === $var) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
if (false === $var) {
|
||||
return 'false';
|
||||
}
|
||||
|
||||
if (true === $var) {
|
||||
return 'true';
|
||||
}
|
||||
|
||||
return (string) $var;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,14 +51,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
|||
|
||||
$attributes = array();
|
||||
foreach ($request->attributes->all() as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$attributes[$key] = sprintf('Object(%s)', get_class($value));
|
||||
if (is_callable(array($value, '__toString'))) {
|
||||
$attributes[$key] .= sprintf(' = %s', (string) $value);
|
||||
}
|
||||
} else {
|
||||
$attributes[$key] = $value;
|
||||
}
|
||||
$attributes[$key] = $this->varToString($value);
|
||||
}
|
||||
|
||||
$content = null;
|
||||
|
|
Reference in New Issue