Skip to content

Commit c6e23bd

Browse files
[DebugBundle] dump() + better Symfony glue
1 parent fad66a3 commit c6e23bd

File tree

2 files changed

+65
-65
lines changed

2 files changed

+65
-65
lines changed

Dumper/HtmlDumper.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class HtmlDumper extends CliDumper
2121
public static $defaultOutputStream = 'php://output';
2222

2323
protected $dumpHeader;
24-
protected $dumpPrefix = '<pre class=sf-var-debug style=white-space:pre>';
24+
protected $dumpPrefix = '<pre class=sf-dump style=white-space:pre>';
2525
protected $dumpSuffix = '</pre>';
2626
protected $colors = true;
2727
protected $headerIsDumped = false;
@@ -88,7 +88,7 @@ protected function dumpHeader()
8888
$this->headerIsDumped = true;
8989
$line = $this->line;
9090

91-
$p = 'sf-var-debug';
91+
$p = 'sf-dump';
9292
$this->line = '<!DOCTYPE html><style>';
9393
parent::dumpLine(0);
9494
$this->line .= "a.$p-ref {{$this->styles['ref']}}";
@@ -119,9 +119,9 @@ protected function style($style, $val)
119119
if ('ref' === $style) {
120120
$ref = substr($val, 1);
121121
if ('#' === $val[0]) {
122-
return "<a class=sf-var-debug-ref name=\"sf-var-debug-ref$ref\">$val</a>";
122+
return "<a class=sf-dump-ref name=\"sf-dump-ref$ref\">$val</a>";
123123
} else {
124-
return "<a class=sf-var-debug-ref href=\"#sf-var-debug-ref$ref\">$val</a>";
124+
return "<a class=sf-dump-ref href=\"#sf-dump-ref$ref\">$val</a>";
125125
}
126126
}
127127

@@ -131,12 +131,12 @@ protected function style($style, $val)
131131
foreach (static::$controlChars as $c) {
132132
if (false !== strpos($val, $c)) {
133133
$r = "\x7F" === $c ? '?' : chr(64 + ord($c));
134-
$val = str_replace($c, "<span class=sf-var-debug-cchr>$r</span>", $val);
134+
$val = str_replace($c, "<span class=sf-dump-cchr>$r</span>", $val);
135135
}
136136
}
137137
}
138138

139-
return "<span class=sf-var-debug-$style>$val</span>";
139+
return "<span class=sf-dump-$style>$val</span>";
140140
}
141141

142142
/**
@@ -150,7 +150,7 @@ protected function dumpLine($depth)
150150

151151
switch ($this->lastDepth - $depth) {
152152
case +1: $this->line = '</span>'.$this->line; break;
153-
case -1: $this->line = "<span class=sf-var-debug-$depth>$this->line"; break;
153+
case -1: $this->line = "<span class=sf-dump-$depth>$this->line"; break;
154154
}
155155

156156
if (-1 === $this->lastDepth) {

Tests/HtmlDumperTest.php

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -38,73 +38,73 @@ public function testGet()
3838
$this->assertSame(
3939
<<<EOTXT
4040
<!DOCTYPE html><style>
41-
a.sf-var-debug-ref {color:#444444}
42-
span.sf-var-debug-num {font-weight:bold;color:#0087FF}
43-
span.sf-var-debug-const {font-weight:bold;color:#0087FF}
44-
span.sf-var-debug-str {font-weight:bold;color:#00D7FF}
45-
span.sf-var-debug-cchr {font-style: italic}
46-
span.sf-var-debug-note {color:#D7AF00}
47-
span.sf-var-debug-ref {color:#444444}
48-
span.sf-var-debug-public {color:#008700}
49-
span.sf-var-debug-protected {color:#D75F00}
50-
span.sf-var-debug-private {color:#D70000}
51-
span.sf-var-debug-meta {color:#005FFF}
41+
a.sf-dump-ref {color:#444444}
42+
span.sf-dump-num {font-weight:bold;color:#0087FF}
43+
span.sf-dump-const {font-weight:bold;color:#0087FF}
44+
span.sf-dump-str {font-weight:bold;color:#00D7FF}
45+
span.sf-dump-cchr {font-style: italic}
46+
span.sf-dump-note {color:#D7AF00}
47+
span.sf-dump-ref {color:#444444}
48+
span.sf-dump-public {color:#008700}
49+
span.sf-dump-protected {color:#D75F00}
50+
span.sf-dump-private {color:#D70000}
51+
span.sf-dump-meta {color:#005FFF}
5252
</style>
5353
54-
<pre class=sf-var-debug style=white-space:pre><span class=sf-var-debug-0><span class=sf-var-debug-note>array:25</span> [
55-
<span class=sf-var-debug-1>"<span class=sf-var-debug-meta>number</span>" => <span class=sf-var-debug-const>1</span>
56-
<span class=sf-var-debug-meta>0</span> => <span class=sf-var-debug-const>null</span> <a class=sf-var-debug-ref name="sf-var-debug-ref1">#1</a>
57-
"<span class=sf-var-debug-meta>const</span>" => <span class=sf-var-debug-num>1.1</span>
58-
<span class=sf-var-debug-meta>1</span> => <span class=sf-var-debug-const>true</span>
59-
<span class=sf-var-debug-meta>2</span> => <span class=sf-var-debug-const>false</span>
60-
<span class=sf-var-debug-meta>3</span> => <span class=sf-var-debug-num>NAN</span>
61-
<span class=sf-var-debug-meta>4</span> => <span class=sf-var-debug-num>INF</span>
62-
<span class=sf-var-debug-meta>5</span> => <span class=sf-var-debug-num>-INF</span>
63-
<span class=sf-var-debug-meta>6</span> => <span class=sf-var-debug-const>9223372036854775807</span>
64-
"<span class=sf-var-debug-meta>str</span>" => "<span class=sf-var-debug-str>déjà</span>"
65-
<span class=sf-var-debug-meta>7</span> => b"<span class=sf-var-debug-str>é</span>"
66-
"<span class=sf-var-debug-meta>[]</span>" => []
67-
"<span class=sf-var-debug-meta>res</span>" => resource:<span class=sf-var-debug-note>stream</span> {
68-
<span class=sf-var-debug-2><span class=sf-var-debug-meta>wrapper_type</span>: "<span class=sf-var-debug-str>plainfile</span>"
69-
<span class=sf-var-debug-meta>stream_type</span>: "<span class=sf-var-debug-str>dir</span>"
70-
<span class=sf-var-debug-meta>mode</span>: "<span class=sf-var-debug-str>r</span>"
71-
<span class=sf-var-debug-meta>unread_bytes</span>: <span class=sf-var-debug-const>0</span>
72-
<span class=sf-var-debug-meta>seekable</span>: <span class=sf-var-debug-const>true</span>
73-
<span class=sf-var-debug-meta>timed_out</span>: <span class=sf-var-debug-const>false</span>
74-
<span class=sf-var-debug-meta>blocked</span>: <span class=sf-var-debug-const>true</span>
75-
<span class=sf-var-debug-meta>eof</span>: <span class=sf-var-debug-const>false</span>
76-
<span class=sf-var-debug-meta>options</span>: []
54+
<pre class=sf-dump style=white-space:pre><span class=sf-dump-0><span class=sf-dump-note>array:25</span> [
55+
<span class=sf-dump-1>"<span class=sf-dump-meta>number</span>" => <span class=sf-dump-const>1</span>
56+
<span class=sf-dump-meta>0</span> => <span class=sf-dump-const>null</span> <a class=sf-dump-ref name="sf-dump-ref1">#1</a>
57+
"<span class=sf-dump-meta>const</span>" => <span class=sf-dump-num>1.1</span>
58+
<span class=sf-dump-meta>1</span> => <span class=sf-dump-const>true</span>
59+
<span class=sf-dump-meta>2</span> => <span class=sf-dump-const>false</span>
60+
<span class=sf-dump-meta>3</span> => <span class=sf-dump-num>NAN</span>
61+
<span class=sf-dump-meta>4</span> => <span class=sf-dump-num>INF</span>
62+
<span class=sf-dump-meta>5</span> => <span class=sf-dump-num>-INF</span>
63+
<span class=sf-dump-meta>6</span> => <span class=sf-dump-const>9223372036854775807</span>
64+
"<span class=sf-dump-meta>str</span>" => "<span class=sf-dump-str>déjà</span>"
65+
<span class=sf-dump-meta>7</span> => b"<span class=sf-dump-str>é</span>"
66+
"<span class=sf-dump-meta>[]</span>" => []
67+
"<span class=sf-dump-meta>res</span>" => resource:<span class=sf-dump-note>stream</span> {
68+
<span class=sf-dump-2><span class=sf-dump-meta>wrapper_type</span>: "<span class=sf-dump-str>plainfile</span>"
69+
<span class=sf-dump-meta>stream_type</span>: "<span class=sf-dump-str>dir</span>"
70+
<span class=sf-dump-meta>mode</span>: "<span class=sf-dump-str>r</span>"
71+
<span class=sf-dump-meta>unread_bytes</span>: <span class=sf-dump-const>0</span>
72+
<span class=sf-dump-meta>seekable</span>: <span class=sf-dump-const>true</span>
73+
<span class=sf-dump-meta>timed_out</span>: <span class=sf-dump-const>false</span>
74+
<span class=sf-dump-meta>blocked</span>: <span class=sf-dump-const>true</span>
75+
<span class=sf-dump-meta>eof</span>: <span class=sf-dump-const>false</span>
76+
<span class=sf-dump-meta>options</span>: []
7777
</span>}
78-
<span class=sf-var-debug-meta>8</span> => resource:<span class=sf-var-debug-note>Unknown</span> {}
79-
"<span class=sf-var-debug-meta>obj</span>" => <span class=sf-var-debug-note>Symfony\Component\VarDumper\Tests\Fixture\DumbFoo</span> { <a class=sf-var-debug-ref name="sf-var-debug-ref2">#2</a>
80-
<span class=sf-var-debug-2><span class=sf-var-debug-public>foo</span>: "<span class=sf-var-debug-str>foo</span>"
81-
"<span class=sf-var-debug-public>bar</span>": "<span class=sf-var-debug-str>bar</span>"
78+
<span class=sf-dump-meta>8</span> => resource:<span class=sf-dump-note>Unknown</span> {}
79+
"<span class=sf-dump-meta>obj</span>" => <span class=sf-dump-note>Symfony\Component\VarDumper\Tests\Fixture\DumbFoo</span> { <a class=sf-dump-ref name="sf-dump-ref2">#2</a>
80+
<span class=sf-dump-2><span class=sf-dump-public>foo</span>: "<span class=sf-dump-str>foo</span>"
81+
"<span class=sf-dump-public>bar</span>": "<span class=sf-dump-str>bar</span>"
8282
</span>}
83-
"<span class=sf-var-debug-meta>closure</span>" => <span class=sf-var-debug-note>Closure</span> {
84-
<span class=sf-var-debug-2><span class=sf-var-debug-meta>reflection</span>: """
85-
<span class=sf-var-debug-str>Closure [ &lt;user&gt; {$closureLabel} Symfony\Component\VarDumper\Tests\Fixture\{closure} ] {</span>
86-
<span class=sf-var-debug-str> @@ {$var['file']} {$var['line']} - {$var['line']}</span>
83+
"<span class=sf-dump-meta>closure</span>" => <span class=sf-dump-note>Closure</span> {
84+
<span class=sf-dump-2><span class=sf-dump-meta>reflection</span>: """
85+
<span class=sf-dump-str>Closure [ &lt;user&gt; {$closureLabel} Symfony\Component\VarDumper\Tests\Fixture\{closure} ] {</span>
86+
<span class=sf-dump-str> @@ {$var['file']} {$var['line']} - {$var['line']}</span>
8787
88-
<span class=sf-var-debug-str> - Parameters [2] {</span>
89-
<span class=sf-var-debug-str> Parameter #0 [ &lt;required&gt; \$a ]</span>
90-
<span class=sf-var-debug-str> Parameter #1 [ &lt;optional&gt; PDO or NULL &amp;\$b = NULL ]</span>
91-
<span class=sf-var-debug-str> }</span>
92-
<span class=sf-var-debug-str>}</span>
88+
<span class=sf-dump-str> - Parameters [2] {</span>
89+
<span class=sf-dump-str> Parameter #0 [ &lt;required&gt; \$a ]</span>
90+
<span class=sf-dump-str> Parameter #1 [ &lt;optional&gt; PDO or NULL &amp;\$b = NULL ]</span>
91+
<span class=sf-dump-str> }</span>
92+
<span class=sf-dump-str>}</span>
9393
"""
9494
</span>}
95-
"<span class=sf-var-debug-meta>line</span>" => <span class=sf-var-debug-const>{$var['line']}</span>
96-
"<span class=sf-var-debug-meta>nobj</span>" => <span class=sf-var-debug-note>array:1</span> [
97-
<span class=sf-var-debug-2><span class=sf-var-debug-meta>0</span> => {} <a class=sf-var-debug-ref name="sf-var-debug-ref3">#3</a>
95+
"<span class=sf-dump-meta>line</span>" => <span class=sf-dump-const>{$var['line']}</span>
96+
"<span class=sf-dump-meta>nobj</span>" => <span class=sf-dump-note>array:1</span> [
97+
<span class=sf-dump-2><span class=sf-dump-meta>0</span> => {} <a class=sf-dump-ref name="sf-dump-ref3">#3</a>
9898
</span>]
99-
"<span class=sf-var-debug-meta>recurs</span>" => <span class=sf-var-debug-note>array:1</span> [ <a class=sf-var-debug-ref name="sf-var-debug-ref4">#4</a>
100-
<span class=sf-var-debug-2><span class=sf-var-debug-meta>0</span> => <span class=sf-var-debug-note>array:1</span> [<a class=sf-var-debug-ref href="#sf-var-debug-ref4">&4</a>]
99+
"<span class=sf-dump-meta>recurs</span>" => <span class=sf-dump-note>array:1</span> [ <a class=sf-dump-ref name="sf-dump-ref4">#4</a>
100+
<span class=sf-dump-2><span class=sf-dump-meta>0</span> => <span class=sf-dump-note>array:1</span> [<a class=sf-dump-ref href="#sf-dump-ref4">&4</a>]
101101
</span>]
102-
<span class=sf-var-debug-meta>9</span> => <span class=sf-var-debug-const>null</span> <a class=sf-var-debug-ref href="#sf-var-debug-ref1">&1</a>
103-
"<span class=sf-var-debug-meta>sobj</span>" => <span class=sf-var-debug-note>Symfony\Component\VarDumper\Tests\Fixture\DumbFoo</span> {<a class=sf-var-debug-ref href="#sf-var-debug-ref2">@2</a>}
104-
"<span class=sf-var-debug-meta>snobj</span>" => {<a class=sf-var-debug-ref href="#sf-var-debug-ref3">&3</a>}
105-
"<span class=sf-var-debug-meta>snobj2</span>" => {<a class=sf-var-debug-ref href="#sf-var-debug-ref3">@3</a>}
106-
"<span class=sf-var-debug-meta>file</span>" => "<span class=sf-var-debug-str>{$var['file']}</span>"
107-
b"<span class=sf-var-debug-meta>bin-key-é</span>" => ""
102+
<span class=sf-dump-meta>9</span> => <span class=sf-dump-const>null</span> <a class=sf-dump-ref href="#sf-dump-ref1">&1</a>
103+
"<span class=sf-dump-meta>sobj</span>" => <span class=sf-dump-note>Symfony\Component\VarDumper\Tests\Fixture\DumbFoo</span> {<a class=sf-dump-ref href="#sf-dump-ref2">@2</a>}
104+
"<span class=sf-dump-meta>snobj</span>" => {<a class=sf-dump-ref href="#sf-dump-ref3">&3</a>}
105+
"<span class=sf-dump-meta>snobj2</span>" => {<a class=sf-dump-ref href="#sf-dump-ref3">@3</a>}
106+
"<span class=sf-dump-meta>file</span>" => "<span class=sf-dump-str>{$var['file']}</span>"
107+
b"<span class=sf-dump-meta>bin-key-é</span>" => ""
108108
</span>]
109109
</pre>
110110

0 commit comments

Comments
 (0)