1 | <?php |
||
15 | class LookaheadIterator extends \IteratorIterator |
||
16 | { |
||
17 | /** |
||
18 | * Current iterator. |
||
19 | * |
||
20 | * @var \Iterator |
||
21 | */ |
||
22 | protected $_iterator; |
||
23 | |||
24 | /** |
||
25 | * Current key. |
||
26 | * |
||
27 | * @var mixed |
||
28 | */ |
||
29 | protected $_key = 0; |
||
30 | |||
31 | /** |
||
32 | * Current value. |
||
33 | * |
||
34 | * @var mixed |
||
35 | */ |
||
36 | protected $_current; |
||
37 | |||
38 | /** |
||
39 | * Whether the current element is valid or not. |
||
40 | * |
||
41 | * @var bool |
||
42 | */ |
||
43 | protected $_valid = false; |
||
44 | |||
45 | /** |
||
46 | * LookaheadIterator constructor. |
||
47 | * @param \Traversable $iterator |
||
48 | */ |
||
49 | public function __construct(\Traversable $iterator) |
||
53 | |||
54 | /** |
||
55 | * Return the current element. |
||
56 | * |
||
57 | * @return mixed |
||
58 | */ |
||
59 | public function current() |
||
63 | |||
64 | /** |
||
65 | * Return the key of the current element. |
||
66 | * |
||
67 | * @return mixed |
||
68 | */ |
||
69 | public function key() |
||
73 | |||
74 | /** |
||
75 | * Rewind the iterator to the first element. |
||
76 | * |
||
77 | * @return void |
||
78 | */ |
||
79 | public function rewind() |
||
86 | |||
87 | /** |
||
88 | * Get inner iterator. |
||
89 | * |
||
90 | * @return \Iterator |
||
91 | */ |
||
92 | public function getInnerIterator() |
||
96 | |||
97 | /** |
||
98 | * Move forward to next element. |
||
99 | * |
||
100 | * @return void |
||
101 | */ |
||
102 | public function next() |
||
116 | |||
117 | /** |
||
118 | * Check if current position is valid. |
||
119 | * |
||
120 | * @return bool |
||
121 | */ |
||
122 | public function valid() |
||
126 | |||
127 | /** |
||
128 | * Check whether there is a next element. |
||
129 | * |
||
130 | * @return bool |
||
131 | */ |
||
132 | public function hasNext() |
||
136 | |||
137 | /** |
||
138 | * Get next value. |
||
139 | * |
||
140 | * @return mixed |
||
141 | */ |
||
142 | public function getNext() |
||
146 | |||
147 | /** |
||
148 | * Get next key. |
||
149 | * |
||
150 | * @return mixed |
||
151 | */ |
||
152 | public function getNextKey() |
||
156 | } |
||
157 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.