protected function walkHash($type, &$a)
 {
     if ('array:0' === $type) {
         $this->line .= '[]';
     } else {
         $h = $this->lastHash;
         $this->line .= '{"_":';
         $this->lastHash = $this->counter;
         $this->dumpString($this->counter . ':' . $type, false);
         if ($type = parent::walkHash($type, $a)) {
             ++$this->depth;
             $this->dumpString('__refs', true);
             $this->line .= '{';
             foreach ($type as $k => &$a) {
                 $a = '"' . $k . '":[' . implode(',', $a) . ']';
             }
             $this->line .= implode(',', $type) . '}';
             --$this->depth;
         }
         if ($this->counter !== $this->lastHash || isset($this->depthLimited[$this->counter])) {
             $this->dumpLine(1);
         }
         $this->lastHash = $h;
         $this->line .= '}';
     }
 }
Ejemplo n.º 2
0
 protected function walkHash($type, &$a, $len)
 {
     if ('array:0' === $type) {
         $this->line .= '[]';
     } else {
         $is_array = 0 === strncmp($type, 'array:', 6);
         if ($is_array) {
             $this->line .= '[';
             //$this->dumpString(substr($type, 6), false, 'note');
         } else {
             $this->dumpString($type, false, 'note');
             $this->line .= '{';
         }
         $this->line .= ' ' . $this->style('ref', "#{$this->counter}");
         $startCounter = $this->counter;
         $refs = parent::walkHash($type, $a, $len);
         if ($this->counter !== $startCounter) {
             $this->dumpLine(1);
         }
         $this->line .= $is_array ? ']' : '}';
         if ($refs) {
             $col1 = 0;
             $type = array();
             foreach ($refs as $k => $v) {
                 if (isset($this->valPool[$k])) {
                     $v = $this->valPool[$k];
                     $type[$k] = gettype($v);
                     switch ($type[$k]) {
                         case 'object':
                             $type[$k] = get_class($v);
                             break;
                         case 'unknown type':
                         case 'resource':
                             $type[$k] = 'resource:' . get_resource_type($v);
                             break;
                     }
                     $col1 = max($col1, strlen($type[$k]));
                 }
             }
             $col2 = strlen($this->counter);
             foreach ($refs as $k => $v) {
                 $this->dumpLine(0);
                 $this->line .= str_repeat(' ', $col2 - strlen($k));
                 $this->line .= $this->style('ref', "#{$k}");
                 if ($col1) {
                     $this->line .= sprintf(" % -{$col1}s", isset($type[$k]) ? $type[$k] : 'array');
                 }
                 $this->line .= ':';
                 foreach ($v as $v) {
                     $this->line .= ' ' . $this->style('note', $v < 0 ? '#' . -$v : "@{$v}");
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 protected function walkHash($type, &$a, $len)
 {
     if ('array:0' === $type) {
         $this->line .= '[]';
     } else {
         $this->line .= '{"_":';
         $this->dumpString($this->counter . ':' . $type, false);
         $startCounter = $this->counter;
         if ($type = parent::walkHash($type, $a, $len)) {
             ++$this->depth;
             $this->dumpString('__refs', true);
             foreach ($type as $k => $v) {
                 $type[$k] = '"' . $k . '":[' . implode(',', $v) . ']';
             }
             $this->line .= '{' . implode(',', $type) . '}';
             --$this->depth;
         }
         if ($this->counter !== $startCounter) {
             $this->dumpLine(1);
         }
         $this->line .= '}';
     }
 }