41 protected $stats = [
'total' => 0,
'used' => 0,
'unused' => 0];
48 register_shutdown_function([$this,
'display']);
58 if (!self::$instance) {
59 self::$instance =
new Log();
72 $this->stats[
'total']++;
77 $this->roots[] =
$item;
80 $this->currentItem =
$item;
91 $this->currentItem->setHash(spl_object_hash($object));
92 $this->currentItem = $this->currentItem->getParent();
101 public function add($object)
103 $this->stats[
'total']++;
104 if ($this->currentItem) {
105 $item =
new Item(get_class($object), $this->currentItem);
106 $this->currentItem->addChild(
$item);
108 $item =
new Item(get_class($object),
null);
109 $this->roots[] =
$item;
111 $item->setHash(spl_object_hash($object));
122 $this->used[spl_object_hash($object)] = 1;
132 $this->stats[
'used'] = count($this->used);
133 $this->stats[
'unused'] = $this->stats[
'total'] - $this->stats[
'used'];
134 echo
'<table border="1" cellspacing="0" cellpadding="2">',
136 "Creation chain (Red items are never used) Total: {$this->stats['total']}\n",
137 "Used: {$this->stats['used']} Not used: {$this->stats['unused']}",
138 '</th></tr></thead>',
140 '<tr><th>Instance class</th></tr>';
141 foreach ($this->roots as $root) {
144 echo
'</tbody></table>';
156 $colorStyle = isset($this->used[
$item->getHash()]) ?
'' :
' style="color:red" ';
158 echo
"<tr><td $colorStyle>" . str_repeat(
'ยท ', $level) .
$item->getClass()
159 .
' - ' .
$item->getHash() .
'</td></tr>';
161 foreach (
$item->getChildren() as $child) {
displayItem(Item $item, $level=0)
$_option $_optionId $class