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

Appearance settings

Commit 01a3925

Browse filesBrowse files
[VarDumper] add types to all arguments
1 parent d9f0467 commit 01a3925
Copy full SHA for 01a3925

18 files changed

+48
-68
lines changed

‎src/Symfony/Component/VarDumper/Caster/CutStub.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/CutStub.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class CutStub extends Stub
2222
{
23-
public function __construct($value)
23+
public function __construct(mixed $value)
2424
{
2525
$this->value = $value;
2626

‎src/Symfony/Component/VarDumper/Caster/DsPairStub.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/DsPairStub.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class DsPairStub extends Stub
2020
{
21-
public function __construct($key, $value)
21+
public function __construct(string|int $key, mixed $value)
2222
{
2323
$this->value = [
2424
Caster::PREFIX_VIRTUAL.'key' => $key,

‎src/Symfony/Component/VarDumper/Caster/LinkStub.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/LinkStub.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class LinkStub extends ConstStub
2323
private static $vendorRoots;
2424
private static $composerRoots;
2525

26-
public function __construct($label, int $line = 0, $href = null)
26+
public function __construct($label, int $line = 0, mixed $href = null)
2727
{
2828
$this->value = $label;
2929

‎src/Symfony/Component/VarDumper/Caster/RdKafkaCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/RdKafkaCaster.php
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232
class RdKafkaCaster
3333
{
34-
public static function castKafkaConsumer(KafkaConsumer $c, array $a, Stub $stub, $isNested)
34+
public static function castKafkaConsumer(KafkaConsumer $c, array $a, Stub $stub, bool $isNested)
3535
{
3636
$prefix = Caster::PREFIX_VIRTUAL;
3737

@@ -51,7 +51,7 @@ public static function castKafkaConsumer(KafkaConsumer $c, array $a, Stub $stub,
5151
return $a;
5252
}
5353

54-
public static function castTopic(Topic $c, array $a, Stub $stub, $isNested)
54+
public static function castTopic(Topic $c, array $a, Stub $stub, bool $isNested)
5555
{
5656
$prefix = Caster::PREFIX_VIRTUAL;
5757

@@ -75,7 +75,7 @@ public static function castTopicPartition(TopicPartition $c, array $a)
7575
return $a;
7676
}
7777

78-
public static function castMessage(Message $c, array $a, Stub $stub, $isNested)
78+
public static function castMessage(Message $c, array $a, Stub $stub, bool $isNested)
7979
{
8080
$prefix = Caster::PREFIX_VIRTUAL;
8181

@@ -86,7 +86,7 @@ public static function castMessage(Message $c, array $a, Stub $stub, $isNested)
8686
return $a;
8787
}
8888

89-
public static function castConf(Conf $c, array $a, Stub $stub, $isNested)
89+
public static function castConf(Conf $c, array $a, Stub $stub, bool $isNested)
9090
{
9191
$prefix = Caster::PREFIX_VIRTUAL;
9292

@@ -97,7 +97,7 @@ public static function castConf(Conf $c, array $a, Stub $stub, $isNested)
9797
return $a;
9898
}
9999

100-
public static function castTopicConf(TopicConf $c, array $a, Stub $stub, $isNested)
100+
public static function castTopicConf(TopicConf $c, array $a, Stub $stub, bool $isNested)
101101
{
102102
$prefix = Caster::PREFIX_VIRTUAL;
103103

@@ -108,7 +108,7 @@ public static function castTopicConf(TopicConf $c, array $a, Stub $stub, $isNest
108108
return $a;
109109
}
110110

111-
public static function castRdKafka(\RdKafka $c, array $a, Stub $stub, $isNested)
111+
public static function castRdKafka(\RdKafka $c, array $a, Stub $stub, bool $isNested)
112112
{
113113
$prefix = Caster::PREFIX_VIRTUAL;
114114

@@ -121,14 +121,14 @@ public static function castRdKafka(\RdKafka $c, array $a, Stub $stub, $isNested)
121121
return $a;
122122
}
123123

124-
public static function castCollectionMetadata(CollectionMetadata $c, array $a, Stub $stub, $isNested)
124+
public static function castCollectionMetadata(CollectionMetadata $c, array $a, Stub $stub, bool $isNested)
125125
{
126126
$a += iterator_to_array($c);
127127

128128
return $a;
129129
}
130130

131-
public static function castTopicMetadata(TopicMetadata $c, array $a, Stub $stub, $isNested)
131+
public static function castTopicMetadata(TopicMetadata $c, array $a, Stub $stub, bool $isNested)
132132
{
133133
$prefix = Caster::PREFIX_VIRTUAL;
134134

@@ -140,7 +140,7 @@ public static function castTopicMetadata(TopicMetadata $c, array $a, Stub $stub,
140140
return $a;
141141
}
142142

143-
public static function castPartitionMetadata(PartitionMetadata $c, array $a, Stub $stub, $isNested)
143+
public static function castPartitionMetadata(PartitionMetadata $c, array $a, Stub $stub, bool $isNested)
144144
{
145145
$prefix = Caster::PREFIX_VIRTUAL;
146146

@@ -153,7 +153,7 @@ public static function castPartitionMetadata(PartitionMetadata $c, array $a, Stu
153153
return $a;
154154
}
155155

156-
public static function castBrokerMetadata(BrokerMetadata $c, array $a, Stub $stub, $isNested)
156+
public static function castBrokerMetadata(BrokerMetadata $c, array $a, Stub $stub, bool $isNested)
157157
{
158158
$prefix = Caster::PREFIX_VIRTUAL;
159159

@@ -166,7 +166,7 @@ public static function castBrokerMetadata(BrokerMetadata $c, array $a, Stub $stu
166166
return $a;
167167
}
168168

169-
private static function extractMetadata($c)
169+
private static function extractMetadata(KafkaConsumer|\RdKafka $c)
170170
{
171171
$prefix = Caster::PREFIX_VIRTUAL;
172172

‎src/Symfony/Component/VarDumper/Caster/RedisCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/RedisCaster.php
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ public static function castRedisCluster(\RedisCluster $c, array $a, Stub $stub,
102102
return $a;
103103
}
104104

105-
/**
106-
* @param \Redis|\RedisArray|\RedisCluster $redis
107-
*/
108-
private static function getRedisOptions($redis, array $options = []): EnumStub
105+
private static function getRedisOptions(\Redis|\RedisArray|\RedisCluster $redis, array $options = []): EnumStub
109106
{
110107
$serializer = $redis->getOption(\Redis::OPT_SERIALIZER);
111108
if (\is_array($serializer)) {

‎src/Symfony/Component/VarDumper/Caster/ResourceCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/ResourceCaster.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static function castStreamContext($stream, array $a, Stub $stub, bool $is
6060
return @stream_context_get_params($stream) ?: $a;
6161
}
6262

63-
public static function castGd($gd, array $a, Stub $stub, $isNested)
63+
public static function castGd($gd, array $a, Stub $stub, bool $isNested)
6464
{
6565
$a['size'] = imagesx($gd).'x'.imagesy($gd);
6666
$a['trueColor'] = imageistruecolor($gd);

‎src/Symfony/Component/VarDumper/Caster/SplCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/SplCaster.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function castArrayIterator(\ArrayIterator $c, array $a, Stub $stub
3939
return self::castSplArray($c, $a, $stub, $isNested);
4040
}
4141

42-
public static function castHeap(\Iterator $c, array $a, Stub $stub, $isNested)
42+
public static function castHeap(\Iterator $c, array $a, Stub $stub, bool $isNested)
4343
{
4444
$a += [
4545
Caster::PREFIX_VIRTUAL.'heap' => iterator_to_array(clone $c),

‎src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,11 @@ public function setMinDepth(int $minDepth)
253253
/**
254254
* Clones a PHP variable.
255255
*
256-
* @param mixed $var Any PHP variable
257-
* @param int $filter A bit field of Caster::EXCLUDE_* constants
256+
* @param int $filter A bit field of Caster::EXCLUDE_* constants
258257
*
259258
* @return Data The cloned variable represented by a Data object
260259
*/
261-
public function cloneVar($var, int $filter = 0)
260+
public function cloneVar(mixed $var, int $filter = 0)
262261
{
263262
$this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) {
264263
if (\E_RECOVERABLE_ERROR === $type || \E_USER_ERROR === $type) {
@@ -291,11 +290,9 @@ public function cloneVar($var, int $filter = 0)
291290
/**
292291
* Effectively clones the PHP variable.
293292
*
294-
* @param mixed $var Any PHP variable
295-
*
296293
* @return array The cloned variable represented in an array
297294
*/
298-
abstract protected function doClone($var);
295+
abstract protected function doClone(mixed $var);
299296

300297
/**
301298
* Casts an object to an array representation.

‎src/Symfony/Component/VarDumper/Cloner/ClonerInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/ClonerInterface.php
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ interface ClonerInterface
1919
/**
2020
* Clones a PHP variable.
2121
*
22-
* @param mixed $var Any PHP variable
23-
*
2422
* @return Data The cloned variable represented by a Data object
2523
*/
26-
public function cloneVar($var);
24+
public function cloneVar(mixed $var);
2725
}

‎src/Symfony/Component/VarDumper/Cloner/Data.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/Data.php
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function getType()
6969
*
7070
* @return string|int|float|bool|array|Data[]|null A native representation of the original value
7171
*/
72-
public function getValue($recursive = false)
72+
public function getValue(array|bool $recursive = false)
7373
{
7474
$item = $this->data[$this->position][$this->key];
7575

@@ -239,11 +239,9 @@ public function withContext(array $context)
239239
/**
240240
* Seeks to a specific key in nested data structures.
241241
*
242-
* @param string|int $key The key to seek to
243-
*
244242
* @return static|null Null if the key is not set
245243
*/
246-
public function seek($key)
244+
public function seek(string|int $key)
247245
{
248246
$item = $this->data[$this->position][$this->key];
249247

@@ -309,7 +307,7 @@ public function dump(DumperInterface $dumper)
309307
*
310308
* @param mixed $item A Stub object or the original value being dumped
311309
*/
312-
private function dumpItem(DumperInterface $dumper, Cursor $cursor, array &$refs, $item)
310+
private function dumpItem(DumperInterface $dumper, Cursor $cursor, array &$refs, mixed $item)
313311
{
314312
$cursor->refIndex = 0;
315313
$cursor->softRefTo = $cursor->softRefHandle = $cursor->softRefCount = 0;
@@ -431,7 +429,7 @@ private function dumpChildren(DumperInterface $dumper, Cursor $parentCursor, arr
431429
return $hashCut;
432430
}
433431

434-
private function getStub($item)
432+
private function getStub(mixed $item)
435433
{
436434
if (!$item || !\is_array($item)) {
437435
return $item;

‎src/Symfony/Component/VarDumper/Cloner/DumperInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/DumperInterface.php
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ interface DumperInterface
2020
{
2121
/**
2222
* Dumps a scalar value.
23-
*
24-
* @param string $type The PHP type of the value being dumped
25-
* @param string|int|float|bool $value The scalar value being dumped
2623
*/
27-
public function dumpScalar(Cursor $cursor, string $type, $value);
24+
public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool $value);
2825

2926
/**
3027
* Dumps a string.
@@ -42,7 +39,7 @@ public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut);
4239
* @param string|int $class The object class, resource type or array count
4340
* @param bool $hasChild When the dump of the hash has child item
4441
*/
45-
public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild);
42+
public function enterHash(Cursor $cursor, int $type, string|int $class, bool $hasChild);
4643

4744
/**
4845
* Dumps while leaving an hash.
@@ -52,5 +49,5 @@ public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild);
5249
* @param bool $hasChild When the dump of the hash has child item
5350
* @param int $cut The number of items the hash has been cut by
5451
*/
55-
public function leaveHash(Cursor $cursor, int $type, $class, bool $hasChild, int $cut);
52+
public function leaveHash(Cursor $cursor, int $type, string|int $class, bool $hasChild, int $cut);
5653
}

‎src/Symfony/Component/VarDumper/Cloner/VarCloner.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/VarCloner.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class VarCloner extends AbstractCloner
2222
/**
2323
* {@inheritdoc}
2424
*/
25-
protected function doClone($var)
25+
protected function doClone(mixed $var)
2626
{
2727
$len = 1; // Length of $queue
2828
$pos = 0; // Number of cloned items past the minimum depth

‎src/Symfony/Component/VarDumper/Dumper/CliDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Dumper/CliDumper.php
+6-8Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function setDisplayOptions(array $displayOptions)
125125
/**
126126
* {@inheritdoc}
127127
*/
128-
public function dumpScalar(Cursor $cursor, string $type, $value)
128+
public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool $value)
129129
{
130130
$this->dumpKey($cursor);
131131

@@ -267,7 +267,7 @@ public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut)
267267
/**
268268
* {@inheritdoc}
269269
*/
270-
public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild)
270+
public function enterHash(Cursor $cursor, int $type, string|int $class, bool $hasChild)
271271
{
272272
if (null === $this->colors) {
273273
$this->colors = $this->supportsColors();
@@ -308,7 +308,7 @@ public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild)
308308
/**
309309
* {@inheritdoc}
310310
*/
311-
public function leaveHash(Cursor $cursor, int $type, $class, bool $hasChild, int $cut)
311+
public function leaveHash(Cursor $cursor, int $type, string|int $class, bool $hasChild, int $cut)
312312
{
313313
if (empty($cursor->attr['cut_hash'])) {
314314
$this->dumpEllipsis($cursor, $hasChild, $cut);
@@ -324,7 +324,7 @@ public function leaveHash(Cursor $cursor, int $type, $class, bool $hasChild, int
324324
* @param bool $hasChild When the dump of the hash has child item
325325
* @param int $cut The number of items the hash has been cut by
326326
*/
327-
protected function dumpEllipsis(Cursor $cursor, $hasChild, $cut)
327+
protected function dumpEllipsis(Cursor $cursor, bool $hasChild, int $cut)
328328
{
329329
if ($cut) {
330330
$this->line .= '';
@@ -428,7 +428,7 @@ protected function dumpKey(Cursor $cursor)
428428
*
429429
* @return string The value with style decoration
430430
*/
431-
protected function style($style, $value, $attr = [])
431+
protected function style(string $style, string $value, array $attr = [])
432432
{
433433
if (null === $this->colors) {
434434
$this->colors = $this->supportsColors();
@@ -576,10 +576,8 @@ protected function endValue(Cursor $cursor)
576576
*
577577
* Reference: Composer\XdebugHandler\Process::supportsColor
578578
* https://github.com/composer/xdebug-handler
579-
*
580-
* @param mixed $stream A CLI output stream
581579
*/
582-
private function hasColorSupport($stream): bool
580+
private function hasColorSupport(mixed $stream): bool
583581
{
584582
if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
585583
return false;

‎src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
+5-10Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,16 @@ public function setDisplayOptions(array $displayOptions)
116116

117117
/**
118118
* Sets an HTML header that will be dumped once in the output stream.
119-
*
120-
* @param string $header An HTML string
121119
*/
122-
public function setDumpHeader($header)
120+
public function setDumpHeader(string $header)
123121
{
124122
$this->dumpHeader = $header;
125123
}
126124

127125
/**
128126
* Sets an HTML prefix and suffix that will encapse every single dump.
129-
*
130-
* @param string $prefix The prepended HTML string
131-
* @param string $suffix The appended HTML string
132127
*/
133-
public function setDumpBoundaries($prefix, $suffix)
128+
public function setDumpBoundaries(string $prefix, string $suffix)
134129
{
135130
$this->dumpPrefix = $prefix;
136131
$this->dumpSuffix = $suffix;
@@ -808,7 +803,7 @@ public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut)
808803
/**
809804
* {@inheritdoc}
810805
*/
811-
public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild)
806+
public function enterHash(Cursor $cursor, int $type, string|int $class, bool $hasChild)
812807
{
813808
if (Cursor::HASH_OBJECT === $type) {
814809
$cursor->attr['depth'] = $cursor->depth;
@@ -839,7 +834,7 @@ public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild)
839834
/**
840835
* {@inheritdoc}
841836
*/
842-
public function leaveHash(Cursor $cursor, int $type, $class, bool $hasChild, int $cut)
837+
public function leaveHash(Cursor $cursor, int $type, string|int $class, bool $hasChild, int $cut)
843838
{
844839
$this->dumpEllipsis($cursor, $hasChild, $cut);
845840
if ($hasChild) {
@@ -851,7 +846,7 @@ public function leaveHash(Cursor $cursor, int $type, $class, bool $hasChild, int
851846
/**
852847
* {@inheritdoc}
853848
*/
854-
protected function style($style, $value, $attr = [])
849+
protected function style(string $style, string $value, array $attr = [])
855850
{
856851
if ('' === $value) {
857852
return '';

‎src/Symfony/Component/VarDumper/Resources/functions/dump.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Resources/functions/dump.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* @author Nicolas Grekas <p@tchwork.com>
1717
*/
18-
function dump($var, ...$moreVars)
18+
function dump(mixed $var, mixed ...$moreVars): mixed
1919
{
2020
VarDumper::dump($var);
2121

@@ -32,7 +32,7 @@ function dump($var, ...$moreVars)
3232
}
3333

3434
if (!function_exists('dd')) {
35-
function dd(...$vars)
35+
function dd(mixed ...$vars): void
3636
{
3737
foreach ($vars as $v) {
3838
VarDumper::dump($v);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.