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 90e3da4

Browse filesBrowse files
minor #33153 [VarDumper] Add parameter type declarations (derrabus)
This PR was merged into the 5.0-dev branch. Discussion ---------- [VarDumper] Add parameter type declarations | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32179 | License | MIT | Doc PR | N/A Commits ------- 9e6512b [VarDumper] Add parameter type declarations.
2 parents de5b2a9 + 9e6512b commit 90e3da4
Copy full SHA for 90e3da4

30 files changed

+145
-166
lines changed

‎src/Symfony/Component/Console/Tests/Helper/DumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Helper/DumperTest.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ public static function tearDownAfterClass(): void
3737
*/
3838
public function testInvoke($variable)
3939
{
40-
$dumper = new Dumper($this->getMockBuilder(OutputInterface::class)->getMock());
40+
$output = $this->getMockBuilder(OutputInterface::class)->getMock();
41+
$output->method('isDecorated')->willReturn(false);
42+
43+
$dumper = new Dumper($output);
4144

4245
$this->assertDumpMatchesFormat($dumper($variable), $variable);
4346
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/AmqpCaster.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class AmqpCaster
4444
AMQP_EX_TYPE_HEADERS => 'AMQP_EX_TYPE_HEADERS',
4545
];
4646

47-
public static function castConnection(\AMQPConnection $c, array $a, Stub $stub, $isNested)
47+
public static function castConnection(\AMQPConnection $c, array $a, Stub $stub, bool $isNested)
4848
{
4949
$prefix = Caster::PREFIX_VIRTUAL;
5050

@@ -77,7 +77,7 @@ public static function castConnection(\AMQPConnection $c, array $a, Stub $stub,
7777
return $a;
7878
}
7979

80-
public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, $isNested)
80+
public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, bool $isNested)
8181
{
8282
$prefix = Caster::PREFIX_VIRTUAL;
8383

@@ -100,7 +100,7 @@ public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, $isNes
100100
return $a;
101101
}
102102

103-
public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, $isNested)
103+
public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, bool $isNested)
104104
{
105105
$prefix = Caster::PREFIX_VIRTUAL;
106106

@@ -123,7 +123,7 @@ public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, $isNested)
123123
return $a;
124124
}
125125

126-
public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, $isNested)
126+
public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, bool $isNested)
127127
{
128128
$prefix = Caster::PREFIX_VIRTUAL;
129129

@@ -151,7 +151,7 @@ public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, $isN
151151
return $a;
152152
}
153153

154-
public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, $isNested, $filter = 0)
154+
public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
155155
{
156156
$prefix = Caster::PREFIX_VIRTUAL;
157157

@@ -191,7 +191,7 @@ public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, $isN
191191
return $a;
192192
}
193193

194-
private static function extractFlags($flags)
194+
private static function extractFlags(int $flags)
195195
{
196196
$flagsArray = [];
197197

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/ArgsStub.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct(array $args, string $function, ?string $class)
4949
}
5050
}
5151

52-
private static function getParameters($function, $class)
52+
private static function getParameters(string $function, ?string $class)
5353
{
5454
if (isset(self::$parameters[$k = $class.'::'.$function])) {
5555
return self::$parameters[$k];

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/Caster.php
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@ class Caster
4040
/**
4141
* Casts objects to arrays and adds the dynamic property prefix.
4242
*
43-
* @param object $obj The object to cast
44-
* @param string $class The class of the object
45-
* @param bool $hasDebugInfo Whether the __debugInfo method exists on $obj or not
43+
* @param bool $hasDebugInfo Whether the __debugInfo method exists on $obj or not
4644
*
4745
* @return array The array-cast of the object, with prefixed dynamic properties
4846
*/
49-
public static function castObject($obj, $class, $hasDebugInfo = false): array
47+
public static function castObject(object $obj, string $class, bool $hasDebugInfo = false): array
5048
{
5149
$a = $obj instanceof \Closure ? [] : (array) $obj;
5250

@@ -110,7 +108,7 @@ public static function castObject($obj, $class, $hasDebugInfo = false): array
110108
*
111109
* @return array The filtered array
112110
*/
113-
public static function filter(array $a, $filter, array $listedProperties = [], &$count = 0): array
111+
public static function filter(array $a, int $filter, array $listedProperties = [], ?int &$count = 0): array
114112
{
115113
$count = 0;
116114

@@ -151,7 +149,7 @@ public static function filter(array $a, $filter, array $listedProperties = [], &
151149
return $a;
152150
}
153151

154-
public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, $isNested): array
152+
public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, bool $isNested): array
155153
{
156154
if (isset($a['__PHP_Incomplete_Class_Name'])) {
157155
$stub->class .= '('.$a['__PHP_Incomplete_Class_Name'].')';

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/DOMCaster.php
+18-18Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class DOMCaster
6161
XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE',
6262
];
6363

64-
public static function castException(\DOMException $e, array $a, Stub $stub, $isNested)
64+
public static function castException(\DOMException $e, array $a, Stub $stub, bool $isNested)
6565
{
6666
$k = Caster::PREFIX_PROTECTED.'code';
6767
if (isset($a[$k], self::$errorCodes[$a[$k]])) {
@@ -71,7 +71,7 @@ public static function castException(\DOMException $e, array $a, Stub $stub, $is
7171
return $a;
7272
}
7373

74-
public static function castLength($dom, array $a, Stub $stub, $isNested)
74+
public static function castLength($dom, array $a, Stub $stub, bool $isNested)
7575
{
7676
$a += [
7777
'length' => $dom->length,
@@ -80,7 +80,7 @@ public static function castLength($dom, array $a, Stub $stub, $isNested)
8080
return $a;
8181
}
8282

83-
public static function castImplementation($dom, array $a, Stub $stub, $isNested)
83+
public static function castImplementation($dom, array $a, Stub $stub, bool $isNested)
8484
{
8585
$a += [
8686
Caster::PREFIX_VIRTUAL.'Core' => '1.0',
@@ -90,7 +90,7 @@ public static function castImplementation($dom, array $a, Stub $stub, $isNested)
9090
return $a;
9191
}
9292

93-
public static function castNode(\DOMNode $dom, array $a, Stub $stub, $isNested)
93+
public static function castNode(\DOMNode $dom, array $a, Stub $stub, bool $isNested)
9494
{
9595
$a += [
9696
'nodeName' => $dom->nodeName,
@@ -114,7 +114,7 @@ public static function castNode(\DOMNode $dom, array $a, Stub $stub, $isNested)
114114
return $a;
115115
}
116116

117-
public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, $isNested)
117+
public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, bool $isNested)
118118
{
119119
$a += [
120120
'nodeName' => $dom->nodeName,
@@ -130,7 +130,7 @@ public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub
130130
return $a;
131131
}
132132

133-
public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, $isNested, $filter = 0)
133+
public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, bool $isNested, int $filter = 0)
134134
{
135135
$a += [
136136
'doctype' => $dom->doctype,
@@ -164,7 +164,7 @@ public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, $is
164164
return $a;
165165
}
166166

167-
public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub $stub, $isNested)
167+
public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub $stub, bool $isNested)
168168
{
169169
$a += [
170170
'data' => $dom->data,
@@ -174,7 +174,7 @@ public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub
174174
return $a;
175175
}
176176

177-
public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, $isNested)
177+
public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, bool $isNested)
178178
{
179179
$a += [
180180
'name' => $dom->name,
@@ -187,7 +187,7 @@ public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, $isNested)
187187
return $a;
188188
}
189189

190-
public static function castElement(\DOMElement $dom, array $a, Stub $stub, $isNested)
190+
public static function castElement(\DOMElement $dom, array $a, Stub $stub, bool $isNested)
191191
{
192192
$a += [
193193
'tagName' => $dom->tagName,
@@ -197,7 +197,7 @@ public static function castElement(\DOMElement $dom, array $a, Stub $stub, $isNe
197197
return $a;
198198
}
199199

200-
public static function castText(\DOMText $dom, array $a, Stub $stub, $isNested)
200+
public static function castText(\DOMText $dom, array $a, Stub $stub, bool $isNested)
201201
{
202202
$a += [
203203
'wholeText' => $dom->wholeText,
@@ -206,7 +206,7 @@ public static function castText(\DOMText $dom, array $a, Stub $stub, $isNested)
206206
return $a;
207207
}
208208

209-
public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, $isNested)
209+
public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, bool $isNested)
210210
{
211211
$a += [
212212
'typeName' => $dom->typeName,
@@ -216,7 +216,7 @@ public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, $is
216216
return $a;
217217
}
218218

219-
public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, $isNested)
219+
public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, bool $isNested)
220220
{
221221
$a += [
222222
'severity' => $dom->severity,
@@ -230,7 +230,7 @@ public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, $is
230230
return $a;
231231
}
232232

233-
public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, $isNested)
233+
public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, bool $isNested)
234234
{
235235
$a += [
236236
'lineNumber' => $dom->lineNumber,
@@ -243,7 +243,7 @@ public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, $isNe
243243
return $a;
244244
}
245245

246-
public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $stub, $isNested)
246+
public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $stub, bool $isNested)
247247
{
248248
$a += [
249249
'name' => $dom->name,
@@ -257,7 +257,7 @@ public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $s
257257
return $a;
258258
}
259259

260-
public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, $isNested)
260+
public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, bool $isNested)
261261
{
262262
$a += [
263263
'publicId' => $dom->publicId,
@@ -267,7 +267,7 @@ public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, $is
267267
return $a;
268268
}
269269

270-
public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, $isNested)
270+
public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, bool $isNested)
271271
{
272272
$a += [
273273
'publicId' => $dom->publicId,
@@ -281,7 +281,7 @@ public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, $isNest
281281
return $a;
282282
}
283283

284-
public static function castProcessingInstruction(\DOMProcessingInstruction $dom, array $a, Stub $stub, $isNested)
284+
public static function castProcessingInstruction(\DOMProcessingInstruction $dom, array $a, Stub $stub, bool $isNested)
285285
{
286286
$a += [
287287
'target' => $dom->target,
@@ -291,7 +291,7 @@ public static function castProcessingInstruction(\DOMProcessingInstruction $dom,
291291
return $a;
292292
}
293293

294-
public static function castXPath(\DOMXPath $dom, array $a, Stub $stub, $isNested)
294+
public static function castXPath(\DOMXPath $dom, array $a, Stub $stub, bool $isNested)
295295
{
296296
$a += [
297297
'document' => $dom->document,

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/DateCaster.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class DateCaster
2222
{
2323
private const PERIOD_LIMIT = 3;
2424

25-
public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, $isNested, $filter)
25+
public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, bool $isNested, int $filter)
2626
{
2727
$prefix = Caster::PREFIX_VIRTUAL;
2828
$location = $d->getTimezone()->getLocation();
@@ -41,7 +41,7 @@ public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub,
4141
return $a;
4242
}
4343

44-
public static function castInterval(\DateInterval $interval, array $a, Stub $stub, $isNested, $filter)
44+
public static function castInterval(\DateInterval $interval, array $a, Stub $stub, bool $isNested, int $filter)
4545
{
4646
$now = new \DateTimeImmutable();
4747
$numberOfSeconds = $now->add($interval)->getTimestamp() - $now->getTimestamp();
@@ -69,7 +69,7 @@ private static function formatInterval(\DateInterval $i)
6969
return $i->format(rtrim($format));
7070
}
7171

72-
public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stub, $isNested, $filter)
72+
public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stub, bool $isNested, int $filter)
7373
{
7474
$location = $timeZone->getLocation();
7575
$formatted = (new \DateTime('now', $timeZone))->format($location ? 'e (P)' : 'P');
@@ -80,7 +80,7 @@ public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stu
8080
return $filter & Caster::EXCLUDE_VERBOSE ? $z : $z + $a;
8181
}
8282

83-
public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, $isNested, $filter)
83+
public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, bool $isNested, int $filter)
8484
{
8585
$dates = [];
8686
foreach (clone $p as $i => $d) {
@@ -108,12 +108,12 @@ public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, $isNeste
108108
return $filter & Caster::EXCLUDE_VERBOSE ? $p : $p + $a;
109109
}
110110

111-
private static function formatDateTime(\DateTimeInterface $d, $extra = '')
111+
private static function formatDateTime(\DateTimeInterface $d, string $extra = ''): string
112112
{
113113
return $d->format('Y-m-d H:i:'.self::formatSeconds($d->format('s'), $d->format('u')).$extra);
114114
}
115115

116-
private static function formatSeconds($s, $us)
116+
private static function formatSeconds(string $s, string $us): string
117117
{
118118
return sprintf('%02d.%s', $s, 0 === ($len = \strlen($t = rtrim($us, '0'))) ? '0' : ($len <= 3 ? str_pad($t, 3, '0') : $us));
119119
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/DoctrineCaster.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
class DoctrineCaster
2525
{
26-
public static function castCommonProxy(CommonProxy $proxy, array $a, Stub $stub, $isNested)
26+
public static function castCommonProxy(CommonProxy $proxy, array $a, Stub $stub, bool $isNested)
2727
{
2828
foreach (['__cloner__', '__initializer__'] as $k) {
2929
if (\array_key_exists($k, $a)) {
@@ -35,7 +35,7 @@ public static function castCommonProxy(CommonProxy $proxy, array $a, Stub $stub,
3535
return $a;
3636
}
3737

38-
public static function castOrmProxy(OrmProxy $proxy, array $a, Stub $stub, $isNested)
38+
public static function castOrmProxy(OrmProxy $proxy, array $a, Stub $stub, bool $isNested)
3939
{
4040
foreach (['_entityPersister', '_identifier'] as $k) {
4141
if (\array_key_exists($k = "\0Doctrine\\ORM\\Proxy\\Proxy\0".$k, $a)) {
@@ -47,7 +47,7 @@ public static function castOrmProxy(OrmProxy $proxy, array $a, Stub $stub, $isNe
4747
return $a;
4848
}
4949

50-
public static function castPersistentCollection(PersistentCollection $coll, array $a, Stub $stub, $isNested)
50+
public static function castPersistentCollection(PersistentCollection $coll, array $a, Stub $stub, bool $isNested)
5151
{
5252
foreach (['snapshot', 'association', 'typeClass'] as $k) {
5353
if (\array_key_exists($k = "\0Doctrine\\ORM\\PersistentCollection\0".$k, $a)) {

0 commit comments

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