1111
1212namespace Symfony \Component \VarDumper \Command \Descriptor ;
1313
14+ use Symfony \Component \Console \Formatter \OutputFormatterStyle ;
1415use Symfony \Component \Console \Input \ArrayInput ;
1516use Symfony \Component \Console \Output \OutputInterface ;
1617use Symfony \Component \Console \Style \SymfonyStyle ;
@@ -28,10 +29,12 @@ class CliDescriptor implements DumpDescriptorInterface
2829{
2930private $ dumper ;
3031private $ lastIdentifier ;
32+ private $ supportsHref ;
3133
3234public function __construct (CliDumper $ dumper )
3335 {
3436$ this ->dumper =$ dumper ;
37+ $ this ->supportsHref =method_exists (OutputFormatterStyle::class,'setHref ' );
3538 }
3639
3740public function describe (OutputInterface $ output ,Data $ data ,array $ context ,int $ clientId ):void
@@ -62,15 +65,19 @@ public function describe(OutputInterface $output, Data $data, array $context, in
6265
6366if (isset ($ context ['source ' ])) {
6467$ source =$ context ['source ' ];
65- $ rows [] =array ('source ' ,sprintf ('%s on line %d ' ,$ source ['name ' ],$ source ['line ' ]));
68+ $ sourceInfo =sprintf ('%s on line %d ' ,$ source ['name ' ],$ source ['line ' ]);
69+ $ fileLink =$ source ['file_link ' ] ??null ;
70+ if ($ this ->supportsHref &&$ fileLink ) {
71+ $ sourceInfo =sprintf ('<href=%s>%s</> ' ,$ fileLink ,$ sourceInfo );
72+ }
73+ $ rows [] =array ('source ' ,$ sourceInfo );
6674$ file =$ source ['file_relative ' ] ??$ source ['file ' ];
6775$ rows [] =array ('file ' ,$ file );
68- $ fileLink =$ source ['file_link ' ] ??null ;
6976 }
7077
7178$ io ->table (array (),$ rows );
7279
73- if (isset ($ fileLink )) {
80+ if (! $ this -> supportsHref && isset ($ fileLink )) {
7481$ io ->writeln (array ('<info>Open source in your IDE/browser:</info> ' ,$ fileLink ));
7582$ io ->newLine ();
7683 }