Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 237629ad64b4b6ce2d2c6ad15a2085f128d6f11e 2 parents b8a2f8c + 2ceebdc
@fabpot fabpot authored
View
8 src/Symfony/Component/Config/Definition/Processor.php
@@ -89,14 +89,14 @@ public static function normalizeKeys(array $config)
*
* 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
View
41 src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php
@@ -31,4 +31,45 @@ public function unserialize($data)
{
$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;
+ }
}
View
9 src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
@@ -51,14 +51,7 @@ public function collect(Request $request, Response $response, \Exception $except
$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;
Please sign in to comment.
Something went wrong with that request. Please try again.