@@ -59,6 +59,7 @@ public function __construct($output = null, $charset = null, $flags = 0)
5959 {
60 60 AbstractDumper::__construct ($ output , $ charset , $ flags );
6161 $ this ->dumpId = 'sf-dump- ' .mt_rand ();
62+ $ this ->displayOptions ['fileLinkFormat ' ] = ini_get ('xdebug.file_link_format ' ) ?: get_cfg_var ('xdebug.file_link_format ' );
6263 }
6364
6465 /**
@@ -189,18 +190,14 @@ function toggle(a, recursive) {
189190 options = {$options},
190191 elt = root.getElementsByTagName('A'),
191192 len = elt.length,
192- i = 0, s, h, fmt,
193+ i = 0, s, h,
193194 t = [];
194195
195196 while (i < len) t.push(elt[i++]);
196197
197198 for (i in x) {
198199 options[i] = x[i];
199200 }
200- fmt = options.fileLinkFormat;
201- if (fmt && 'string' == typeof fmt) {
202- fmt = [fmt];
203- }
204201
205202 function a(e, f) {
206203 addEventListener(root, e, function (e) {
@@ -221,8 +218,10 @@ function isCtrlKey(e) {
221218 refStyle.innerHTML = '';
222219 }
223220 });
224- a('mouseover', function (a) {
225- if (a = idRx.exec(a.className)) {
221+ a('mouseover', function (a, e, c) {
222+ if (c) {
223+ e.target.style.cursor = "pointer";
224+ } else if (a = idRx.exec(a.className)) {
226225 try {
227226 refStyle.innerHTML = 'pre.sf-dump .'+a[0]+'{background-color: #B729D9; color: #FFF !important; border-radius: 2px}';
228227 } catch (e) {
@@ -321,16 +320,6 @@ function isCtrlKey(e) {
321320 }
322321 }
323322 }
324- } else if (fmt && (a = elt.getAttribute('data-file'))) {
325- if (fmt[1]) {
326- for (x in fmt[1]) {
327- if (0 === a.indexOf(x)) {
328- a = fmt[1][x] + a.substr(x.length);
329- break;
330- }
331- }
332- }
333- elt.href = fmt[0].replace('%l', elt.getAttribute('data-line')).replace('%f', a);
334323 }
335324 }
336325
@@ -391,7 +380,7 @@ function isCtrlKey(e) {
391380 display: inline-block;
392381 overflow: visible;
393382 text-overflow: ellipsis;
394- width: 50px ;
383+ width: 5em ;
395384 white-space: nowrap;
396385 overflow: hidden;
397386 vertical-align: top;
@@ -411,7 +400,7 @@ function isCtrlKey(e) {
411400 );
412401
413402 foreach ($ this ->styles as $ class => $ style ) {
414- $ line .= 'pre.sf-dump ' .('default ' !== $ class ? ' .sf-dump- ' . $ class : '' ).'{ ' .$ style .'} ' ;
403+ $ line .= 'pre.sf-dump ' .('default ' === $ class ? ', pre .sf-dump' : '' ). ' .sf-dump- ' . $ class .'{ ' .$ style .'} ' ;
415404 }
416405
417406 return $ this ->dumpHeader = preg_replace ('/\s+/ ' , ' ' , $ line ).'</style> ' .$ this ->dumpHeader ;
@@ -485,37 +474,27 @@ protected function style($style, $value, $attr = array())
485474 $ style .= sprintf (' title="Private property defined in class: `%s`" ' , esc ($ this ->utf8Encode ($ attr ['class ' ])));
486475 }
487476 $ map = static ::$ controlCharsMap ;
488- $ style = "<span class=sf-dump- {$ style }> " ;
489477
490478 if (isset ($ attr ['ellipsis ' ])) {
491479 $ label = esc (substr ($ value , -$ attr ['ellipsis ' ]));
492-
493- $ v = sprintf ('</ span>%s<abbr title="%s" class=sf-dump-ellipsis>%2$ s</abbr>%s</ span>%1$s ' , $ style , substr ($ v , 0 , -strlen ($ label )), $ label );
480+ $ style = str_replace ( ' title=" ' , " title= \" $ v \n" , $ style );
481+ $ v = sprintf ('<span class=sf-dump-ellipsis>%s</span>%s ' , substr ($ v , 0 , -strlen ($ label )), $ label );
494482 }
495483
496- $ v = preg_replace_callback (static ::$ controlCharsRx , function ($ c ) use ($ map, $ style ) {
497- $ s = '</ span> ' ;
484+ $ v = " <span class=sf-dump- { $ style } > " . preg_replace_callback (static ::$ controlCharsRx , function ($ c ) use ($ map ) {
485+ $ s = '<span class=sf-dump-default > ' ;
498486 $ c = $ c [$ i = 0 ];
499487 do {
500488 $ s .= isset ($ map [$ c [$ i ]]) ? $ map [$ c [$ i ]] : sprintf ('\x%02X ' , ord ($ c [$ i ]));
501489 } while (isset ($ c [++$ i ]));
502490
503- return $ s .$ style ;
504- }, $ v, - 1 , $ cchrCount ) ;
491+ return $ s .' </span> ' ;
492+ }, $ v). ' </span> ' ;
505493
506- if ('< ' === $ v [0 ]) {
507- $ v = substr ($ v , 7 );
508- } else {
509- $ v = $ style .$ v ;
510- }
511- if ('> ' === substr ($ v , -1 )) {
512- $ v = substr ($ v , 0 , -strlen ($ style ));
513- } else {
514- $ v .= '</span> ' ;
494+ if (isset ($ attr ['file ' ]) && $ href = $ this ->getSourceLink ($ attr ['file ' ], isset ($ attr ['line ' ]) ? $ attr ['line ' ] : 0 )) {
495+ $ attr ['href ' ] = $ href ;
515496 }
516- if (isset ($ attr ['file ' ])) {
517- $ v = sprintf ('<a data-file="%s" data-line="%d">%s</a> ' , esc ($ this ->utf8Encode ($ attr ['file ' ])), isset ($ attr ['line ' ]) ? $ attr ['line ' ] : 1 , $ v );
518- } elseif (isset ($ attr ['href ' ])) {
497+ if (isset ($ attr ['href ' ])) {
519498 $ v = sprintf ('<a href="%s">%s</a> ' , esc ($ this ->utf8Encode ($ attr ['href ' ])), $ v );
520499 }
521500 if (isset ($ attr ['lang ' ])) {
@@ -554,6 +533,31 @@ protected function dumpLine($depth, $endOfValue = false)
554533 }
555534 AbstractDumper::dumpLine ($ depth );
556535 }
536+
537+ private function getSourceLink ($ file , $ line )
538+ {
539+ $ fileLinkFormat = $ this ->extraDisplayOptions + $ this ->displayOptions ;
540+
541+ if (!$ fileLinkFormat = $ fileLinkFormat ['fileLinkFormat ' ]) {
542+ return false ;
543+ }
544+ if (!is_array ($ fileLinkFormat )) {
545+ $ i = max (strpos ($ fileLinkFormat , '%f ' ), strpos ($ fileLinkFormat , '%l ' ));
546+ $ i = strpos ($ fileLinkFormat , '#" ' , $ i ) ?: strlen ($ fileLinkFormat );
547+ $ fileLinkFormat = array (substr ($ fileLinkFormat , 0 , $ i ), substr ($ fileLinkFormat , $ i + 1 ));
548+ $ fileLinkFormat [1 ] = @json_decode ('{ ' .$ fileLinkFormat [1 ].'} ' , true ) ?: array ();
549+ $ this ->extraDisplayOptions ['fileLinkFormat ' ] = $ fileLinkFormat ;
550+ }
551+
552+ foreach ($ fileLinkFormat [1 ] as $ k => $ v ) {
553+ if (0 === strpos ($ file , $ k )) {
554+ $ file = substr_replace ($ file , $ v , 0 , strlen ($ k ));
555+ break ;
556+ }
557+ }
558+
559+ return strtr ($ fileLinkFormat [0 ], array ('%f ' => $ file , '%l ' => $ line ));
560+ }
557561}
558562
559563function esc ($ str )
0 commit comments