1 | <?php |
||
16 | class Tree implements Iterator |
||
17 | { |
||
18 | /** |
||
19 | * List of Item instances children of this tree. |
||
20 | * |
||
21 | * @var Item[] |
||
22 | */ |
||
23 | protected $items; |
||
24 | |||
25 | /** |
||
26 | * The current index for the Iterator interface. |
||
27 | * |
||
28 | * @var int |
||
29 | */ |
||
30 | protected $iteratorIndex; |
||
31 | |||
32 | /** |
||
33 | * Initializes the instance. |
||
34 | */ |
||
35 | 1 | public function __construct() |
|
39 | |||
40 | /** |
||
41 | * Get the items contained in this tree. |
||
42 | * |
||
43 | * @return Item[] |
||
44 | */ |
||
45 | 1 | public function getItems() |
|
49 | |||
50 | /** |
||
51 | * Get the total number of items in this instance and in all the sub-instances. |
||
52 | * |
||
53 | * @return int |
||
54 | */ |
||
55 | public function getItemsCount() |
||
64 | |||
65 | /** |
||
66 | * Resolve the items contained in other CHM files. |
||
67 | * |
||
68 | * @param Map $map |
||
69 | * @param bool $ignoreErrors Set to true to ignore missing CHM and/or entries. |
||
70 | * |
||
71 | * @throws Exception Throw an Exception in case of errors. |
||
72 | */ |
||
73 | 1 | public function resolve(Map $map, $ignoreErrors = false) |
|
82 | |||
83 | /** |
||
84 | * Create a new instance starting from the whole TOC/Index source 'HTML'. |
||
85 | * |
||
86 | * @param CHM $chm The parent CHM instance. |
||
87 | * @param string $data The contents of the .hhc/.hhk file. |
||
88 | * |
||
89 | * @throws Exception Throw an Exception in case of errors. |
||
90 | * |
||
91 | * @return static |
||
92 | */ |
||
93 | 1 | public static function fromString(CHM $chm, $data) |
|
121 | |||
122 | /** |
||
123 | * Depth of the found child items. |
||
124 | * |
||
125 | * @var int |
||
126 | */ |
||
127 | protected $depth; |
||
128 | |||
129 | /** |
||
130 | * Parse a DOMElement and read the items/sub trees. |
||
131 | * |
||
132 | * @param CHM $chm |
||
133 | * @param DOMElement $parentElement |
||
134 | * @param int $depth |
||
135 | */ |
||
136 | 1 | protected function parseParentElement(CHM $chm, DOMElement $parentElement, $depth) |
|
163 | |||
164 | /** |
||
165 | * {@inheritdoc} |
||
166 | * |
||
167 | * @see Iterator::current() |
||
168 | */ |
||
169 | public function current() |
||
173 | |||
174 | /** |
||
175 | * {@inheritdoc} |
||
176 | * |
||
177 | * @see Iterator::key() |
||
178 | */ |
||
179 | public function key() |
||
183 | |||
184 | /** |
||
185 | * {@inheritdoc} |
||
186 | * |
||
187 | * @see Iterator::next() |
||
188 | */ |
||
189 | public function next() |
||
193 | |||
194 | /** |
||
195 | * {@inheritdoc} |
||
196 | * |
||
197 | * @see Iterator::rewind() |
||
198 | */ |
||
199 | public function rewind() |
||
203 | |||
204 | /** |
||
205 | * {@inheritdoc} |
||
206 | * |
||
207 | * @see Iterator::valid() |
||
208 | */ |
||
209 | public function valid() |
||
213 | } |
||
214 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.