Skip to content

[VarDumper] Remove dead code #23637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions src/Symfony/Component/VarDumper/Cloner/VarCloner.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,10 @@ protected function doClone($var)
$a = null; // Array cast for nested structures
$stub = null; // Stub capturing the main properties of an original item value
// or null if the original value is used directly
$zval = array( // Main properties of the current value
'type' => null,
'zval_isref' => null,
'zval_hash' => null,
'array_count' => null,
'object_class' => null,
'object_handle' => null,
'resource_type' => null,
);
$zvalType = null; // Main properties of the current value
$zvalIsRef = null;
$zvalHash = null;

if (!self::$hashMask) {
self::initHashMask();
}
Expand Down Expand Up @@ -84,14 +79,14 @@ protected function doClone($var)
$k = $j;
}
$refs[$k] = $cookie;
if ($zval['zval_isref'] = $vals[$k] === $cookie) {
$zval['zval_hash'] = $v instanceof Stub ? spl_object_hash($v) : null;
if ($zvalIsRef = $vals[$k] === $cookie) {
$zvalHash = $v instanceof Stub ? spl_object_hash($v) : null;
}
$zval['type'] = gettype($v);
if ($zval['zval_isref']) {
$zvalType = gettype($v);
if ($zvalIsRef) {
$vals[$k] = &$stub; // Break hard references to make $queue completely
unset($stub); // independent from the original structure
if (isset($hardRefs[$zval['zval_hash']])) {
if (isset($hardRefs[$zvalHash])) {
$vals[$k] = $refs[$k] = $v;
if ($v->value instanceof Stub && (Stub::TYPE_OBJECT === $v->value->type || Stub::TYPE_RESOURCE === $v->value->type)) {
++$v->value->refCount;
Expand All @@ -102,7 +97,7 @@ protected function doClone($var)
}
// Create $stub when the original value $v can not be used directly
// If $v is a nested structure, put that structure in array $a
switch ($zval['type']) {
switch ($zvalType) {
case 'string':
if (isset($v[0]) && !preg_match('//u', $v)) {
$stub = new Stub();
Expand Down Expand Up @@ -148,15 +143,15 @@ protected function doClone($var)
$a = $v;
}

$stub->value = $zval['array_count'] ?: count($a);
$stub->value = count($a);
}
break;

case 'object':
if (empty($objRefs[$h = $zval['object_handle'] ?: ($hashMask ^ hexdec(substr(spl_object_hash($v), $hashOffset, PHP_INT_SIZE)))])) {
if (empty($objRefs[$h = $hashMask ^ hexdec(substr(spl_object_hash($v), $hashOffset, PHP_INT_SIZE))])) {
$stub = new Stub();
$stub->type = Stub::TYPE_OBJECT;
$stub->class = $zval['object_class'] ?: get_class($v);
$stub->class = get_class($v);
$stub->value = $v;
$stub->handle = $h;
$a = $this->castObject($stub, 0 < $i);
Expand Down Expand Up @@ -188,7 +183,7 @@ protected function doClone($var)
if (empty($resRefs[$h = (int) $v])) {
$stub = new Stub();
$stub->type = Stub::TYPE_RESOURCE;
if ('Unknown' === $stub->class = $zval['resource_type'] ?: @get_resource_type($v)) {
if ('Unknown' === $stub->class = @get_resource_type($v)) {
$stub->class = 'Closed';
}
$stub->value = $v;
Expand All @@ -211,7 +206,7 @@ protected function doClone($var)
}

if (isset($stub)) {
if ($zval['zval_isref']) {
if ($zvalIsRef) {
$refs[$k] = new Stub();
$refs[$k]->value = $stub;
$h = spl_object_hash($refs[$k]);
Expand Down Expand Up @@ -245,7 +240,7 @@ protected function doClone($var)
$stub->position = $len++;
}
$stub = $a = null;
} elseif ($zval['zval_isref']) {
} elseif ($zvalIsRef) {
$refs[$k] = $vals[$k] = new Stub();
$refs[$k]->value = $v;
$h = spl_object_hash($refs[$k]);
Expand Down