- if (isset($stub)) {
- if ($zval['zval_isref']) {
- if ($useExt) {
- $vals[$k] = $hardRefs[$zval['zval_hash']] = $v = new Stub();
- $v->value = $stub;
- } else {
- $refs[$k] = new Stub();
- $refs[$k]->value = $stub;
- $h = spl_object_hash($refs[$k]);
- $vals[$k] = $hardRefs[$h] = &$refs[$k];
- $values[$h] = $v;
- }
- $vals[$k]->handle = ++$refsCounter;
- } else {
- $vals[$k] = $stub;
- }
-
- if ($a) {
- if ($i && 0 <= $maxItems) {
- $k = count($a);
- if ($pos < $maxItems) {
- if ($maxItems < $pos += $k) {
- $a = array_slice($a, 0, $maxItems - $pos);
- if ($stub->cut >= 0) {
- $stub->cut += $pos - $maxItems;
- }
- }
- } else {
- if ($stub->cut >= 0) {
- $stub->cut += $k;
- }
- $stub = $a = null;
- unset($arrayRefs[$len]);
- continue;
+ if ($a) {
+ if (!$minimumDepthReached || 0 > $maxItems) {
+ $queue[$len] = $a;
+ $stub->position = $len++;
+ } elseif ($pos < $maxItems) {
+ if ($maxItems < $pos += \count($a)) {
+ $a = \array_slice($a, 0, $maxItems - $pos);
+ if ($stub->cut >= 0) {
+ $stub->cut += $pos - $maxItems;