10000 [VarDumper] Fix return type dumping · symfony/symfony@c5b6751 · GitHub
[go: up one dir, main page]

Skip to content

Commit c5b6751

Browse files
[VarDumper] Fix return type dumping
1 parent 80182fa commit c5b6751

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, arra
114114
'this' => 'getClosureThis',
115115
));
116116

117+
if (isset($a[$prefix.'returnType'])) {
118+
$a[$prefix.'returnType'] = (string) $a[$prefix.'returnType'];
119+
}
117120
if (isset($a[$prefix.'this'])) {
118121
$a[$prefix.'this'] = new CutStub($a[$prefix.'this']);
119122
}

src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,25 @@ public function testReflectionCaster()
6060
, $var
6161
);
6262
}
63+
64+
/**
65+
* @requires PHP 7.0
66+
*/
67+
public function testReturnType()
68+
{
69+
$f = eval('return function ():int {};');
70+
71+
$this->assertDumpMatchesFormat(
72+
<<<'EOTXT'
73+
Closure {
74+
returnType: "int"
75+
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
76+
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
77+
file: "%sReflectionCasterTest.php(69) : eval()'d code"
78+
line: "1 to 1"
79+
}
80+
EOTXT
81+
, $f
82+
);
83+
}
6384
}

0 commit comments

Comments
 (0)
0