1 | <?php |
||
48 | class ItemList implements ItemListInterface |
||
49 | { |
||
50 | /** |
||
51 | * Items |
||
52 | * |
||
53 | * @var ItemInterface[] |
||
54 | */ |
||
55 | protected $items; |
||
56 | |||
57 | /** |
||
58 | * Internal pointer |
||
59 | * |
||
60 | * @var int |
||
61 | */ |
||
62 | protected $pointer; |
||
63 | |||
64 | /** |
||
65 | * ItemList constructor |
||
66 | * |
||
67 | * @param ItemInterface[] $items Items |
||
68 | * @api |
||
69 | */ |
||
70 | 15 | public function __construct(array $items = []) |
|
75 | |||
76 | /** |
||
77 | * Return the current item |
||
78 | * |
||
79 | * @return ItemInterface Item |
||
80 | * @api |
||
81 | */ |
||
82 | 1 | public function current() |
|
86 | |||
87 | /** |
||
88 | * Move forward to next element |
||
89 | * |
||
90 | * @return void |
||
91 | * @api |
||
92 | */ |
||
93 | 1 | public function next() |
|
97 | |||
98 | /** |
||
99 | * Return the position of the current element |
||
100 | * |
||
101 | * @return int Position of the current element |
||
102 | * @api |
||
103 | */ |
||
104 | 1 | public function key() |
|
105 | { |
||
106 | 1 | return $this->pointer; |
|
107 | } |
||
108 | |||
109 | /** |
||
110 | * Checks if current position is valid |
||
111 | * |
||
112 | * @return boolean The current position is valid |
||
113 | * @api |
||
114 | */ |
||
115 | 1 | public function valid() |
|
119 | |||
120 | /** |
||
121 | * Rewind the item list to the first element |
||
122 | * |
||
123 | * @return void |
||
124 | * @api |
||
125 | */ |
||
126 | 1 | public function rewind() |
|
130 | |||
131 | /** |
||
132 | * Return an object representation of the item list |
||
133 | * |
||
134 | * @return \stdClass Micro information items |
||
135 | * @api |
||
136 | */ |
||
137 | 1 | public function toObject() |
|
147 | |||
148 | /** |
||
149 | * Return the first item, optionally of particular types |
||
150 | * |
||
151 | * @param array ...$types Item types |
||
152 | * @return ItemInterface Item |
||
153 | * @throws OutOfBoundsException If there are no matching items |
||
154 | * @api |
||
155 | */ |
||
156 | 3 | public function getFirstItem(...$types) |
|
170 | |||
171 | /** |
||
172 | * Return all items as an array, optionally filtered by item type(s) |
||
173 | * |
||
174 | * @param array ...$types Item types |
||
175 | * @return ItemInterface[] Items matching the requested types |
||
176 | * @api |
||
177 | */ |
||
178 | 4 | public function getItems(...$types) |
|
192 | |||
193 | /** |
||
194 | * Return the number of items in this list |
||
195 | * |
||
196 | * @return int Number of items |
||
197 | * @api |
||
198 | */ |
||
199 | 1 | public function count() |
|
203 | |||
204 | /** |
||
205 | * Generic item getter |
||
206 | * |
||
207 | * @param string $type Item type |
||
208 | * @param array $arguments Arguments |
||
209 | * @return ItemInterface Item |
||
210 | * @throws InvalidArgumentException If the item index is invalid |
||
211 | * @api |
||
212 | */ |
||
213 | 2 | public function __call($type, $arguments) |
|
231 | |||
232 | /** |
||
233 | * Return an item by type and index |
||
234 | * |
||
235 | * @param string $type Item type |
||
236 | * @param int $index Item index |
||
237 | * @return ItemInterface Item |
||
238 | * @throws OutOfBoundsException If the item index is out of bounds |
||
239 | */ |
||
240 | 2 | protected function getItemByTypeAndIndex($type, $index) |
|
255 | } |
||
256 |
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: