1 | <?php |
||
12 | trait ArrayListTrait |
||
13 | { |
||
14 | /** |
||
15 | * internal array |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $array; |
||
20 | |||
21 | /** |
||
22 | * flush array list |
||
23 | * |
||
24 | * @return $this |
||
25 | */ |
||
26 | public function clear() |
||
31 | |||
32 | /** |
||
33 | * returns element with key $key |
||
34 | * @param $key |
||
35 | * @return mixed|null |
||
36 | */ |
||
37 | public function get($key) |
||
41 | |||
42 | /** |
||
43 | * Returns the value of the array element that's currently being pointed to by the |
||
44 | * internal pointer. It does not move the pointer in any way. If the |
||
45 | * internal pointer points beyond the end of the elements list or the array is |
||
46 | * empty, current returns false. |
||
47 | * |
||
48 | * @return mixed|false |
||
49 | */ |
||
50 | public function current() |
||
54 | |||
55 | /** |
||
56 | * Advance the internal array pointer of an array. |
||
57 | * Returns the array value in the next place that's pointed to by the |
||
58 | * internal array pointer, or false if there are no more elements. |
||
59 | * |
||
60 | * @return mixed|false |
||
61 | */ |
||
62 | public function next() |
||
66 | |||
67 | /** |
||
68 | * Rewind the internal array pointer. |
||
69 | * Returns the array value in the previous place that's pointed to by |
||
70 | * the internal array pointer, or false if there are no more |
||
71 | * |
||
72 | * @return mixed|false |
||
73 | */ |
||
74 | public function prev() |
||
78 | |||
79 | /** |
||
80 | * Inserts or replaces the element at the specified position in this list with the specified element. |
||
81 | * |
||
82 | * @param $key |
||
83 | * @param $element |
||
84 | * @return $this |
||
85 | */ |
||
86 | public function set($key, $element) |
||
91 | |||
92 | /** |
||
93 | * overrides contents of ArrayList with the contents of $array |
||
94 | * @param array $array |
||
95 | * @return $this |
||
96 | */ |
||
97 | public function setArray(array $array) |
||
101 | |||
102 | /** |
||
103 | * Appends the specified element to the end of this list. |
||
104 | * |
||
105 | * @param $element |
||
106 | * @return $this |
||
107 | */ |
||
108 | public function append($element) |
||
113 | |||
114 | /** |
||
115 | * Inserts the specified element at the specified position in this list. If an other element already exist at the |
||
116 | * specified position the affected positions will transformed into a numerated array. As well the existing element |
||
117 | * as the specified element will be appended to this array. |
||
118 | * |
||
119 | * @param $key |
||
120 | * @param $element |
||
121 | * @return $this |
||
122 | */ |
||
123 | public function add($key, $element) |
||
136 | |||
137 | /** |
||
138 | * Removes the element at the specified position in this list. |
||
139 | * |
||
140 | * @param $key |
||
141 | * @return $this |
||
142 | */ |
||
143 | public function remove($key) |
||
148 | |||
149 | /** |
||
150 | * Returns true if an element exists on the specified position. |
||
151 | * |
||
152 | * @param mixed $key |
||
153 | * @return bool |
||
154 | */ |
||
155 | public function hasKey($key) |
||
159 | |||
160 | /** |
||
161 | * Returns true if the specified value exists in this list. Uses PHP's array_search function |
||
162 | * @link http://php.net/manual/en/function.array-search.php |
||
163 | * |
||
164 | * @param string $value |
||
165 | * |
||
166 | * @return mixed |
||
|
|||
167 | */ |
||
168 | public function hasValue($value) |
||
173 | |||
174 | /** |
||
175 | * replaces this list by the specified array |
||
176 | * @param array $data |
||
177 | * |
||
178 | * @return ArrayList |
||
179 | */ |
||
180 | public function replace(array $data) |
||
185 | |||
186 | /** |
||
187 | * {@inheritDoc} |
||
188 | */ |
||
189 | public function getIterator() |
||
193 | |||
194 | /** |
||
195 | * Offset to retrieve |
||
196 | * @link http://php.net/manual/en/arrayaccess.offsetget.php |
||
197 | * @param mixed $offset The offset to retrieve. |
||
198 | * |
||
199 | * @return mixed Can return all value types. |
||
200 | */ |
||
201 | public function offsetGet($offset) |
||
205 | |||
206 | /** |
||
207 | * Offset to set |
||
208 | * @link http://php.net/manual/en/arrayaccess.offsetset.php |
||
209 | * @param mixed $offset The offset to assign the value to. |
||
210 | * @param mixed $value The value to set. |
||
211 | */ |
||
212 | public function offsetSet($offset, $value) |
||
216 | |||
217 | /** |
||
218 | * Whether a offset exists |
||
219 | * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
||
220 | * |
||
221 | * @param mixed $offset |
||
222 | * @return bool |
||
223 | */ |
||
224 | public function offsetExists($offset) |
||
228 | |||
229 | /** |
||
230 | * Offset to unset |
||
231 | * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
||
232 | * @param mixed $offset The offset to unset. |
||
233 | */ |
||
234 | public function offsetUnset($offset) |
||
238 | |||
239 | /** |
||
240 | * {@inheritDoc} |
||
241 | */ |
||
242 | public function toArray() |
||
246 | |||
247 | /** |
||
248 | * {@inheritDoc} |
||
249 | */ |
||
250 | public function count() |
||
254 | |||
255 | /** |
||
256 | * Shuffles this list (randomizes the order of the elements in). It uses the PHP function shuffle |
||
257 | * @see http://php.net/manual/en/function.shuffle.php |
||
258 | * @return $this |
||
259 | */ |
||
260 | public function shuffle() { |
||
264 | |||
265 | /** |
||
266 | * returns a clone of this ArrayList, filtered by the given closure function |
||
267 | * @param \Closure $closure |
||
268 | * @return ArrayList |
||
269 | */ |
||
270 | public function filter(\Closure $closure) |
||
274 | |||
275 | /** |
||
276 | * returns a clone of this ArrayList, filtered by the given array keys |
||
277 | * @param array $keys |
||
278 | * @return ArrayList |
||
279 | */ |
||
280 | public function filterByKeys(array $keys) |
||
288 | } |
||
289 |
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.