1 | <?php |
||
20 | class ArrayList implements Collection |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * internal array |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $array; |
||
29 | |||
30 | /** |
||
31 | * ArrayList constructor. |
||
32 | * @param array $data |
||
33 | */ |
||
34 | public function __construct(array $data = []) |
||
38 | |||
39 | /** |
||
40 | * flush array list |
||
41 | * |
||
42 | * @return $this |
||
43 | */ |
||
44 | public function clear() |
||
49 | |||
50 | /** |
||
51 | * returns element with key $key |
||
52 | * @param $key |
||
53 | * @return mixed|null |
||
54 | */ |
||
55 | public function get($key) |
||
59 | |||
60 | /** |
||
61 | * Returns the value of the array element that's currently being pointed to by the |
||
62 | * internal pointer. It does not move the pointer in any way. If the |
||
63 | * internal pointer points beyond the end of the elements list or the array is |
||
64 | * empty, current returns false. |
||
65 | * |
||
66 | * @return mixed|false |
||
67 | */ |
||
68 | public function current() |
||
72 | |||
73 | /** |
||
74 | * Advance the internal array pointer of an array. |
||
75 | * Returns the array value in the next place that's pointed to by the |
||
76 | * internal array pointer, or false if there are no more elements. |
||
77 | * |
||
78 | * @return mixed|false |
||
79 | */ |
||
80 | public function next() |
||
84 | |||
85 | /** |
||
86 | * Rewind the internal array pointer. |
||
87 | * Returns the array value in the previous place that's pointed to by |
||
88 | * the internal array pointer, or false if there are no more |
||
89 | * |
||
90 | * @return mixed|false |
||
91 | */ |
||
92 | public function prev() |
||
96 | |||
97 | /** |
||
98 | * Inserts or replaces the element at the specified position in this list with the specified element. |
||
99 | * |
||
100 | * @param $key |
||
101 | * @param $element |
||
102 | * @return $this |
||
103 | */ |
||
104 | public function set($key, $element) |
||
109 | |||
110 | /** |
||
111 | * overrides contents of ArrayList with the contents of $array |
||
112 | * @param array $array |
||
113 | * @return $this |
||
114 | */ |
||
115 | public function setArray(array $array) |
||
119 | |||
120 | /** |
||
121 | * Appends the specified element to the end of this list. |
||
122 | * |
||
123 | * @param $element |
||
124 | * @return $this |
||
125 | */ |
||
126 | public function append($element) |
||
131 | |||
132 | /** |
||
133 | * Inserts the specified element at the specified position in this list. If an other element already exist at the |
||
134 | * specified position the affected positions will transformed into a numerated array. As well the existing element |
||
135 | * as the specified element will be appended to this array. |
||
136 | * |
||
137 | * @param $key |
||
138 | * @param $element |
||
139 | * @return $this |
||
140 | */ |
||
141 | public function add($key, $element) |
||
154 | |||
155 | /** |
||
156 | * Removes the element at the specified position in this list. |
||
157 | * |
||
158 | * @param $key |
||
159 | * @return $this |
||
160 | */ |
||
161 | public function remove($key) |
||
166 | |||
167 | /** |
||
168 | * Returns true if an element exists on the specified position. |
||
169 | * |
||
170 | * @param mixed $key |
||
171 | * @return bool |
||
172 | */ |
||
173 | public function hasKey($key) |
||
177 | |||
178 | /** |
||
179 | * Returns true if the specified value exists in this list. Uses PHP's array_search function |
||
180 | * @link http://php.net/manual/en/function.array-search.php |
||
181 | * |
||
182 | * @param string $value |
||
183 | * |
||
184 | * @return mixed |
||
|
|||
185 | */ |
||
186 | public function hasValue($value) |
||
191 | |||
192 | /** |
||
193 | * replaces this list by the specified array |
||
194 | * @param array $data |
||
195 | * |
||
196 | * @return ArrayList |
||
197 | */ |
||
198 | public function replace(array $data) |
||
203 | |||
204 | /** |
||
205 | * {@inheritDoc} |
||
206 | */ |
||
207 | public function getIterator() |
||
211 | |||
212 | /** |
||
213 | * Offset to retrieve |
||
214 | * @link http://php.net/manual/en/arrayaccess.offsetget.php |
||
215 | * @param mixed $offset The offset to retrieve. |
||
216 | * |
||
217 | * @return mixed Can return all value types. |
||
218 | */ |
||
219 | public function offsetGet($offset) |
||
223 | |||
224 | /** |
||
225 | * Offset to set |
||
226 | * @link http://php.net/manual/en/arrayaccess.offsetset.php |
||
227 | * @param mixed $offset The offset to assign the value to. |
||
228 | * @param mixed $value The value to set. |
||
229 | */ |
||
230 | public function offsetSet($offset, $value) |
||
234 | |||
235 | /** |
||
236 | * Whether a offset exists |
||
237 | * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
||
238 | * |
||
239 | * @param mixed $offset |
||
240 | * @return bool |
||
241 | */ |
||
242 | public function offsetExists($offset) |
||
246 | |||
247 | /** |
||
248 | * Offset to unset |
||
249 | * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
||
250 | * @param mixed $offset The offset to unset. |
||
251 | */ |
||
252 | public function offsetUnset($offset) |
||
256 | |||
257 | /** |
||
258 | * {@inheritDoc} |
||
259 | */ |
||
260 | public function toArray() |
||
264 | |||
265 | /** |
||
266 | * {@inheritDoc} |
||
267 | */ |
||
268 | public function count() |
||
272 | |||
273 | /** |
||
274 | * Shuffles this list (randomizes the order of the elements in). It uses the PHP function shuffle |
||
275 | * @see http://php.net/manual/en/function.shuffle.php |
||
276 | * @return $this |
||
277 | */ |
||
278 | public function shuffle() { |
||
282 | |||
283 | /** |
||
284 | * returns a clone of this ArrayList, filtered by the given closure function |
||
285 | * @param \Closure $closure |
||
286 | * @return ArrayList |
||
287 | */ |
||
288 | public function filter(\Closure $closure) |
||
292 | |||
293 | /** |
||
294 | * returns a clone of this ArrayList, filtered by the given array keys |
||
295 | * @param array $keys |
||
296 | * @return ArrayList |
||
297 | */ |
||
298 | public function filterByKeys(array $keys) |
||
306 | } |
||
307 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.