Skip to content

[VarDumper] Add types to private properties #42933

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
2 changes: 1 addition & 1 deletion src/Symfony/Component/VarDumper/Caster/ArgsStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class ArgsStub extends EnumStub
{
private static $parameters = [];
private static array $parameters = [];

public function __construct(array $args, string $function, ?string $class)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ExceptionCaster
\E_STRICT => 'E_STRICT',
];

private static $framesCache = [];
private static array $framesCache = [];

public static function castError(\Error $e, array $a, Stub $stub, bool $isNested, int $filter = 0)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/VarDumper/Caster/LinkStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class LinkStub extends ConstStub
{
public $inVendor = false;

private static $vendorRoots;
private static $composerRoots;
private static array $vendorRoots;
private static array $composerRoots = [];

public function __construct(string $label, int $line = 0, string $href = null)
{
Expand Down Expand Up @@ -65,7 +65,7 @@ public function __construct(string $label, int $line = 0, string $href = null)

private function getComposerRoot(string $file, bool &$inVendor)
{
if (null === self::$vendorRoots) {
if (!isset(self::$vendorRoots)) {
self::$vendorRoots = [];

foreach (get_declared_classes() as $class) {
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/VarDumper/Caster/MemcachedCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/
class MemcachedCaster
{
private static $optionConstants;
private static $defaultOptions;
private static array $optionConstants;
private static array $defaultOptions;

public static function castMemcached(\Memcached $c, array $a, Stub $stub, bool $isNested)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,15 @@ abstract class AbstractCloner implements ClonerInterface
/**
* @var array<string, list<callable>>
*/
private $casters = [];
private array $casters = [];

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

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

/**
* @param callable[]|null $casters A map of casters
Expand Down
14 changes: 7 additions & 7 deletions src/Symfony/Component/VarDumper/Cloner/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
*/
class Data implements \ArrayAccess, \Countable, \IteratorAggregate
{
private $data;
private $position = 0;
private $key = 0;
private $maxDepth = 20;
private $maxItemsPerDepth = -1;
private $useRefHandles = -1;
private $context = [];
private array $data;
private int $position = 0;
private int|string $key = 0;
private int $maxDepth = 20;
private int $maxItemsPerDepth = -1;
private int $useRefHandles = -1;
private array $context = [];

/**
* @param array $data An array as returned by ClonerInterface::cloneVar()
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/VarDumper/Cloner/Stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Stub
public $position = 0;
public $attr = [];

private static $defaultProperties = [];
private static array $defaultProperties = [];

/**
* @internal
Expand Down
8 changes: 3 additions & 5 deletions src/Symfony/Component/VarDumper/Cloner/VarCloner.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
class VarCloner extends AbstractCloner
{
private static $gid;
private static $arrayCache = [];
private static string $gid;
private static array $arrayCache = [];

/**
* {@inheritdoc}
Expand All @@ -44,9 +44,7 @@ protected function doClone(mixed $var): array
$stub = null; // Stub capturing the main properties of an original item value
// or null if the original value is used directly

if (!$gid = self::$gid) {
$gid = self::$gid = md5(random_bytes(6)); // Unique string used to detect the special $GLOBALS variable
}
$gid = self::$gid ??= md5(random_bytes(6)); // Unique string used to detect the special $GLOBALS variable
$arrayStub = new Stub();
$arrayStub->type = Stub::TYPE_ARRAY;
$fromObjCast = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/
class CliDescriptor implements DumpDescriptorInterface
{
private $dumper;
private $lastIdentifier;
private CliDumper $dumper;
private mixed $lastIdentifier = null;

public function __construct(CliDumper $dumper)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
*/
class HtmlDescriptor implements DumpDescriptorInterface
{
private $dumper;
private $initialized = false;
private HtmlDumper $dumper;
private bool $initialized = false;

public function __construct(HtmlDumper $dumper)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/VarDumper/Command/ServerDumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ class ServerDumpCommand extends Command
protected static $defaultName = 'server:dump';
protected static $defaultDescription = 'Start a dump server that collects and displays dumps in a single place';

private $server;
private DumpServer $server;

/** @var DumpDescriptorInterface[] */
private $descriptors;
private array $descriptors;

public function __construct(DumpServer $server, array $descriptors = [])
{
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
protected $indentPad = ' ';
protected $flags;

private $charset = '';
private string $charset = '';

/**
* @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput
Expand Down
10 changes: 4 additions & 6 deletions src/Symfony/Component/VarDumper/Dumper/CliDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class CliDumper extends AbstractDumper
protected $collapseNextHash = false;
protected $expandNextHash = false;

private $displayOptions = [
private array $displayOptions = [
'fileLinkFormat' => null,
];

private $handlesHrefGracefully;
private bool $handlesHrefGracefully;

/**
* {@inheritdoc}
Expand Down Expand Up @@ -441,10 +441,8 @@ protected function style(string $style, string $value, array $attr = []): string
$this->colors = $this->supportsColors();
}

if (null === $this->handlesHrefGracefully) {
$this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR')
&& (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100);
}
$this->handlesHrefGracefully ??= 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR')
&& (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100);

if (isset($attr['ellipsis'], $attr['ellipsis-type'])) {
$prefix = substr($value, 0, -$attr['ellipsis']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
*/
final class RequestContextProvider implements ContextProviderInterface
{
private $requestStack;
private $cloner;
private RequestStack $requestStack;
private VarCloner $cloner;

public function __construct(RequestStack $requestStack)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
*/
final class SourceContextProvider implements ContextProviderInterface
{
private $limit;
private $charset;
private $projectDir;
private $fileLinkFormatter;
private int $limit;
private ?string $charset;
private ?string $projectDir;
private ?FileLinkFormatter $fileLinkFormatter;

public function __construct(string $charset = null, string $projectDir = null, FileLinkFormatter $fileLinkFormatter = null, int $limit = 9)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*/
class ContextualizedDumper implements DataDumperInterface
{
private $wrappedDumper;
private $contextProviders;
private DataDumperInterface $wrappedDumper;
private array $contextProviders;

/**
* @param ContextProviderInterface[] $contextProviders
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ class HtmlDumper extends CliDumper
protected $lastDepth = -1;
protected $styles;

private $displayOptions = [
private array $displayOptions = [
'maxDepth' => 1,
'maxStringLength' => 160,
'fileLinkFormat' => null,
];
private $extraDisplayOptions = [];
private array $extraDisplayOptions = [];

/**
* {@inheritdoc}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/VarDumper/Dumper/ServerDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
*/
class ServerDumper implements DataDumperInterface
{
private $connection;
private $wrappedDumper;
private Connection $connection;
private ?DataDumperInterface $wrappedDumper;

/**
* @param string $host The server host
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/VarDumper/Server/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*/
class Connection
{
private $host;
private $contextProviders;
private string $host;
private array $contextProviders;

/**
* @var resource|null
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/VarDumper/Server/DumpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
*/
class DumpServer
{
private $host;
private $logger;
private string $host;
private ?LoggerInterface $logger;

/**
* @var resource|null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trait VarDumperTestTrait
/**
* @internal
*/
private $varDumperConfig = [
private array $varDumperConfig = [
'casters' => [],
'flags' => null,
];
Expand Down
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