diff --git a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php index cacd2113d7694..94c1bd3a6b8a0 100644 --- a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php @@ -171,12 +171,11 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st if ($c->hasType()) { $a[$prefix.'typeHint'] = $c->getType()->__toString(); } - } elseif ($c->isArray()) { - $a[$prefix.'typeHint'] = 'array'; - } elseif (method_exists($c, 'isCallable') && $c->isCallable()) { - $a[$prefix.'typeHint'] = 'callable'; - } elseif ($v = $c->getClass()) { - $a[$prefix.'typeHint'] = $v->name; + } else { + $v = explode(' ', $c->__toString(), 6); + if (isset($v[5]) && 0 === strspn($v[4], '.&$')) { + $a[$prefix.'typeHint'] = $v[4]; + } } } catch (\ReflectionException $e) { if (preg_match('/^Class ([^ ]++) does not exist$/', $e->getMessage(), $m)) { diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php index 5c306a671085c..e98642414f0f7 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\VarDumper\Tests\Caster; use Symfony\Component\VarDumper\Test\VarDumperTestCase; +use Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass; /** * @author Nicolas Grekas
@@ -47,7 +48,7 @@ public function testReflectionCaster() "export" => ReflectionMethod { +name: "export" +class: "ReflectionClass" - parameters: array:2 [ +%A parameters: array:2 [ "$%s" => ReflectionParameter { %A position: 0 %A } @@ -70,7 +71,7 @@ public function testReflectionParameter() ReflectionParameter { +name: "arg1" position: 0 - typeHint: "Symfony\Component\VarDumper\Tests\Caster\NotExistingClass" + typeHint: "Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass" default: null } EOTXT @@ -121,6 +122,6 @@ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest" } } -function reflectionParameterFixture(NotExistingClass $arg1 = null, $arg2) +function reflectionParameterFixture(NotLoadableClass $arg1 = null, $arg2) { } diff --git a/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php b/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php new file mode 100644 index 0000000000000..d8e0cb359f4fd --- /dev/null +++ b/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php @@ -0,0 +1,7 @@ +
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: