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