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

Commit5f737e8

Browse files
feature#29613 [VarDumper] Use hyperlinks in CliDescriptor (ogizanagi)
This PR was merged into the 4.3-dev branch.Discussion----------[VarDumper] Use hyperlinks in CliDescriptor| Q | A| ------------- | ---| Branch? | master <!-- see below -->| Bug fix? | no| New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks? | no <!-- seehttps://symfony.com/bc -->| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tests pass? | yes <!-- please add some, will be required by reviewers -->| Fixed tickets | Part of#29585 <!-- #-prefixed issue number(s), if any -->| License | MIT| Doc PR | N/ALeverages#29168 to add the hyperlink directly on the source text instead of printing below:#### Before (or with `symfony/console < 4.3`)![capture d ecran 2018-12-14 a 16 37 18](https://user-images.githubusercontent.com/2211145/50012891-1e2efe00-ffc0-11e8-9e07-b5358cb057bd.png)#### After![capture d ecran 2018-12-14 a 16 12 13](https://user-images.githubusercontent.com/2211145/50012921-25560c00-ffc0-11e8-92cd-d6efd43419f9.png)Commits-------e54e219 [VarDumper] Use hyperlinks in CliDescriptor
2 parents5511377 +e54e219 commit5f737e8

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