/** * {@inheritdoc} */ public function __construct(array $tree, NcursesVarDumpTypeAbstract $parent = null) { if ("object" != $tree["type"]) { throw new \InvalidArgumentException("Invalid var tree given, expected 'object'"); } parent::__construct($tree, $parent); $this->setExpandable(true); // render object $isClone = null !== $tree["refUid"]; $rightArrow = $isClone ? ">>" : "▸"; $strCollapsed = "<<4>>object<<0>>(<<5>>{$tree["class"]}<<0>>)"; $strCollapsed .= "<<6>>#{$tree["id"]}<<0>> (<<1>>{$tree["count"]}<<0>>) "; $strExpanded = $strCollapsed; $strCollapsed .= $rightArrow; $strExpanded .= "▾"; $this->setStringArrayCollapsed($this->buildTextArray($strCollapsed)); $this->setStringArrayExpanded($this->buildTextArray($strExpanded)); // add children if ($isClone) { return; } foreach ($tree["properties"] as $subTree) { $class = $subTree["class"] ? "<<5>>{$subTree["class"]}:<<0>>" : ""; $key = $subTree["static"] ? "<<2>>static:<<3>>{$subTree["access"]}:<<0>>{$class}{$subTree["name"]}" : "<<3>>{$subTree["access"]}:<<0>>{$subTree["name"]}"; $key = "[{$key}] = "; $child = NcursesVarDumpTypeAbstract::factory($subTree["value"]); $wrapper = new NcursesVarDumpTypeWrapper($child, $this, $key); $this->addChild($wrapper); } }
/** * {@inheritdoc} */ public function __construct(array $tree, NcursesVarDumpTypeAbstract $parent = null) { if ("array" != $tree["type"]) { throw new \InvalidArgumentException("Invalid var tree given, expected 'array'"); } parent::__construct($tree, $parent); $this->setExpandable(true); // render array $isClone = null !== $tree["refUid"]; $strCollapsed = "<<4>>array<<0>>(<<1>>{$tree["count"]}<<0>>) "; $strExpanded = $strCollapsed; $strCollapsed .= $isClone ? ">>" : "▸"; $strExpanded .= "▾"; $this->setStringArrayCollapsed($this->buildTextArray($strCollapsed)); $this->setStringArrayExpanded($this->buildTextArray($strExpanded)); // add children foreach ($tree["children"] as $k => $subTree) { $key = "[{$k}] = "; $child = NcursesVarDumpTypeAbstract::factory($subTree); $wrapper = new NcursesVarDumpTypeWrapper($child, $this, $key); $this->addChild($wrapper); } }