Skip to content

Commit 5767c81

Browse files
alexandre-lassnicolas-grekas
authored andcommitted
[VarDumper] Add missing return types
1 parent cb21bc9 commit 5767c81

13 files changed

+61
-10
lines changed

Caster/ClassStub.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ public function __construct(string $identifier, callable|array|string $callable
8585
}
8686
}
8787

88+
/**
89+
* @return mixed
90+
*/
8891
public static function wrapCallable(mixed $callable)
8992
{
9093
if (\is_object($callable) || !\is_callable($callable)) {

Caster/ExceptionCaster.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, boo
289289
return $a;
290290
}
291291

292+
/**
293+
* @return array
294+
*/
292295
public static function castFlattenException(FlattenException $e, array $a, Stub $stub, bool $isNested)
293296
{
294297
if ($isNested) {

Caster/LinkStub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(string $label, int $line = 0, string $href = null)
6060
}
6161
}
6262

63-
private function getComposerRoot(string $file, bool &$inVendor)
63+
private function getComposerRoot(string $file, bool &$inVendor): string|false
6464
{
6565
if (!isset(self::$vendorRoots)) {
6666
self::$vendorRoots = [];

Caster/StubCaster.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public static function castStub(Stub $c, array $a, Stub $stub, bool $isNested)
4646
return $a;
4747
}
4848

49+
/**
50+
* @return array
51+
*/
4952
public static function castCutArray(CutArrayStub $c, array $a, Stub $stub, bool $isNested)
5053
{
5154
return $isNested ? $c->preservedSubset : $a;

Cloner/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ private function dumpChildren(DumperInterface $dumper, Cursor $parentCursor, arr
414414
return $hashCut;
415415
}
416416

417-
private function getStub(mixed $item)
417+
private function getStub(mixed $item): mixed
418418
{
419419
if (!$item || !\is_array($item)) {
420420
return $item;

Cloner/DumperInterface.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ interface DumperInterface
2020
{
2121
/**
2222
* Dumps a scalar value.
23+
*
24+
* @return void
2325
*/
2426
public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool|null $value);
2527

@@ -29,6 +31,8 @@ public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool|n
2931
* @param string $str The string being dumped
3032
* @param bool $bin Whether $str is UTF-8 or binary encoded
3133
* @param int $cut The number of characters $str has been cut by
34+
*
35+
* @return void
3236
*/
3337
public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut);
3438

@@ -38,6 +42,8 @@ public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut);
3842
* @param int $type A Cursor::HASH_* const for the type of hash
3943
* @param string|int|null $class The object class, resource type or array count
4044
* @param bool $hasChild When the dump of the hash has child item
45+
*
46+
* @return void
4147
*/
4248
public function enterHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild);
4349

@@ -48,6 +54,8 @@ public function enterHash(Cursor $cursor, int $type, string|int|null $class, boo
4854
* @param string|int|null $class The object class, resource type or array count
4955
* @param bool $hasChild When the dump of the hash has child item
5056
* @param int $cut The number of items the hash has been cut by
57+
*
58+
* @return void
5159
*/
5260
public function leaveHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild, int $cut);
5361
}

Dumper/CliDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ private function isWindowsTrueColor(): bool
648648
return $result;
649649
}
650650

651-
private function getSourceLink(string $file, int $line)
651+
private function getSourceLink(string $file, int $line): string|false
652652
{
653653
if ($fmt = $this->displayOptions['fileLinkFormat']) {
654654
return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : ($fmt->format($file, $line) ?: 'file://'.$file.'#L'.$line);

Dumper/ContextualizedDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(DataDumperInterface $wrappedDumper, array $contextPr
3232
}
3333

3434
/**
35-
* @return void
35+
* @return string|null
3636
*/
3737
public function dump(Data $data)
3838
{
@@ -41,6 +41,6 @@ public function dump(Data $data)
4141
$context[$contextProvider::class] = $contextProvider->getContext();
4242
}
4343

44-
$this->wrappedDumper->dump($data->withContext($context));
44+
return $this->wrappedDumper->dump($data->withContext($context));
4545
}
4646
}

Dumper/DataDumperInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@
2020
*/
2121
interface DataDumperInterface
2222
{
23+
24+
/**
25+
* @return string|null
26+
*/
2327
public function dump(Data $data);
2428
}

Dumper/HtmlDumper.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,18 @@ public function __construct($output = null, string $charset = null, int $flags =
8282
$this->styles = static::$themes['dark'] ?? self::$themes['dark'];
8383
}
8484

85+
/**
86+
* @return void
87+
*/
8588
public function setStyles(array $styles)
8689
{
8790
$this->headerIsDumped = false;
8891
$this->styles = $styles + $this->styles;
8992
}
9093

94+
/**
95+
* @return void
96+
*/
9197
public function setTheme(string $themeName)
9298
{
9399
if (!isset(static::$themes[$themeName])) {
@@ -101,6 +107,8 @@ public function setTheme(string $themeName)
101107
* Configures display options.
102108
*
103109
* @param array $displayOptions A map of display options to customize the behavior
110+
*
111+
* @return void
104112
*/
105113
public function setDisplayOptions(array $displayOptions)
106114
{
@@ -110,6 +118,8 @@ public function setDisplayOptions(array $displayOptions)
110118

111119
/**
112120
* Sets an HTML header that will be dumped once in the output stream.
121+
*
122+
* @return void
113123
*/
114124
public function setDumpHeader(?string $header)
115125
{
@@ -118,6 +128,8 @@ public function setDumpHeader(?string $header)
118128

119129
/**
120130
* Sets an HTML prefix and suffix that will encapse every single dump.
131+
*
132+
* @return void
121133
*/
122134
public function setDumpBoundaries(string $prefix, string $suffix)
123135
{
@@ -136,6 +148,8 @@ public function dump(Data $data, $output = null, array $extraDisplayOptions = []
136148

137149
/**
138150
* Dumps the HTML header.
151+
*
152+
* @return string
139153
*/
140154
protected function getDumpHeader()
141155
{
@@ -773,6 +787,9 @@ function showCurrent(state)
773787
return $this->dumpHeader = preg_replace('/\s+/', ' ', $line).'</style>'.$this->dumpHeader;
774788
}
775789

790+
/**
791+
* @return void
792+
*/
776793
public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut)
777794
{
778795
if ('' === $str && isset($cursor->attr['img-data'], $cursor->attr['content-type'])) {
@@ -788,6 +805,9 @@ public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut)
788805
}
789806
}
790807

808+
/**
809+
* @return void
810+
*/
791811
public function enterHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild)
792812
{
793813
if (Cursor::HASH_OBJECT === $type) {
@@ -816,6 +836,9 @@ public function enterHash(Cursor $cursor, int $type, string|int|null $class, boo
816836
}
817837
}
818838

839+
/**
840+
* @return void
841+
*/
819842
public function leaveHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild, int $cut)
820843
{
821844
$this->dumpEllipsis($cursor, $hasChild, $cut);
@@ -923,6 +946,9 @@ protected function style(string $style, string $value, array $attr = []): string
923946
return $v;
924947
}
925948

949+
/**
950+
* @return void
951+
*/
926952
protected function dumpLine(int $depth, bool $endOfValue = false)
927953
{
928954
if (-1 === $this->lastDepth) {
@@ -950,7 +976,7 @@ protected function dumpLine(int $depth, bool $endOfValue = false)
950976
AbstractDumper::dumpLine($depth);
951977
}
952978

953-
private function getSourceLink(string $file, int $line)
979+
private function getSourceLink(string $file, int $line): string|false
954980
{
955981
$options = $this->extraDisplayOptions + $this->displayOptions;
956982

0 commit comments

Comments
 (0)