Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commite54e219

Browse files
committed
[VarDumper] Use hyperlinks in CliDescriptor
1 parentf2590d1 commite54e219

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

‎src/Symfony/Component/VarDumper/Command/Descriptor/CliDescriptor.php‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespaceSymfony\Component\VarDumper\Command\Descriptor;
1313

14+
useSymfony\Component\Console\Formatter\OutputFormatterStyle;
1415
useSymfony\Component\Console\Input\ArrayInput;
1516
useSymfony\Component\Console\Output\OutputInterface;
1617
useSymfony\Component\Console\Style\SymfonyStyle;
@@ -28,10 +29,12 @@ class CliDescriptor implements DumpDescriptorInterface
2829
{
2930
private$dumper;
3031
private$lastIdentifier;
32+
private$supportsHref;
3133

3234
publicfunction__construct(CliDumper$dumper)
3335
{
3436
$this->dumper =$dumper;
37+
$this->supportsHref =method_exists(OutputFormatterStyle::class,'setHref');
3538
}
3639

3740
publicfunctiondescribe(OutputInterface$output,Data$data,array$context,int$clientId):void
@@ -62,15 +65,19 @@ public function describe(OutputInterface $output, Data $data, array $context, in
6265

6366
if (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
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp