1 | <?php |
||
15 | class SlicedIterator implements \Iterator |
||
16 | { |
||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | private $iterator; |
||
21 | |||
22 | /** |
||
23 | * @var int |
||
24 | */ |
||
25 | private $cursor = 0; |
||
26 | |||
27 | /** |
||
28 | * SlicedIterator constructor. |
||
29 | * @param iterable $iterator |
||
30 | */ |
||
31 | public function __construct(iterable $iterator) |
||
35 | |||
36 | /** |
||
37 | * @param iterable $iterator |
||
38 | * @return array |
||
39 | */ |
||
40 | private function toArray(iterable $iterator): array |
||
44 | |||
45 | /** |
||
46 | * @return \Traversable |
||
47 | */ |
||
48 | public function getOuterIterator(): \Traversable |
||
56 | |||
57 | /** |
||
58 | * @param int $offset |
||
59 | * @return mixed|null |
||
60 | */ |
||
61 | public function lookahead(int $offset = 0) |
||
65 | |||
66 | /** |
||
67 | * @param int $offset |
||
68 | * @return \Traversable|SlicedIterator |
||
69 | */ |
||
70 | public function slice(int $offset): \Traversable |
||
78 | |||
79 | /** |
||
80 | * @param \Closure $filter |
||
81 | * @return \Traversable|SlicedIterator |
||
82 | */ |
||
83 | public function sliceWhile(\Closure $filter): \Traversable |
||
93 | |||
94 | /** |
||
95 | * @return mixed|null |
||
96 | */ |
||
97 | public function current() |
||
101 | |||
102 | /** |
||
103 | * @return void |
||
104 | */ |
||
105 | public function next(): void |
||
109 | |||
110 | /** |
||
111 | * @return int |
||
112 | */ |
||
113 | public function key(): int |
||
117 | |||
118 | /** |
||
119 | * @return bool |
||
120 | */ |
||
121 | public function valid(): bool |
||
126 | |||
127 | /** |
||
128 | * @return void |
||
129 | */ |
||
130 | public function rewind(): void |
||
134 | } |
||
135 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: