Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite14db39

Browse files
[DebugBundle] Use output mechanism of dumpers instead of echoing
1 parent70e6a14 commite14db39

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

‎src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php‎

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -250,20 +250,33 @@ public function __destruct()
250250

251251
privatefunctiondoDump($data,$name,$file,$line)
252252
{
253-
if ($this->dumperinstanceof HtmlDumper) {
254-
$name =$this->htmlEncode($name);
255-
$file =$this->htmlEncode($file);
256-
if ('' !==$file) {
257-
if ($this->fileLinkFormat) {
258-
$link =strtr($this->fileLinkFormat,array('%f' =>$file,'%l' =>$line));
259-
$name =sprintf('<a href="%s" title="%s">%s</a>',$link,$file,$name);
253+
if (PHP_VERSION_ID >=50400 &&$this->dumperinstanceof CliDumper) {
254+
$contextDumper =function ($name,$file,$line,$fileLinkFormat) {
255+
if ($thisinstanceof HtmlDumper) {
256+
if ('' !==$file) {
257+
$s =$this->style('meta','%s');
258+
$name =strip_tags($this->style('',$name));
259+
$file =strip_tags($this->style('',$file));
260+
if ($fileLinkFormat) {
261+
$link =strtr($fileLinkFormat,array('%f' =>$file,'%l' => (int)$line));
262+
$name =sprintf('<a href="%s" title="%s">'.$s.'</a>',$link,$file,$name);
263+
}else {
264+
$name =sprintf('<abbr title="%s">'.$s.'</abbr>',$file,$name);
265+
}
266+
}else {
267+
$name =$this->style('meta',$name);
268+
}
269+
$this->line =$name.' on line'.$this->style('meta',$line).':';
260270
}else {
261-
$name =sprintf('<abbr title="%s">%s</abbr>',$file,$name);
271+
$this->line =$this->style('meta',$name).' on line'.$this->style('meta',$line).':';
262272
}
263-
}
264-
echo"\n<span class=\"sf-dump-meta\">{$name} on line{$line}:</span>";
273+
$this->dumpLine(0);
274+
};
275+
$contextDumper =$contextDumper->bindTo($this->dumper,$this->dumper);
276+
$contextDumper($name,$file,$line,$this->fileLinkFormat);
265277
}else {
266-
echo"{$name} on line{$line}:\n";
278+
$cloner =newVarCloner();
279+
$this->dumper->dump($cloner->cloneVar($name.' on line'.$line.':'));
267280
}
268281
$this->dumper->dump($data);
269282
}

‎src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ public function testCollectDefault()
7171
$collector->collect(newRequest(),newResponse());
7272
$output =ob_get_clean();
7373

74-
$this->assertSame("DumpDataCollectorTest.php on line{$line}:\n123\n",$output);
74+
if (PHP_VERSION_ID >=50400) {
75+
$this->assertSame("DumpDataCollectorTest.php on line{$line}:\n123\n",$output);
76+
}else {
77+
$this->assertSame("\"DumpDataCollectorTest.php on line{$line}:\"\n123\n",$output);
78+
}
7579
}
7680

7781
publicfunctiontestCollectHtml()
@@ -84,8 +88,8 @@ public function testCollectHtml()
8488
$line =__LINE__ -1;
8589
$file =__FILE__;
8690
$xOutput =<<<EOTXT
87-
88-
<span class="sf-dump-meta"><a href="test://{$file}:{$line}" title="{$file}">DumpDataCollectorTest.php</a> on line{$line}:</span> <pre class=sf-dump id=sf-dump data-indent-pad=" "><span class=sf-dump-num>123</span>
91+
<pre class=sf-dump id=sf-dump data-indent-pad=" "><a href="test://{$file}:{$line}" title="{$file}"><span class=sf-dump-meta>DumpDataCollectorTest.php</span></a> on line <span class=sf-dump-meta>{$line}</span>:
92+
<span class=sf-dump-num>123</span>
8993
</pre>
9094
9195
EOTXT;
@@ -110,6 +114,10 @@ public function testFlush()
110114

111115
ob_start();
112116
$collector =null;
113-
$this->assertSame("DumpDataCollectorTest.php on line{$line}:\n456\n",ob_get_clean());
117+
if (PHP_VERSION_ID >=50400) {
118+
$this->assertSame("DumpDataCollectorTest.php on line{$line}:\n456\n",ob_get_clean());
119+
}else {
120+
$this->assertSame("\"DumpDataCollectorTest.php on line{$line}:\"\n456\n",ob_get_clean());
121+
}
114122
}
115123
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp