1 | <?php declare(strict_types=1); |
||
11 | class NodeCollection implements \Countable, \ArrayAccess, \RecursiveIterator |
||
12 | { |
||
13 | /** @var iterable */ |
||
14 | protected $nodes = []; |
||
15 | |||
16 | /** |
||
17 | * @param iterable $nodes |
||
18 | */ |
||
19 | 138 | public function __construct(iterable $nodes = null) { |
|
28 | |||
29 | /** |
||
30 | * @see \Countable::count() |
||
31 | * |
||
32 | * @return int |
||
33 | */ |
||
34 | 76 | public function count(): int { |
|
37 | |||
38 | /** |
||
39 | * @see \ArrayAccess::offsetExists() |
||
40 | * |
||
41 | * @param mixed $offset |
||
42 | * |
||
43 | * @return bool |
||
44 | */ |
||
45 | public function offsetExists($offset): bool { |
||
48 | |||
49 | /** |
||
50 | * @see \ArrayAccess::offsetGet() |
||
51 | * |
||
52 | * @param mixed $offset |
||
53 | * |
||
54 | * @return mixed |
||
55 | */ |
||
56 | 20 | public function offsetGet($offset) { |
|
59 | |||
60 | /** |
||
61 | * @see \ArrayAccess::offsetSet() |
||
62 | * |
||
63 | * @param mixed $offset |
||
64 | * @param mixed $value |
||
65 | */ |
||
66 | 81 | public function offsetSet($offset, $value): void { |
|
73 | |||
74 | /** |
||
75 | * @see \ArrayAccess::offsetUnset() |
||
76 | * |
||
77 | * @param mixed $offset |
||
78 | */ |
||
79 | public function offsetUnset($offset): void { |
||
82 | |||
83 | /** |
||
84 | * @see \RecursiveIterator::RecursiveIteratorIterator() |
||
85 | * |
||
86 | * @return \RecursiveIteratorIterator |
||
87 | */ |
||
88 | public function getRecursiveIterator(): \RecursiveIteratorIterator { |
||
91 | |||
92 | /** |
||
93 | * @see \RecursiveIterator::getChildren() |
||
94 | * |
||
95 | * @return \RecursiveIterator |
||
96 | */ |
||
97 | public function getChildren(): \RecursiveIterator { |
||
106 | |||
107 | /** |
||
108 | * @see \RecursiveIterator::hasChildren() |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | public function hasChildren(): bool { |
||
119 | |||
120 | /** |
||
121 | * @see \RecursiveIterator::current() |
||
122 | * @see \Iterator::current() |
||
123 | * |
||
124 | * @return mixed |
||
125 | */ |
||
126 | 130 | public function current() { |
|
129 | |||
130 | /** |
||
131 | * @see \RecursiveIterator::key() |
||
132 | * @see \Iterator::key() |
||
133 | * |
||
134 | * @return mixed |
||
135 | */ |
||
136 | 1 | public function key() { |
|
139 | |||
140 | /** |
||
141 | * @see \RecursiveIterator::next() |
||
142 | * @see \Iterator::next() |
||
143 | * |
||
144 | * @return mixed |
||
145 | */ |
||
146 | 130 | public function next() { |
|
149 | |||
150 | /** |
||
151 | * @see \RecursiveIterator::rewind() |
||
152 | * @see \Iterator::rewind() |
||
153 | * |
||
154 | * @return mixed |
||
155 | */ |
||
156 | 133 | public function rewind() { |
|
159 | |||
160 | /** |
||
161 | * @see \RecursiveIterator::valid() |
||
162 | * @see \Iterator::valid() |
||
163 | * |
||
164 | * @return bool |
||
165 | */ |
||
166 | 131 | public function valid(): bool { |
|
169 | } |
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.