1 | <?php |
||
8 | class ArrayUtils |
||
9 | { |
||
10 | /** |
||
11 | * Explode an array on string. |
||
12 | * |
||
13 | * @param array $array |
||
14 | * @param string $explodeOn |
||
15 | * @param int $limit |null |
||
|
|||
16 | * |
||
17 | * @return array |
||
18 | */ |
||
19 | 1 | public static function explodeArrayOnKeys($array, $explodeOn, $limit = null) |
|
33 | |||
34 | /** |
||
35 | * Fill the array adding the missing keys from 0 to the max key, setting values to $value, and orders it. |
||
36 | * |
||
37 | * @param array $array |
||
38 | * @param string $value |
||
39 | * |
||
40 | * @return array |
||
41 | */ |
||
42 | 3 | public static function fillMissingKeys(array $array, $value = '') |
|
64 | |||
65 | /** |
||
66 | * Filter an array key. |
||
67 | * |
||
68 | * @param array $array |
||
69 | * @param string $value |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | 1 | public static function filterArrayOnKey(array $array, $value) |
|
83 | |||
84 | /** |
||
85 | * @param array $array |
||
86 | * @param string $separator |
||
87 | * |
||
88 | * @return array |
||
89 | */ |
||
90 | 2 | public static function flattenArray(array $array, $separator = '_') |
|
104 | |||
105 | /** |
||
106 | * @param array $array |
||
107 | * @param $prefix |
||
108 | * @param string $separator |
||
109 | * |
||
110 | * @return array |
||
111 | */ |
||
112 | 2 | public static function prefixArray(array $array, $prefix, $separator = '_') |
|
124 | |||
125 | /** |
||
126 | * Determine if an array is associative or not. |
||
127 | * |
||
128 | * @param array $input |
||
129 | * |
||
130 | * @return bool |
||
131 | */ |
||
132 | 3 | public static function isAssociativeArray(array $input) |
|
136 | |||
137 | /** |
||
138 | * Returns whether the array has numeric keys in order 0, 1, ... n or not. |
||
139 | * |
||
140 | * @param array $array |
||
141 | * |
||
142 | * @return bool |
||
143 | */ |
||
144 | 1 | public static function isIndexedArray(array $array) |
|
148 | |||
149 | /** |
||
150 | * Calculate the depth of an array. |
||
151 | * Be aware of array with references to other places in the same array. This can cause memory exhaustion. |
||
152 | * |
||
153 | * @param array $array |
||
154 | * @param bool $deReference deReference should the array values be de-referenced first? |
||
155 | * |
||
156 | * @throws \RuntimeException |
||
157 | * @throws \InvalidArgumentException |
||
158 | * |
||
159 | * @return int |
||
160 | */ |
||
161 | 2 | public static function calculateArrayDepth(array $array, $deReference = false) |
|
180 | |||
181 | /** |
||
182 | * Merge two arrays together (kinda). And a bit of replace. |
||
183 | * Copy the values of source array into the target array, when the keys are numerical . |
||
184 | * this function is scheduled for replacement, please use array_merge or array_replace. |
||
185 | * |
||
186 | * @param array $targetArray targetArray |
||
187 | * @param array $sourceArray sourceArray |
||
188 | * @param bool $combineUnique |
||
189 | * |
||
190 | * @deprecated please use array_merge or array_replace |
||
191 | * |
||
192 | * @return array |
||
193 | */ |
||
194 | 1 | public static function mergeRecursive(array $targetArray, array $sourceArray, $combineUnique = true) |
|
217 | |||
218 | /** |
||
219 | * @param array $haystack |
||
220 | * @param array ...$needles |
||
221 | * |
||
222 | * @return bool |
||
223 | */ |
||
224 | 1 | public static function hasAllKeys(array $haystack, ...$needles) |
|
234 | |||
235 | /** |
||
236 | * @param array $haystack |
||
237 | * @param array ...$needles |
||
238 | * |
||
239 | * @return bool |
||
240 | */ |
||
241 | 1 | public static function hasAnyKey(array $haystack, ...$needles) |
|
251 | |||
252 | /** |
||
253 | * Convert an array to camelcased key version |
||
254 | * |
||
255 | * @param array $array |
||
256 | * |
||
257 | * @throws \InvalidArgumentException |
||
258 | * @throws \Ddeboer\Transcoder\Exception\UnsupportedEncodingException |
||
259 | * @throws \Ddeboer\Transcoder\Exception\ExtensionMissingException |
||
260 | * |
||
261 | * @return array |
||
262 | */ |
||
263 | 2 | public static function toUnderscore(array $array = []) |
|
276 | } |
||
277 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.