1 | <?php |
||
16 | class PushbackIterator implements \Iterator |
||
17 | { |
||
18 | /** |
||
19 | * Nested iterator |
||
20 | * |
||
21 | * @var \Iterator |
||
22 | */ |
||
23 | private $nestedIterator; |
||
24 | |||
25 | /** |
||
26 | * Unread item from previous iteration |
||
27 | * |
||
28 | * @var string[] |
||
29 | */ |
||
30 | private $unreadItems; |
||
31 | |||
32 | /** |
||
33 | * Result of previous iteration |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | private $lastIterationResult; |
||
38 | |||
39 | /** |
||
40 | * String length to return from this iterator |
||
41 | * |
||
42 | * @var int |
||
43 | */ |
||
44 | private $chunkSize; |
||
45 | |||
46 | /** |
||
47 | * Iteration key |
||
48 | * |
||
49 | * @var int |
||
50 | */ |
||
51 | private $key; |
||
52 | |||
53 | /** |
||
54 | * Length of last result push back |
||
55 | * |
||
56 | * @var int |
||
57 | */ |
||
58 | private $backLength; |
||
59 | |||
60 | /** |
||
61 | * PushbackIterator constructor. |
||
62 | * |
||
63 | * @param \Iterator $nestedIterator Nested iterator |
||
64 | * @param int $chunkSize Max length of string to return |
||
65 | */ |
||
66 | 37 | public function __construct(\Iterator $nestedIterator, $chunkSize) |
|
72 | |||
73 | /** |
||
74 | * @inheritDoc |
||
75 | */ |
||
76 | 19 | public function current() |
|
80 | |||
81 | /** |
||
82 | * @inheritDoc |
||
83 | */ |
||
84 | 16 | public function next() |
|
99 | |||
100 | /** |
||
101 | * @inheritDoc |
||
102 | */ |
||
103 | 5 | public function key() |
|
107 | |||
108 | /** |
||
109 | * @inheritDoc |
||
110 | */ |
||
111 | 41 | public function valid() |
|
115 | |||
116 | /** |
||
117 | * @inheritDoc |
||
118 | */ |
||
119 | 37 | public function rewind() |
|
127 | |||
128 | /** |
||
129 | * Return given length of previously read string back into iterator |
||
130 | * |
||
131 | * @param int $length Length of string to return back |
||
132 | * |
||
133 | * @return void |
||
134 | */ |
||
135 | 7 | public function unread($length) |
|
144 | |||
145 | /** |
||
146 | * Test if iterator has unread item |
||
147 | * |
||
148 | * @return bool |
||
149 | */ |
||
150 | 41 | private function hasUnreadItem() |
|
154 | |||
155 | /** |
||
156 | * Build chunk to return to user |
||
157 | * |
||
158 | * @return string |
||
159 | */ |
||
160 | 37 | private function buildChunk() |
|
186 | |||
187 | /** |
||
188 | * @inheritDoc |
||
189 | */ |
||
190 | 3 | public function __toString() |
|
194 | |||
195 | /** |
||
196 | * Return an item caused by unread operation |
||
197 | * |
||
198 | * @return void |
||
199 | */ |
||
200 | 37 | private function popLastPushedBackItem() |
|
214 | } |
||
215 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..