diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php index 63e683cb15b50..ba8caad3f38a0 100644 --- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php @@ -192,7 +192,7 @@ protected function castObject(Stub $stub, $isNested) $class, method_exists($class, '__debugInfo'), new \ReflectionClass($class), - array_reverse(array($class => $class) + class_parents($class) + class_implements($class)), + array_reverse(array('*' => '*', $class => $class) + class_parents($class) + class_implements($class)), ); $this->classInfo[$class] = $classInfo; diff --git a/src/Symfony/Component/VarDumper/Tests/VarClonerTest.php b/src/Symfony/Component/VarDumper/Tests/VarClonerTest.php index 1bb94100362a6..620acdcccd02f 100644 --- a/src/Symfony/Component/VarDumper/Tests/VarClonerTest.php +++ b/src/Symfony/Component/VarDumper/Tests/VarClonerTest.php @@ -131,6 +131,56 @@ public function testClone() [useRefHandles:Symfony\Component\VarDumper\Cloner\Data:private] => -1 ) +EOTXT; + $this->assertStringMatchesFormat($expected, print_r($clone, true)); + } + + public function testCaster() + { + $cloner = new VarCloner(array( + '*' => function ($obj, $array) { + $array['foo'] = 123; + + return $array; + }, + __CLASS__ => function ($obj, $array) { + return array(); + }, + )); + $clone = $cloner->cloneVar($this); + + $expected = << Array + ( + [0] => Array + ( + [0] => Symfony\Component\VarDumper\Cloner\Stub Object + ( + [type] => object + [class] => %s + [value] => + [cut] => 0 + [handle] => %d + [refCount] => 0 + [position] => 1 + ) + + ) + + [1] => Array + ( + [foo] => 123 + ) + + ) + + [maxDepth:Symfony\Component\VarDumper\Cloner\Data:private] => 20 + [maxItemsPerDepth:Symfony\Component\VarDumper\Cloner\Data:private] => -1 + [useRefHandles:Symfony\Component\VarDumper\Cloner\Data:private] => -1 +) + EOTXT; $this->assertStringMatchesFormat($expected, print_r($clone, true)); }