From 138cd09948ff09a1cb436cb02e6f3409413ac234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antal=20=C3=81ron?= Date: Thu, 7 Dec 2017 17:59:09 +0100 Subject: [PATCH] [VarDumper] Fixed file links leave blank pages when ide is configured --- .../Component/VarDumper/Dumper/HtmlDumper.php | 3 ++- .../VarDumper/Tests/Caster/StubCasterTest.php | 27 ++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index a268ecf3e5561..b8f1b099f3ff4 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -828,7 +828,8 @@ protected function style($style, $value, $attr = array()) $attr['href'] = $href; } if (isset($attr['href'])) { - $v = sprintf('%s', esc($this->utf8Encode($attr['href'])), $v); + $target = isset($attr['file']) ? '' : ' target="_blank"'; + $v = sprintf('%s', esc($this->utf8Encode($attr['href'])), $target, $v); } if (isset($attr['lang'])) { $v = sprintf('%s', esc($attr['lang']), $v); diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/StubCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/StubCasterTest.php index 525542c5fed9c..36603c51cc012 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/StubCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/StubCasterTest.php @@ -100,7 +100,28 @@ public function testLinkStub() $expectedDump = <<<'EODUMP' array:1 [ - 0 => "Symfony\Component\VarDumper\Tests\Caster\StubCasterTest" + 0 => "Symfony\Component\VarDumper\Tests\Caster\StubCasterTest" +] + +EODUMP; + + $this->assertStringMatchesFormat($expectedDump, $dump); + } + + public function testLinkStubWithNoFileLink() + { + $var = array(new LinkStub('example.com', 0, 'http://example.com')); + + $cloner = new VarCloner(); + $dumper = new HtmlDumper(); + $dumper->setDumpHeader(''); + $dumper->setDumpBoundaries('', ''); + $dumper->setDisplayOptions(array('fileLinkFormat' => '%f:%l')); + $dump = $dumper->dump($cloner->cloneVar($var), true); + + $expectedDump = <<<'EODUMP' +array:1 [ + 0 => "example.com" ] EODUMP; @@ -120,7 +141,7 @@ public function testClassStub() $expectedDump = <<<'EODUMP' array:1 [ - 0 => "hello" + 0 => "hello" ] EODUMP; @@ -161,7 +182,7 @@ public function testClassStubWithNotExistingMethod() $expectedDump = <<<'EODUMP' array:1 [ - 0 => "hello" + 0 => "hello" ] EODUMP;