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 fe567bf

Browse filesBrowse files
[VarDumper] Fix PHP 7.1 compat
1 parent 07d4985 commit fe567bf
Copy full SHA for fe567bf

File tree

1 file changed

+10
-3
lines changed
Filter options

1 file changed

+10
-3
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, arra
115115
));
116116

117117
if (isset($a[$prefix.'returnType'])) {
118-
$a[$prefix.'returnType'] = (string) $a[$prefix.'returnType'];
118+
$a[$prefix.'returnType'] = method_exists('ReflectionType', 'getName') ? $a[$prefix.'returnType']->getName() : $a[$prefix.'returnType']->__toString();
119119
}
120120
if (isset($a[$prefix.'this'])) {
121121
$a[$prefix.'this'] = new CutStub($a[$prefix.'this']);
@@ -164,12 +164,13 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
164164
'position' => 'getPosition',
165165
'isVariadic' => 'isVariadic',
166166
'byReference' => 'isPassedByReference',
167+
'allowsNull' => 'allowsNull',
167168
));
168169

169170
try {
170171
if (method_exists($c, 'hasType')) {
171172
if ($c->hasType()) {
172-
$a[$prefix.'typeHint'] = $c->getType()->__toString();
173+
$a[$prefix.'typeHint'] = method_exists('ReflectionType', 'getName') ? $c->getType()->getName() : $c->getType()->__toString();
173174
}
174175
} else {
175176
$v = explode(' ', $c->__toString(), 6);
@@ -182,14 +183,20 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
182183
$a[$prefix.'typeHint'] = $m[1];
183184
}
184185
}
186+
if (!isset($a[$prefix.'typeHint'])) {
187+
unset($a[$prefix.'allowsNull']);
188+
}
185189

186190
try {
187191
$a[$prefix.'default'] = $v = $c->getDefaultValue();
188192
if (method_exists($c, 'isDefaultValueConstant') && $c->isDefaultValueConstant()) {
189193
$a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v);
190194
}
195+
if (null === $v) {
196+
unset($a[$prefix.'allowsNull']);
197+
}
191198
} catch (\ReflectionException $e) {
192-
if (isset($a[$prefix.'typeHint']) && $c->allowsNull()) {
199+
if (isset($a[$prefix.'typeHint']) && $c->allowsNull() && !method_exists('ReflectionType', 'getName')) {
193200
$a[$prefix.'default'] = null;
194201
}
195202
}

0 commit comments

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