[VarDumper] Add catch-all-objects hook for casters
This commit is contained in:
parent
59ca5b3af9
commit
5999964151
@ -192,7 +192,7 @@ abstract class AbstractCloner implements ClonerInterface
|
||||
$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;
|
||||
|
@ -131,6 +131,56 @@ Symfony\Component\VarDumper\Cloner\Data Object
|
||||
[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 = <<<EOTXT
|
||||
Symfony\Component\VarDumper\Cloner\Data Object
|
||||
(
|
||||
[data:Symfony\Component\VarDumper\Cloner\Data:private] => 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));
|
||||
}
|
||||
|
Reference in New Issue
Block a user