1 | <?php |
||
9 | class ValueData { |
||
10 | private $data; |
||
11 | |||
12 | public function __construct($data) { |
||
15 | |||
16 | //Read $key from array, $this->data = $this->data[$key] but also works for objects |
||
|
|||
17 | private function traverseInto($key) { |
||
18 | if (isset($this->data->{$key})) $this->data = $this->data->{$key}; |
||
19 | else if ($this->isArray() && isset($this->data[$key])) $this->data = $this->data[$key]; |
||
20 | } |
||
21 | |||
22 | public function traverse($key, $result) { |
||
23 | if ($key !== null) $this->traverseInto($key); |
||
24 | else { |
||
25 | //But if the key is null, replace the data structure with the result of the last function call |
||
26 | $lastResult = $result->pop(); |
||
27 | if ($lastResult) { |
||
28 | $this->data = $lastResult; |
||
29 | return $lastResult; |
||
30 | } |
||
31 | } |
||
32 | } |
||
33 | |||
34 | private function isArray() { |
||
37 | |||
38 | public function getData() { |
||
39 | return $this->data; |
||
41 | |||
42 | public function read($value) { |
||
49 | |||
50 | public function call($func, $args) { |
||
53 | |||
54 | public function methodExists($name) { |
||
57 | |||
58 | public function parseNested($parser, $token, $funcName) { |
||
63 | |||
64 | private function callFuncOnObject($obj, $func, $args) { |
||
69 | |||
70 | public function extract($last, $autoLookup, $traversing) { |
||
77 | } |
||
78 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.