1 | <?php |
||
11 | class HierarchicalKeySequence |
||
12 | { |
||
13 | |||
14 | const START_HARDENED = 2147483648; |
||
15 | |||
16 | /** |
||
17 | * @param int $sequence |
||
18 | * @return bool |
||
19 | */ |
||
20 | 57 | public function isHardened($sequence) |
|
24 | |||
25 | /** |
||
26 | * @param int $sequence |
||
27 | * @return int |
||
28 | */ |
||
29 | 42 | public function getHardened($sequence) |
|
40 | |||
41 | /** |
||
42 | * Convert a human readable path node (eg, "0", "0'", or "0h") into the correct sequence (0, 0x80000000, 0x80000000) |
||
43 | * |
||
44 | * @param $node |
||
45 | * @return int|string |
||
46 | */ |
||
47 | 48 | public function fromNode($node) |
|
62 | |||
63 | /** |
||
64 | * Given a sequence, get the human readable node. Ie, 0 -> 0, 0x80000000 -> 0h |
||
65 | * |
||
66 | * @param int $sequence |
||
67 | * @return string |
||
68 | */ |
||
69 | 30 | public function getNode($sequence) |
|
78 | |||
79 | /** |
||
80 | * Decodes a human-readable path, into an array of integers (sequences) |
||
81 | * |
||
82 | * @param string $path |
||
83 | * @return array |
||
84 | */ |
||
85 | 36 | public function decodePath($path) |
|
100 | |||
101 | /** |
||
102 | * Encodes a list of sequences to the human-readable path. |
||
103 | * |
||
104 | * @param array|\stdClass|\Traversable $list |
||
105 | * @return string |
||
106 | */ |
||
107 | 9 | public function encodePath($list) |
|
118 | |||
119 | /** |
||
120 | * Check the list, mainly that it works for foreach() |
||
121 | * |
||
122 | * @param \stdClass|array|\Traversable $list |
||
123 | */ |
||
124 | 15 | public static function validateListType($list) |
|
131 | } |
||
132 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.