[VarDumper] Improve performance of AbstractCloner
This commit is contained in:
parent
edc4a0f572
commit
cff23e52bf
@ -69,7 +69,7 @@ abstract class AbstractCloner implements ClonerInterface
|
|||||||
'DOMProcessingInstruction' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castProcessingInstruction'],
|
'DOMProcessingInstruction' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castProcessingInstruction'],
|
||||||
'DOMXPath' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castXPath'],
|
'DOMXPath' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castXPath'],
|
||||||
|
|
||||||
'XmlReader' => ['Symfony\Component\VarDumper\Caster\XmlReaderCaster', 'castXmlReader'],
|
'XMLReader' => ['Symfony\Component\VarDumper\Caster\XmlReaderCaster', 'castXmlReader'],
|
||||||
|
|
||||||
'ErrorException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castErrorException'],
|
'ErrorException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castErrorException'],
|
||||||
'Exception' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castException'],
|
'Exception' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castException'],
|
||||||
@ -177,7 +177,7 @@ abstract class AbstractCloner implements ClonerInterface
|
|||||||
public function addCasters(array $casters)
|
public function addCasters(array $casters)
|
||||||
{
|
{
|
||||||
foreach ($casters as $type => $callback) {
|
foreach ($casters as $type => $callback) {
|
||||||
$closure = &$this->casters['' === $type || ':' === $type[0] ? $type : strtolower($type)][];
|
$closure = &$this->casters[$type][];
|
||||||
$closure = $callback instanceof \Closure ? $callback : static function (...$args) use ($callback, &$closure) {
|
$closure = $callback instanceof \Closure ? $callback : static function (...$args) use ($callback, &$closure) {
|
||||||
return ($closure = \Closure::fromCallable($callback))(...$args);
|
return ($closure = \Closure::fromCallable($callback))(...$args);
|
||||||
};
|
};
|
||||||
@ -282,15 +282,15 @@ abstract class AbstractCloner implements ClonerInterface
|
|||||||
list($i, $parents, $hasDebugInfo) = $this->classInfo[$class];
|
list($i, $parents, $hasDebugInfo) = $this->classInfo[$class];
|
||||||
} else {
|
} else {
|
||||||
$i = 2;
|
$i = 2;
|
||||||
$parents = [strtolower($class)];
|
$parents = [$class];
|
||||||
$hasDebugInfo = method_exists($class, '__debugInfo');
|
$hasDebugInfo = method_exists($class, '__debugInfo');
|
||||||
|
|
||||||
foreach (class_parents($class) as $p) {
|
foreach (class_parents($class) as $p) {
|
||||||
$parents[] = strtolower($p);
|
$parents[] = $p;
|
||||||
++$i;
|
++$i;
|
||||||
}
|
}
|
||||||
foreach (class_implements($class) as $p) {
|
foreach (class_implements($class) as $p) {
|
||||||
$parents[] = strtolower($p);
|
$parents[] = $p;
|
||||||
++$i;
|
++$i;
|
||||||
}
|
}
|
||||||
$parents[] = '*';
|
$parents[] = '*';
|
||||||
|
Reference in New Issue
Block a user