From e54e21933a15d1222126dc8a5ec2a3e073548c8d Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Fri, 14 Dec 2018 16:36:24 +0100 Subject: [PATCH] [VarDumper] Use hyperlinks in CliDescriptor --- .../VarDumper/Command/Descriptor/CliDescriptor.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/VarDumper/Command/Descriptor/CliDescriptor.php b/src/Symfony/Component/VarDumper/Command/Descriptor/CliDescriptor.php index 1422960ce1187..74c1bc8b4c96c 100644 --- a/src/Symfony/Component/VarDumper/Command/Descriptor/CliDescriptor.php +++ b/src/Symfony/Component/VarDumper/Command/Descriptor/CliDescriptor.php @@ -11,6 +11,7 @@ namespace Symfony\Component\VarDumper\Command\Descriptor; +use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; @@ -28,10 +29,12 @@ class CliDescriptor implements DumpDescriptorInterface { private $dumper; private $lastIdentifier; + private $supportsHref; public function __construct(CliDumper $dumper) { $this->dumper = $dumper; + $this->supportsHref = method_exists(OutputFormatterStyle::class, 'setHref'); } public 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 if (isset($context['source'])) { $source = $context['source']; - $rows[] = array('source', sprintf('%s on line %d', $source['name'], $source['line'])); + $sourceInfo = sprintf('%s on line %d', $source['name'], $source['line']); + $fileLink = $source['file_link'] ?? null; + if ($this->supportsHref && $fileLink) { + $sourceInfo = sprintf('%s', $fileLink, $sourceInfo); + } + $rows[] = array('source', $sourceInfo); $file = $source['file_relative'] ?? $source['file']; $rows[] = array('file', $file); - $fileLink = $source['file_link'] ?? null; } $io->table(array(), $rows); - if (isset($fileLink)) { + if (!$this->supportsHref && isset($fileLink)) { $io->writeln(array('Open source in your IDE/browser:', $fileLink)); $io->newLine(); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy