1 | <?php |
||
13 | class HierarchicalKeySequence |
||
14 | { |
||
15 | |||
16 | const START_HARDENED = 2147483648; |
||
17 | |||
18 | /** |
||
19 | * @param int $sequence |
||
20 | * @return bool |
||
21 | */ |
||
22 | 25 | public function isHardened(int $sequence): bool |
|
26 | |||
27 | /** |
||
28 | * @param int $sequence |
||
29 | * @return int |
||
30 | */ |
||
31 | 19 | public function getHardened(int $sequence): int |
|
42 | |||
43 | /** |
||
44 | * Convert a human readable path node (eg, "0", "0'", or "0h") into the correct sequence (0, 0x80000000, 0x80000000) |
||
45 | * |
||
46 | * @param string $node |
||
47 | * @return int |
||
48 | */ |
||
49 | 22 | public function fromNode(string $node): int |
|
69 | |||
70 | /** |
||
71 | * Given a sequence, get the human readable node. Ie, 0 -> 0, 0x80000000 -> 0h |
||
72 | * |
||
73 | * @param int $sequence |
||
74 | * @return string |
||
75 | */ |
||
76 | 12 | public function getNode(int $sequence): string |
|
85 | |||
86 | /** |
||
87 | * Decodes a human-readable path, into an array of integers (sequences) |
||
88 | * |
||
89 | * @param string $path |
||
90 | * @return int[] |
||
91 | */ |
||
92 | 18 | public function decodePath(string $path): array |
|
107 | |||
108 | /** |
||
109 | * Encodes a list of sequences to the human-readable path. |
||
110 | * |
||
111 | * @param array|\stdClass|\Traversable $list |
||
112 | * @return string |
||
113 | */ |
||
114 | 3 | public function encodePath($list) |
|
125 | |||
126 | /** |
||
127 | * Check the list, mainly that it works for foreach() |
||
128 | * |
||
129 | * @param \stdClass|array|\Traversable $list |
||
130 | */ |
||
131 | 7 | public static function validateListType($list) |
|
137 | } |
||
138 |
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.