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

Appearance settings

Commit 8aa708e

Browse filesBrowse files
committed
feature #33486 [VarDumper] Display fully qualified title (pavinthan, nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [VarDumper] Display fully qualified title | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | We can see the objects with namespace that help us to navigate to the file easily. Before: These are diffrent Collection class <img width="203" alt="Screen Shot 2019-09-06 at 1 02 37 PM" src="https://user-images.githubusercontent.com/13897936/64410319-663f0500-d0a8-11e9-98d5-743e2ccf2737.png"> Now: we can see the diffrent <img width="376" alt="Screen Shot 2019-09-06 at 1 02 20 PM" src="https://user-images.githubusercontent.com/13897936/64410304-60e1ba80-d0a8-11e9-9cb1-f88c0f8c3de9.png"> Commits ------- a8252a2 [VarDumper] display ellipsed FQCN for nested classes 84682ea [VarDumper] Display fully qualified title
2 parents 4234601 + a8252a2 commit 8aa708e
Copy full SHA for 8aa708e

File tree

4 files changed

+32
-27
lines changed
Filter options

4 files changed

+32
-27
lines changed

‎src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
+21-19Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,16 @@ function a(e, f) {
319319
f(e.target, e);
320320
} else if ('A' == e.target.parentNode.tagName) {
321321
f(e.target.parentNode, e);
322-
} else if ((n = e.target.nextElementSibling) && 'A' == n.tagName) {
323-
if (!/\bsf-dump-toggle\b/.test(n.className)) {
324-
n = n.nextElementSibling;
325-
}
322+
} else {
323+
n = /\bsf-dump-ellipsis\b/.test(e.target.className) ? e.target.parentNode : e.target;
324+
325+
if ((n = n.nextElementSibling) && 'A' == n.tagName) {
326+
if (!/\bsf-dump-toggle\b/.test(n.className)) {
327+
n = n.nextElementSibling || n;
328+
}
326329
327-
f(n, e, true);
330+
f(n, e, true);
331+
}
328332
}
329333
});
330334
};
@@ -670,11 +674,6 @@ function showCurrent(state)
670674
pre.sf-dump .sf-dump-compact {
671675
display: none;
672676
}
673-
pre.sf-dump abbr {
674-
text-decoration: none;
675-
border: none;
676-
cursor: help;
677-
}
678677
pre.sf-dump a {
679678
text-decoration: none;
680679
cursor: pointer;
@@ -795,6 +794,7 @@ function showCurrent(state)
795794
foreach ($this->styles as $class => $style) {
796795
$line .= 'pre.sf-dump'.('default' === $class ? ', pre.sf-dump' : '').' .sf-dump-'.$class.'{'.$style.'}';
797796
}
797+
$line .= 'pre.sf-dump .sf-dump-ellipsis-note{'.$this->styles['note'].'}';
798798

799799
return $this->dumpHeader = preg_replace('/\s+/', ' ', $line).'</style>'.$this->dumpHeader;
800800
}
@@ -821,6 +821,9 @@ public function dumpString(Cursor $cursor, $str, $bin, $cut)
821821
*/
822822
public function enterHash(Cursor $cursor, $type, $class, $hasChild)
823823
{
824+
if (Cursor::HASH_OBJECT === $type) {
825+
$cursor->attr['depth'] = $cursor->depth;
826+
}
824827
parent::enterHash($cursor, $type, $class, false);
825828

826829
if ($cursor->skipChildren) {
@@ -884,14 +887,13 @@ protected function style($style, $value, $attr = [])
884887
$style .= sprintf(' title="%s"', empty($attr['dynamic']) ? 'Public property' : 'Runtime added dynamic property');
885888
} elseif ('str' === $style && 1 < $attr['length']) {
886889
$style .= sprintf(' title="%d%s characters"', $attr['length'], $attr['binary'] ? ' binary or non-UTF-8' : '');
887-
} elseif ('note' === $style && false !== $c = strrpos($v, '\\')) {
888-
if (isset($attr['file']) && $link = $this->getSourceLink($attr['file'], isset($attr['line']) ? $attr['line'] : 0)) {
889-
$link = sprintf('<a href="%s" rel="noopener noreferrer">^</a>', esc($this->utf8Encode($link)));
890-
} else {
891-
$link = '';
892-
}
893-
894-
return sprintf('<abbr title="%s" class=sf-dump-%s>%s</abbr>%s', $v, $style, substr($v, $c + 1), $link);
890+
} elseif ('note' === $style && 0 < ($attr['depth'] ?? 0) && false !== $c = strrpos($value, '\\')) {
891+
$style .= ' title=""';
892+
$attr += [
893+
'ellipsis' => \strlen($value) - $c,
894+
'ellipsis-type' => 'note',
895+
'ellipsis-tail' => 1,
896+
];
895897
} elseif ('protected' === $style) {
896898
$style .= ' title="Protected property"';
897899
} elseif ('meta' === $style && isset($attr['title'])) {
@@ -912,7 +914,7 @@ protected function style($style, $value, $attr = [])
912914

913915
if (!empty($attr['ellipsis-tail'])) {
914916
$tail = \strlen(esc(substr($value, -$attr['ellipsis'], $attr['ellipsis-tail'])));
915-
$v .= sprintf('<span class=sf-dump-ellipsis>%s</span>%s', substr($label, 0, $tail), substr($label, $tail));
917+
$v .= sprintf('<span class=%s>%s</span>%s', $class, substr($label, 0, $tail), substr($label, $tail));
916918
} else {
917919
$v .= $label;
918920
}

‎src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ public function testHtmlDump()
142142
#<span class=sf-dump-protected title="Protected property">message</span>: "<span class=sf-dump-str>1</span>"
143143
#<span class=sf-dump-protected title="Protected property">code</span>: <span class=sf-dump-num>0</span>
144144
#<span class=sf-dump-protected title="Protected property">file</span>: "<span class=sf-dump-str title="%sExceptionCasterTest.php
145-
%d characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class=sf-dump-ellipsis>%e</span>Tests%eCaster%eExceptionCasterTest.php</span>"
145+
%d characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%e</span>Tests%eCaster%eExceptionCasterTest.php</span>"
146146
#<span class=sf-dump-protected title="Protected property">line</span>: <span class=sf-dump-num>28</span>
147147
<span class=sf-dump-meta>trace</span>: {<samp>
148148
<span class=sf-dump-meta title="%sExceptionCasterTest.php
149-
Stack level %d."><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class=sf-dump-ellipsis>%e</span>Tests%eCaster%eExceptionCasterTest.php</span>:<span class=sf-dump-num>28</span>
149+
Stack level %d."><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%e</span>Tests%eCaster%eExceptionCasterTest.php</span>:<span class=sf-dump-num>28</span>
150150
&hellip;%d
151151
</samp>}
152152
</samp>}

‎src/Symfony/Component/VarDumper/Tests/Caster/StubCasterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/Caster/StubCasterTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function testClassStubWithNotExistingClass()
162162
$expectedDump = <<<'EODUMP'
163163
<foo></foo><bar><span class=sf-dump-note>array:1</span> [<samp>
164164
<span class=sf-dump-index>0</span> => "<span class=sf-dump-str title="Symfony\Component\VarDumper\Tests\Caster\NotExisting
165-
52 characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-class">Symfony\Component\VarDumper\Tests\Caster</span><span class=sf-dump-ellipsis>\</span>NotExisting</span>"
165+
52 characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-class">Symfony\Component\VarDumper\Tests\Caster</span><span class="sf-dump-ellipsis sf-dump-ellipsis-class">\</span>NotExisting</span>"
166166
</samp>]
167167
</bar>
168168
EODUMP;

‎src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,18 @@ public function testGet()
7878
<span class=sf-dump-meta>seekable</span>: <span class=sf-dump-const>true</span>
7979
%A <span class=sf-dump-meta>options</span>: []
8080
</samp>}
81-
"<span class=sf-dump-key>obj</span>" => <abbr title="Symfony\Component\VarDumper\Tests\Fixture\DumbFoo" class=sf-dump-note>DumbFoo</abbr> {<a class=sf-dump-ref href=#{$dumpId}-ref2%d title="2 occurrences">#%d</a><samp id={$dumpId}-ref2%d>
81+
"<span class=sf-dump-key>obj</span>" => <span class=sf-dump-note title="Symfony\Component\VarDumper\Tests\Fixture\DumbFoo
82+
"><span class="sf-dump-ellipsis sf-dump-ellipsis-note">Symfony\Component\VarDumper\Tests\Fixture</span><span class="sf-dump-ellipsis sf-dump-ellipsis-note">\</span>DumbFoo</span> {<a class=sf-dump-ref href=#{$dumpId}-ref2%d title="2 occurrences">#%d</a><samp id={$dumpId}-ref2%d>
8283
+<span class=sf-dump-public title="Public property">foo</span>: "<span class=sf-dump-str title="3 characters">foo</span>"
8384
+"<span class=sf-dump-public title="Runtime added dynamic property">bar</span>": "<span class=sf-dump-str title="3 characters">bar</span>"
8485
</samp>}
8586
"<span class=sf-dump-key>closure</span>" => <span class=sf-dump-note>Closure(\$a, PDO &amp;\$b = null)</span> {<a class=sf-dump-ref>#%d</a><samp>
8687
<span class=sf-dump-meta>class</span>: "<span class=sf-dump-str title="Symfony\Component\VarDumper\Tests\Dumper\HtmlDumperTest
87-
55 characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-class">Symfony\Component\VarDumper\Tests\Dumper</span><span class=sf-dump-ellipsis>\</span>HtmlDumperTest</span>"
88-
<span class=sf-dump-meta>this</span>: <abbr title="Symfony\Component\VarDumper\Tests\Dumper\HtmlDumperTest" class=sf-dump-note>HtmlDumperTest</abbr> {<a class=sf-dump-ref>#%d</a> &%s;}
88+
55 characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-class">Symfony\Component\VarDumper\Tests\Dumper</span><span class="sf-dump-ellipsis sf-dump-ellipsis-class">\</span>HtmlDumperTest</span>"
89+
<span class=sf-dump-meta>this</span>: <span class=sf-dump-note title="Symfony\Component\VarDumper\Tests\Dumper\HtmlDumperTest
90+
"><span class="sf-dump-ellipsis sf-dump-ellipsis-note">Symfony\Component\VarDumper\Tests\Dumper</span><span class="sf-dump-ellipsis sf-dump-ellipsis-note">\</span>HtmlDumperTest</span> {<a class=sf-dump-ref>#%d</a> &%s;}
8991
<span class=sf-dump-meta>file</span>: "<span class=sf-dump-str title="{$var['file']}
90-
%d characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class=sf-dump-ellipsis>%e</span>Tests%eFixtures%edumb-var.php</span>"
92+
%d characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%e</span>Tests%eFixtures%edumb-var.php</span>"
9193
<span class=sf-dump-meta>line</span>: "<span class=sf-dump-str title="%d characters">{$var['line']} to {$var['line']}</span>"
9294
</samp>}
9395
"<span class=sf-dump-key>line</span>" => <span class=sf-dump-num>{$var['line']}</span>
@@ -98,7 +100,8 @@ public function testGet()
98100
<span class=sf-dump-index>0</span> => <a class=sf-dump-ref href=#{$dumpId}-ref04 title="2 occurrences">&amp;4</a> <span class=sf-dump-note>array:1</span> [<a class=sf-dump-ref href=#{$dumpId}-ref04 title="2 occurrences">&amp;4</a>]
99101
</samp>]
100102
<span class=sf-dump-key>8</span> => <a class=sf-dump-ref href=#{$dumpId}-ref01 title="2 occurrences">&amp;1</a> <span class=sf-dump-const>null</span>
101-
"<span class=sf-dump-key>sobj</span>" => <abbr title="Symfony\Component\VarDumper\Tests\Fixture\DumbFoo" class=sf-dump-note>DumbFoo</abbr> {<a class=sf-dump-ref href=#{$dumpId}-ref2%d title="2 occurrences">#%d</a>}
103+
"<span class=sf-dump-key>sobj</span>" => <span class=sf-dump-note title="Symfony\Component\VarDumper\Tests\Fixture\DumbFoo
104+
"><span class="sf-dump-ellipsis sf-dump-ellipsis-note">Symfony\Component\VarDumper\Tests\Fixture</span><span class="sf-dump-ellipsis sf-dump-ellipsis-note">\</span>DumbFoo</span> {<a class=sf-dump-ref href=#{$dumpId}-ref2%d title="2 occurrences">#%d</a>}
102105
"<span class=sf-dump-key>snobj</span>" => <a class=sf-dump-ref href=#{$dumpId}-ref03 title="2 occurrences">&amp;3</a> {<a class=sf-dump-ref href=#{$dumpId}-ref2%d title="3 occurrences">#%d</a>}
103106
"<span class=sf-dump-key>snobj2</span>" => {<a class=sf-dump-ref href=#{$dumpId}-ref2%d title="3 occurrences">#%d</a>}
104107
"<span class=sf-dump-key>file</span>" => "<span class=sf-dump-str title="%d characters">{$var['file']}</span>"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.