本文整理汇总了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 .= '}';
}
}
示例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}");
}
}
}
}
}
示例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 .= '}';
}
}