@@ -40,8 +40,15 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
4040
4141 public function __construct (Stopwatch $ stopwatch = null , $ fileLinkFormat = null , $ charset = null , RequestStack $ requestStack = null , DataDumperInterface $ dumper = null )
4242 {
43+ $ fileLinkFormat = $ fileLinkFormat ?: ini_get ('xdebug.file_link_format ' ) ?: get_cfg_var ('xdebug.file_link_format ' );
44+ if ($ fileLinkFormat && !is_array ($ fileLinkFormat )) {
45+ $ i = max (strpos ($ fileLinkFormat , '%f ' ), strpos ($ fileLinkFormat , '%l ' ));
46+ $ i = strpos ($ fileLinkFormat , '# ' , $ i ) ?: strlen ($ fileLinkFormat );
47+ $ fileLinkFormat = array (substr ($ fileLinkFormat , 0 , $ i ), substr ($ fileLinkFormat , $ i + 1 ));
48+ parse_str ($ fileLinkFormat [1 ], $ fileLinkFormat [1 ]);
49+ }
4350 $ this ->stopwatch = $ stopwatch ;
44- $ this ->fileLinkFormat = $ fileLinkFormat ?: ini_get ( ' xdebug.file_link_format ' ) ?: get_cfg_var ( ' xdebug.file_link_format ' ) ;
51+ $ this ->fileLinkFormat = $ fileLinkFormat ;
4552 $ this ->charset = $ charset ?: ini_get ('php.output_encoding ' ) ?: ini_get ('default_charset ' ) ?: 'UTF-8 ' ;
4653 $ this ->requestStack = $ requestStack ;
4754 $ this ->dumper = $ dumper ;
@@ -149,6 +156,7 @@ public function collect(Request $request, Response $response, \Exception $except
149156 ) {
150157 if ($ response ->headers ->has ('Content-Type ' ) && false !== strpos ($ response ->headers ->get ('Content-Type ' ), 'html ' )) {
151158 $ this ->dumper = new HtmlDumper ('php://output ' , $ this ->charset );
159+ $ this ->dumper ->setDisplayOptions (array ('fileLinkFormat ' => $ this ->fileLinkFormat ));
152160 } else {
153161 $ this ->dumper = new CliDumper ('php://output ' , $ this ->charset );
154162 }
@@ -198,6 +206,7 @@ public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1)
198206
199207 if ('html ' === $ format ) {
200208 $ dumper = new HtmlDumper ($ data , $ this ->charset );
209+ $ dumper ->setDisplayOptions (array ('fileLinkFormat ' => $ this ->fileLinkFormat ));
201210 } else {
202211 throw new \InvalidArgumentException (sprintf ('Invalid dump format: %s ' , $ format ));
203212 }
@@ -234,6 +243,7 @@ public function __destruct()
234243
235244 if ('cli ' !== PHP_SAPI && stripos ($ h [$ i ], 'html ' )) {
236245 $ this ->dumper = new HtmlDumper ('php://output ' , $ this ->charset );
246+ $ dumper ->setDisplayOptions (array ('fileLinkFormat ' => $ this ->fileLinkFormat ));
237247 } else {
238248 $ this ->dumper = new CliDumper ('php://output ' , $ this ->charset );
239249 }
@@ -258,7 +268,13 @@ private function doDump($data, $name, $file, $line)
258268 $ name = strip_tags ($ this ->style ('' , $ name ));
259269 $ file = strip_tags ($ this ->style ('' , $ file ));
260270 if ($ fileLinkFormat ) {
261- $ link = strtr (strip_tags ($ this ->style ('' , $ fileLinkFormat )), array ('%f ' => $ file , '%l ' => (int ) $ line ));
271+ foreach ($ fileLinkFormat [1 ] as $ k => $ v ) {
272+ if (0 === strpos ($ file , $ k )) {
273+ $ file = substr_replace ($ file , $ v , 0 , strlen ($ k ));
274+ break ;
275+ }
276+ }
277+ $ link = strtr (strip_tags ($ this ->style ('' , $ fileLinkFormat [0 ])), array ('%f ' => $ file , '%l ' => (int ) $ line ));
262278 $ name = sprintf ('<a href="%s" title="%s"> ' .$ s .'</a> ' , $ link , $ file , $ name );
263279 } else {
264280 $ name = sprintf ('<abbr title="%s"> ' .$ s .'</abbr> ' , $ file , $ name );
0 commit comments