当前位置: 首页>>代码示例>>PHP>>正文


PHP Dumper::walkHash方法代码示例

本文整理汇总了PHP中Dumper::walkHash方法的典型用法代码示例。如果您正苦于以下问题:PHP Dumper::walkHash方法的具体用法?PHP Dumper::walkHash怎么用?PHP Dumper::walkHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dumper的用法示例。


在下文中一共展示了Dumper::walkHash方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: walkHash

 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 .= '}';
     }
 }
开发者ID:nicolas-grekas,项目名称:Patchwork-sandbox,代码行数:26,代码来源:JsonDumper.php

示例2: walkHash

 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}");
                 }
             }
         }
     }
 }
开发者ID:nicolas-grekas,项目名称:Patchwork,代码行数:55,代码来源:CliDumper.php

示例3: walkHash

 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 .= '}';
     }
 }
开发者ID:nicolas-grekas,项目名称:Patchwork,代码行数:23,代码来源:JsonDumper.php


注:本文中的Dumper::walkHash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。