Skip to content

[VarDumper] Backport type fixes #42934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,16 @@ abstract class AbstractCloner implements ClonerInterface
protected $maxString = -1;
protected $minDepth = 1;

/**
* @var array<string, list<callable>>
*/
private $casters = [];

/**
* @var callable|null
*/
private $prevErrorHandler;

private $classInfo = [];
private $filter = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

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;
Expand All @@ -29,12 +28,10 @@ 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
Expand Down Expand Up @@ -66,8 +63,7 @@ public function describe(OutputInterface $output, Data $data, array $context, in
if (isset($context['source'])) {
$source = $context['source'];
$sourceInfo = sprintf('%s on line %d', $source['name'], $source['line']);
$fileLink = $source['file_link'] ?? null;
if ($this->supportsHref && $fileLink) {
if ($fileLink = $source['file_link'] ?? null) {
$sourceInfo = sprintf('<href=%s>%s</>', $fileLink, $sourceInfo);
}
$rows[] = ['source', $sourceInfo];
Expand All @@ -77,11 +73,6 @@ public function describe(OutputInterface $output, Data $data, array $context, in

$io->table([], $rows);

if (!$this->supportsHref && isset($fileLink)) {
$io->writeln(['<info>Open source in your IDE/browser:</info>', $fileLink]);
$io->newLine();
}

$this->dumper->dump($data);
$io->newLine();
}
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/VarDumper/Server/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class Connection
{
private $host;
private $contextProviders;

/**
* @var resource|null
*/
private $socket;

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Symfony/Component/VarDumper/Server/DumpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@
class DumpServer
{
private $host;
private $socket;
private $logger;

/**
* @var resource|null
*/
private $socket;

public function __construct(string $host, LoggerInterface $logger = null)
{
if (!str_contains($host, '://')) {
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/VarDumper/VarDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
*/
class VarDumper
{
/**
* @var callable|null
*/
private static $handler;

public static function dump($var)
Expand All @@ -43,6 +46,9 @@ public static function dump($var)
return (self::$handler)($var);
}

/**
* @return callable|null
*/
public static function setHandler(callable $callable = null)
{
$prevHandler = self::$handler;
Expand Down