diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php
index c4101e2d62..74faed19ee 100644
--- a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php
+++ b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php
@@ -246,20 +246,33 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
private function doDump($data, $name, $file, $line)
{
- if ($this->dumper instanceof HtmlDumper) {
- $name = $this->htmlEncode($name);
- $file = $this->htmlEncode($file);
- if ('' !== $file) {
- if ($this->fileLinkFormat) {
- $link = strtr($this->fileLinkFormat, array('%f' => $file, '%l' => $line));
- $name = sprintf('%s', $link, $file, $name);
+ if (PHP_VERSION_ID >= 50400 && $this->dumper instanceof CliDumper) {
+ $contextDumper = function ($name, $file, $line, $fileLinkFormat) {
+ if ($this instanceof HtmlDumper) {
+ if ('' !== $file) {
+ $s = $this->style('meta', '%s');
+ $name = strip_tags($this->style('', $name));
+ $file = strip_tags($this->style('', $file));
+ if ($fileLinkFormat) {
+ $link = strtr($fileLinkFormat, array('%f' => $file, '%l' => (int) $line));
+ $name = sprintf(''.$s.'', $link, $file, $name);
+ } else {
+ $name = sprintf(''.$s.'', $file, $name);
+ }
+ } else {
+ $name = $this->style('meta', $name);
+ }
+ $this->line = $name.' on line '.$this->style('meta', $line).':';
} else {
- $name = sprintf('%s', $file, $name);
+ $this->line = $this->style('meta', $name).' on line '.$this->style('meta', $line).':';
}
- }
- echo "\n{$name} on line {$line}:";
+ $this->dumpLine(0);
+ };
+ $contextDumper = $contextDumper->bindTo($this->dumper, $this->dumper);
+ $contextDumper($name, $file, $line, $this->fileLinkFormat);
} else {
- echo "{$name} on line {$line}:\n";
+ $cloner = new VarCloner();
+ $this->dumper->dump($cloner->cloneVar($name.' on line '.$line.':'));
}
$this->dumper->dump($data);
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php
index 5869c72500..e9b8433c46 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php
@@ -71,7 +71,11 @@ class DumpDataCollectorTest extends \PHPUnit_Framework_TestCase
$collector->collect(new Request(), new Response());
$output = ob_get_clean();
- $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n123\n", $output);
+ if (PHP_VERSION_ID >= 50400) {
+ $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n123\n", $output);
+ } else {
+ $this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n123\n", $output);
+ }
$this->assertSame(1, $collector->getDumpsCount());
$collector->serialize();
}
@@ -85,12 +89,23 @@ class DumpDataCollectorTest extends \PHPUnit_Framework_TestCase
$collector->dump($data);
$line = __LINE__ - 1;
$file = __FILE__;
- $xOutput = <<DumpDataCollectorTest.php on line {$line}: 123
+ if (PHP_VERSION_ID >= 50400) {
+ $xOutput = <<DumpDataCollectorTest.php on line {$line}:
+123
EOTXT;
+ } else {
+ $len = strlen("DumpDataCollectorTest.php on line {$line}:");
+ $xOutput = <<"DumpDataCollectorTest.php on line {$line}:"
+
+123
+
+
+EOTXT;
+ }
ob_start();
$response = new Response();
@@ -114,6 +129,10 @@ EOTXT;
ob_start();
$collector = null;
- $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean());
+ if (PHP_VERSION_ID >= 50400) {
+ $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean());
+ } else {
+ $this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", ob_get_clean());
+ }
}
}